Skip to main content

Project Structure

Concordia follows a well-organized, modular file structure designed for scalability and maintainability.

Root Directory Structure

Source Directory (src/)

The src/ directory contains all application source code:

Detailed Structure

Actions (src/actions/)

Server-side business logic and data mutations.
Purpose:
  • Encapsulate business logic
  • Handle data validation
  • Perform database mutations
  • Return type-safe results
Example:

Components (src/components/)

Reusable UI components organized by domain and purpose.
Organization Pattern:
  • modules/ - Domain-specific components (blog, services, places)
  • templates/ - Page-level layouts and sections
  • ui/ - Reusable, generic UI components
  • Tools/ - Layout and utility components
  • admin/ - Admin-only components

Database (src/database/)

Database schemas, migrations, loaders, and seed data.
Key Files: drizzle.ts - Database connection and configuration:
schemas.ts - Centralized schema exports:
loaders/ - Data loading utilities:

Library (src/lib/)

Shared utilities, helpers, and services.

Pages (src/pages/)

File-based routing structure.
Routing Patterns:
  • [lang]/ - Dynamic language parameter (fr, en, ar, es)
  • [slug].astro - Dynamic route for content
  • [...all].ts - Catch-all route
  • api/ - Server-side API endpoints
Example Routes:

Internationalization (src/i18n/)

Translation files organized by locale.
Translation Structure:

Styles (src/styles/)

Global CSS and design tokens.

Testing Structure


Scripts Directory

Common Commands:

Configuration Files

astro.config.mjs

Astro framework configuration:

drizzle.config.ts

Drizzle ORM configuration:

tsconfig.json

TypeScript configuration:

Naming Conventions

Files

  • Components: PascalCase.astro (e.g., PostCard.astro)
  • Utilities: kebab-case.ts (e.g., locale-url.ts)
  • Schemas: entity_name.schema.ts (e.g., blog_posts.schema.ts)
  • Tests: *.test.ts or *.spec.ts

Code

  • Variables/Functions: camelCase
  • Types/Interfaces: PascalCase
  • Constants: SCREAMING_SNAKE_CASE
  • Database Tables: snake_case

Best Practices

  1. Colocation: Keep related files close (components, styles, tests)
  2. Feature Modules: Group by domain/feature, not by file type
  3. Index Files: Use index.ts for clean imports
  4. Type Imports: Import types from schemas, not from ORM
  5. Barrel Exports: Export from index.ts for public APIs

Next Steps