Production-oriented NestJS + Prisma + PostgreSQL backend for real-estate listings.
- NestJS 11 / TypeScript
- Prisma 7 + PostgreSQL
- JWT auth (admin password + client OTP)
- Helmet, CORS, throttling, global validation
- Copy env and adjust secrets:
cp .env.example .env- Start Postgres (Docker):
docker compose up -d db- Install, migrate, run:
npm install
npx prisma migrate dev
npm run start:devAPI base: http://127.0.0.1:4000/api
Health: GET /api/health
| Endpoint | Access | Description |
|---|---|---|
POST /api/auth/admin/register |
Public (first admin only) | Bootstrap super-admin |
POST /api/auth/admin/login |
Public | Admin login → JWT |
POST /api/auth/admin/create |
Super admin | Create another admin |
POST /api/auth/otp/request |
Public | Request client OTP |
POST /api/auth/otp/verify |
Public | Verify OTP → JWT |
Send Authorization: Bearer <token> on protected routes.
- CLIENT — own profile, apartments, favorites
- ADMIN — catalog CRUD, client management
- SUPER_ADMIN — admin management + all admin powers
Public read access: apartments, categories, cities, districts, locations.
cp .env.example .env
# set JWT_SECRET and NODE_ENV=production
docker compose up --build| Script | Purpose |
|---|---|
npm run start:dev |
Watch mode |
npm run build |
Compile |
npm run start:prod |
Run dist/main |
npm run lint |
ESLint |
npx prisma migrate dev |
Create/apply migrations |
npx prisma studio |
DB UI |