Common Tasks
Quick recipes for the tasks you will do most often. Each one is a brief, self-contained procedure.
Add a New API Endpoint
- Open the appropriate domain controller in
apps/backend/src/domains/<domain>/. - Add a new method with route decorator (
@Get(),@Post(), etc.). - Add
@Roles()to restrict access. - Add
@ApiOperation()and@ApiResponse()for Swagger docs. - Create a service method in the corresponding service file.
- Create a DTO in the
dto/directory if the endpoint accepts a request body. - Export the DTO from
dto/index.ts.
// In the controller
@Get(':id/summary')
@Roles(UserRole.DISPATCHER, UserRole.ADMIN, UserRole.OWNER)
@ApiOperation({ summary: 'Get resource summary' })
async getSummary(@Param('id') id: string, @CurrentUser() user: any) {
const tenantDbId = await this.getTenantDbId(user);
return this.service.getSummary(id, tenantDbId);
}Full tutorial: Adding an Endpoint
Add a New Page
- Create a directory under
apps/web/src/app/matching the desired URL path. - Create a
page.tsxfile inside it. - Import and render a feature component.
import { ReportsDashboard } from '@/features/operations/reports/components/ReportsDashboard';
export default function ReportsPage() {
return <ReportsDashboard />;
}The route is automatically registered. No router configuration needed.
Full guide: App Router Guide
Add a New Database Table
- Open
apps/backend/prisma/schema.prisma. - Add the new model:
model MaintenanceLog {
id Int @id @default(autoincrement())
logId String @unique @map("log_id") @db.VarChar(50)
description String
performedAt DateTime @map("performed_at") @db.Timestamptz
tenantId Int @map("tenant_id")
tenant Tenant @relation(fields: [tenantId], references: [id])
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
@@index([tenantId])
@@map("maintenance_logs")
}- Add the relation to the
Tenantmodel (if tenant-scoped). - Run the migration:
cd apps/backend
pnpm run prisma:migrate- Regenerate the Prisma client:
pnpm run prisma:generateFull guide: Database & Prisma
Install a New Shadcn Component
cd apps/web
pnpm dlx shadcn@latest add [component-name]For example:
pnpm dlx shadcn@latest add calendar
pnpm dlx shadcn@latest add checkbox
pnpm dlx shadcn@latest add radio-groupThe component is installed to src/shared/components/ui/. Import it in your code:
import { Calendar } from '@/shared/components/ui/calendar';Full reference: UI Standards
Add a New Feature Module
- Create the directory structure:
mkdir -p apps/web/src/features/<domain>/<feature>/{components,hooks,__tests__}- Create
api.tswith fetch functions. - Create
types.tswith TypeScript interfaces. - Create hooks in
hooks/using React Query. - Create components in
components/. - Create
index.tsbarrel export.
export * from './types';
export { useMyFeature } from './hooks/use-my-feature';Full guide: Feature Modules
Run Database Migrations
Create a new migration (after editing schema.prisma):
cd apps/backend
pnpm run prisma:migrateDeploy existing migrations (production):
cd apps/backend
pnpm run prisma:migrate:deployCheck migration status:
cd apps/backend
pnpm run prisma:migrate:statusSeed the Database
Base data (essential records):
cd apps/backend
pnpm run setup:baseDemo data (sample records for development):
cd apps/backend
pnpm run setup:demoReset and reseed (drops all data):
cd apps/backend
pnpm run setup:resetCheck seed status:
cd apps/backend
pnpm run setup:statusRun Tests
Backend unit tests:
cd apps/backend
pnpm run test # Run once
pnpm run test:watch # Watch mode
pnpm run test:cov # With coverage reportBackend E2E tests:
cd apps/backend
pnpm run test:e2eFrontend tests:
cd apps/web
pnpm run test # Run once
pnpm run test:watch # Watch modeAll tests via Turborepo:
pnpm run test # From project rootAccess Prisma Studio
Prisma Studio is a visual database browser. Run it from the project root:
pnpm run backend:prisma:studioOr from the backend directory:
cd apps/backend
pnpm run prisma:studioThis opens a web interface (typically at http://localhost:5555) where you can browse tables, view and edit records, and explore relationships.
Check API Docs (Swagger)
- Make sure the backend is running (
pnpm run backend:devorpnpm run dev). - Open http://localhost:8000/api in your browser.
- Click “Authorize” to enter a JWT token for authenticated endpoints.
- Browse endpoints grouped by tags (Drivers, Vehicles, Route Planning, etc.).
The OpenAPI spec is also available as JSON at http://localhost:8000/api/openapi.json.
Start and Stop Infrastructure
Start PostgreSQL and Redis:
pnpm run docker:upStop containers:
pnpm run docker:downView container logs:
pnpm run docker:logsRestart containers:
pnpm run docker:restartGenerate the Prisma Client
Run this after any schema change or fresh install:
pnpm run backend:prisma:generateOr from the backend directory:
cd apps/backend
pnpm run prisma:generateQuick Reference Table
| Task | Command | Run From |
|---|---|---|
| Start all apps | pnpm run dev | Root |
| Start backend only | pnpm run backend:dev | Root |
| Start frontend only | pnpm run frontend:dev | Root |
| Start docs only | pnpm run docs:dev | Root |
| Start Docker (DB + Redis) | pnpm run docker:up | Root |
| Stop Docker | pnpm run docker:down | Root |
| Install dependencies | pnpm install | Root |
| Run migrations | pnpm run prisma:migrate | apps/backend/ |
| Generate Prisma client | pnpm run backend:prisma:generate | Root |
| Open Prisma Studio | pnpm run backend:prisma:studio | Root |
| Seed base data | pnpm run setup:base | apps/backend/ |
| Seed demo data | pnpm run setup:demo | apps/backend/ |
| Reset database | pnpm run setup:reset | apps/backend/ |
| Run backend tests | pnpm run test | apps/backend/ |
| Run frontend tests | pnpm run test | apps/web/ |
| Build all | pnpm run build | Root |
| Add Shadcn component | pnpm dlx shadcn@latest add [name] | apps/web/ |
| View Swagger docs | Open http://localhost:8000/api | Browser |