How javier13g/backendrealstate works
Project type and purpose
• This is a backend API project built with NestJS (a Node.js framework), using Prisma as the ORM and MongoDB as the data store.
• It exposes RESTful HTTP endpoints (controllers) for authentication (JWT), user management, roles, and status‐user management.
File structure
• Top-level folders & files:
• src/ : all application code
• prisma/ : Prisma schema & client generation
• test/ : end‐to‐end tests
• Inside src/ you see distinct NestJS modules:
• auth/
• users/
• roles/
• status-user/
• common/ (shared filters)
• prisma/ (PrismaService & module)
• Core NestJS files: app.module.ts (root module), main.ts (bootstrap), app.service, app.controller.
• Configuration files for TypeScript, ESLint, Nest CLI, Prettier, and package.json scripts.
README
• Confirms NestJS + Prisma + MongoDB + JWT stack.
a. Main components:
• HTTP Client (e.g., browser or mobile app)
• NestJS API Server
– API Gateway / Entry Point (main.ts)
– Controllers (AuthController, UsersController, RolesController, StatusUserController, AppController)
– Services (AuthService, UsersService, RolesService, StatusUserService, AppService)
– Shared/Common Filters (e.g., HTTP exception filter)
– Prisma Module & PrismaService (database access abstraction)
• MongoDB Database
• External JWT lib (used by AuthService, but part of the API server)
b. Relationships & interactions:
1. Client → NestJS HTTP Listener
2. HTTP Request routed to appropriate Controller
3. Controller calls its Service
4. Service uses PrismaService to query/update MongoDB
5. PrismaService translates service calls into MongoDB operations
6. DB returns results → Service applies business logic → Controller returns HTTP response
7. Auth flows: incoming credentials → AuthService verifies via Prisma → issues JWT → client stores token for subsequent calls
c. Architectural patterns & principles:
• Modular monolith: each feature (auth, users, roles, status‐user) is its own Nest module
• Layered architecture: Controller (entry point) → Service (business logic) → Repository/ORM (Prisma) → Database
• Dependency Injection: modules import/supply PrismaService and share common filters
• DTOs for input validation (in each module’s dto folder)
d. Technologies & frameworks:
• NestJS (framework; modules, controllers, services)
• TypeScript (language)
• Prisma ORM (PrismaService, schema.prisma)
• MongoDB (NoSQL document store)
• JWT (stateless authentication)