Deep DivesAPI
Development
Local development guide for the RawStack API component.
Setup
cd apps/api
npm install
docker compose up -d
cp .env.dist .env
npm run devThe API starts on http://localhost:3001. OpenAPI docs are served at http://localhost:3001/docs.
Project structure
apps/api/
├── src/
│ ├── main.ts # Bootstrap — NestJS app, Zod pipes, Swagger
│ ├── app.module.ts # Root module
│ ├── auth/ # Auth module (CQRS + DDD)
│ ├── user/ # User module (CQRS + DDD)
│ └── common/ # Shared filters, base models
├── prisma/
│ ├── schema.prisma # Database schema
│ └── migrations/ # Migration history
├── test/
│ ├── unit/ # Jest unit tests
│ ├── integration/ # Integration tests (real DB)
│ └── e2e/ # End-to-end API tests
├── docker-compose.yml
├── .env.dist
└── DockerfileAdding a new module
Follow the existing auth or user module as a template:
- Create
src/<module>/domain/— entities, value objects, repository interfaces - Create
src/<module>/application/— commands, queries, handlers - Create
src/<module>/infrastructure/— controllers, Prisma repos, sagas - Register the module in
app.module.ts
Database migrations
# Generate a new migration from schema changes
npx prisma migrate dev --name <migration-name>
# Apply migrations (production)
npx prisma migrate deploy
# Open Prisma Studio (GUI)
npx prisma studioUseful scripts
| Script | Description |
|---|---|
npm run dev | Start with watch mode + auto-migrate |
npm run build | Compile TypeScript |
npm run lint | ESLint |
npm run format | Prettier |