Skip to content

Latest commit

Β 

History

History
132 lines (110 loc) Β· 3.79 KB

File metadata and controls

132 lines (110 loc) Β· 3.79 KB

Project Structure

Directory Layout

matters-server/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ common/           # Shared utilities and constants
β”‚   β”‚   β”œβ”€β”€ enums/       # Enumeration definitions
β”‚   β”‚   β”œβ”€β”€ errors/      # Custom error classes
β”‚   β”‚   └── utils/       # Utility functions
β”‚   β”‚
β”‚   β”œβ”€β”€ connectors/      # Database and external service connectors
β”‚   β”‚   β”œβ”€β”€ __test__/   # Connector tests
β”‚   β”‚   └── *.ts        # Service implementations
β”‚   β”‚
β”‚   β”œβ”€β”€ definitions/     # Type definitions and interfaces
β”‚   β”‚   └── *.ts        # TypeScript type definitions
β”‚   β”‚
β”‚   β”œβ”€β”€ mutations/       # GraphQL mutation resolvers
β”‚   β”‚   └── *.ts        # Mutation implementations
β”‚   β”‚
β”‚   β”œβ”€β”€ queries/         # GraphQL query resolvers
β”‚   β”‚   └── *.ts        # Query implementations
β”‚   β”‚
β”‚   β”œβ”€β”€ types/          # GraphQL type definitions
β”‚   β”‚   β”œβ”€β”€ __test__/   # Type tests
β”‚   β”‚   └── *.ts        # GraphQL schema types
β”‚   β”‚
β”‚   └── utils/          # Application utilities
β”‚       └── *.ts        # Helper functions
β”‚
β”œβ”€β”€ db/                 # Database related files
β”‚   β”œβ”€β”€ migrations/     # Database migrations
β”‚   β”œβ”€β”€ seeds/         # Database seed files
β”‚   └── bin/           # Database scripts
β”‚
β”œβ”€β”€ docs/              # Documentation
β”‚   └── *.md          #  Documentation files
β”‚
β”œβ”€β”€ .env.example       # Environment variables template
β”œβ”€β”€ package.json       # NPM package configuration
└── README.md         # Project overview

Key Components

1. GraphQL Layer

  • Types: Define GraphQL schema types in src/types/
  • Queries: Implement query resolvers in src/queries/
  • Mutations: Implement mutation resolvers in src/mutations/

2. Data Layer

  • Connectors: Database and external service connections in src/connectors/
  • Migrations: Database schema changes in db/migrations/
  • Seeds: Initial data population in db/seeds/

3. Testing

  • Unit Tests: Located in __test__ directories
  • Test Utilities: Common test setup in src/types/__test__/utils.js
  • Test Mode: Special testing configurations in docs/Test-Mode.md

4. Common Utilities

  • Enums: Shared constants in src/common/enums/
  • Errors: Custom error classes in src/common/errors/
  • Utils: Helper functions in src/common/utils/

Development Workflow

  1. Setup

    npm install
    cp .env.example .env
    npm run db:migrate
  2. Database Changes

    # Create migration
    npm run db:migration:make <name>
    
    # Create seed
    npm run db:seed:make <name>
    
    # Run migrations
    npm run db:migrate
  3. Testing

    # Run all tests
    npm run test
    
    # Run specific test
    npm run test -- <test-file>
  4. Development

    # Start development server
    npm run start:dev

Key Files

  • Environment: .env.example - Template for environment variables
  • Database: db/migrations/ - Database schema changes
  • GraphQL: src/types/ - GraphQL schema definitions
  • Tests: src/**/__test__/ - Test files
  • Documentation: docs/ - Project documentation

Best Practices

  1. Code Organization

    • Keep related files together
    • Use clear, descriptive names
    • Follow TypeScript best practices
  2. Testing

    • Write tests for new features
    • Follow test guidelines in docs/Unittest.md
    • Use test mode for development
  3. Database

    • Use migrations for schema changes
    • Include rollback scripts
    • Document complex queries
  4. Documentation

    • Keep README up to date
    • Document complex logic
    • Include examples in tests