Backend Architecture
NestJS modules, database, scheduler, real-time communication, and external integrations in the server.
Module Structure
The backend is a NestJS 11 application organized into four architectural layers:
| Layer | Responsibility |
|---|---|
api/ | oRPC procedures, REST controllers, DTOs |
application/ | Use cases, command handlers, sagas, guards |
modules/ | Feature modules (messaging, events, assistant, jobs) |
infrastructure/ | Database, Redis, BullMQ, email, AI, secrets |
Dependencies point inward: API depends on Application, which depends on Domain interfaces. Infrastructure implements those interfaces. NestJS dependency injection wires everything at the module level.
Database
PostgreSQL is the primary data store, accessed through Prisma 7 ORM. The Prisma schema
defines all models and migrations. Repository interfaces live in the domain layer; implementations
live in infrastructure. The PrismaModule provides the Prisma client globally.