The source of truth for technical detail is the code itself. This section captures the high-level architecture; the low-level database schema, API models, and endpoint contracts are generated from — and kept in sync by — the code:

<aside> 📚

Technical reference (authoritative, always current):

Layered Architecture

The codebase follows a strict, one-directional layering — a layer never skips the one below it (for example, a React component never calls a service directly; it goes through a query hook).

flowchart TB
  subgraph Backend
    direction TB
    E["persistence — *_entity.py"] --> S["service — *_service.py"] --> R["router — *_router.py"]
  end
  subgraph Frontend
    direction TB
    FS["FE service — *.service.ts"] --> Q["query layer — *.queries.ts"] --> P["presentational — components / pages"]
  end
  R -->|HTTP / JSON| FS

Layers

Naming conventions

A suffix tells you the layer and shape at a glance:

Suffix / file Layer Meaning
FooEntity / foo_entity.py persistence SQLAlchemy model — one DB table
FooDto / foo_model.py API contract Pydantic request/response schema
FooService / foo_service.py service Business logic for a domain
foo_router.py router FastAPI endpoints for a domain
foo.service.ts FE service Typed Axios client for a domain
foo.queries.ts query layer React Query hooks for a domain
foo.types.ts FE types Frontend DTOs + convertFoo mappers

Domains

Each backend domain under backend/src/modules/<name>/ follows the same four-file pattern (_entity / _model / _service / _router): account, auth, party, student, police, incident, location, notification. Each frontend domain mirrors it with a *.service.ts / *.queries.ts / *.types.ts trio under frontend/src/lib/api/<domain>/.

3.4. Frontend Conventions