How miguelba18/sideo-backend works
1. This is a NestJS TypeScript backend organized as a modular monolith. The application boots from src/main.ts, loads the root AppModule, and exposes feature controllers through Nest’s dependency-injection and module system.
2. The top-level architecture is split into shared infrastructure in src/common, configuration in src/config, persistence/bootstrap data in src/database, and business features under src/modules. Each feature module follows the same shape: controller, service, DTOs, and entity models.
3. src/common contains the cross-cutting security layer. It defines custom decorators for current user, roles, and permissions, plus guards for JWT authentication, role-based access, permission checks, and subscription checks. This is the main enforcement boundary around protected routes.
4. Authentication is handled by src/modules/auth. It provides login, registration, profile completion, and password-change flows, backed by a JWT strategy. This module is the entry point for identity and token issuance, and its controller/service likely coordinate with the users and roles modules.
5. User and access control data is separated into users and roles. The roles module models roles, permissions, and role-permission relations, while the users module manages evaluator/user profiles. The database seeds include initial roles/permissions and a superadmin account, indicating the app expects a preloaded authorization baseline.
6. Business data appears to center on organizational management: companies, employees, and subscriptions. Companies and employees are separate domain modules, while subscriptions track plan/state changes such as creation, renewal, upgrade, and status. The subscription guard suggests plan state directly gates some routes or features.
7. Evaluations are a major domain subsystem. src/modules/evaluations stores evaluation records plus a detail entity, and includes a rosa-calculator helper, which implies business logic for scoring or assessment computation is encapsulated here rather than in controllers.
8. Reporting and dashboards are read-oriented aggregation layers. reports likely produces persisted or generated reports from the core domain data, while dashboard likely collects summary metrics for the UI/API consumer. These modules sit on top of the core entities rather than owning primary workflow state.
9. mailer is a separate utility module for outbound email workflows. It has its own DTOs, entity, controller, service, and module, so email delivery is treated as an application boundary rather than embedded inside auth or subscriptions.
10. The codebase is entity-driven and DTO-based throughout. DTOs define request/command payloads at the API boundary, entities define persistence models, and services hold the domain/application logic. Controllers are thin adapters that translate HTTP requests into service calls.
11. The persistence layer is configured via src/config/database.config.ts and initialized with seed scripts under src/database/seeds. Even though the exact ORM is not shown here, the presence of entities and seeds indicates a database-backed architecture with bootstrap data for authorization and admin setup.
12. Testing is built into the structure with unit specs alongside each module and an E2E test suite under test/. Deployment artifacts like Dockerfile and procfile suggest the service is intended to run as a containerized Node/Nest backend in production.
Main entry points: app.module.ts App module · auth.module.ts Auth · evaluations.module.ts Evaluations · reports.module.ts Reports
Components 20
Bootstrap
Application entrypoint and Nest root wiring
- main · Starts Nest and loads the app module
src/main.ts - App module · Root composition of the monolith
src/app.module.ts
Shared
Cross-cutting guards, decorators, and enums
- Security · Current-user, roles, permissions, JWT, and subscription enforcement
src/common
Data
Configuration, database setup, and seed data
- DB config · Database connection settings
src/config/database.config.ts - Auth seed · Initial roles and permissions bootstrap data
src/database/seeds/roles-permissions.seed.ts - Superadmin seed · Bootstrap admin account
src/database/seeds/superadmin.seed.ts
Features
Business modules under Nest DI
- Auth · Login, registration, profile completion, and password change
src/modules/auth/auth.module.ts - Auth API · HTTP entrypoint for identity flows
src/modules/auth/auth.controller.ts - Auth service · Authentication and token orchestration
src/modules/auth/auth.service.ts - JWT strategy · Token validation strategy
src/modules/auth/strategies/jwt.strategy.ts - Users · Evaluator and profile management
src/modules/users/users.module.ts - Roles · Roles, permissions, and role-permission relations
src/modules/roles/roles.module.ts - Companies · Company domain management
src/modules/companies/company.module.ts - Employees · Employee domain management
src/modules/employees/employees.module.ts - Subscriptions · Plan lifecycle and status management
src/modules/subscriptions/subscriptions.module.ts - Evaluations · Evaluation records and scoring workflows
src/modules/evaluations/evaluations.module.ts - Rosa calc · Evaluation scoring logic
src/modules/evaluations/rosa/rosa-calculator.ts - Reports · Read-oriented report generation
src/modules/reports/reports.module.ts - Dashboard · Aggregated summary metrics
src/modules/dashboard/dashboard.module.ts - Mailer · Outbound email workflows
src/modules/mailer/mailer.module.ts
Connections 31
- main → App module: boots · Nest application starts from the root module
- App module → Security: uses · Shared guards and decorators protect feature routes
- App module → DB config: configures · Wires database connection settings
- App module → Auth seed: seeds · Bootstraps authorization baseline
- App module → Superadmin seed: seeds · Bootstraps the superadmin account
- App module → Auth: imports · Registers auth feature
- App module → Users: imports · Registers users feature
- App module → Roles: imports · Registers roles feature
- App module → Companies: imports · Registers companies feature
- App module → Employees: imports · Registers employees feature
- App module → Subscriptions: imports · Registers subscriptions feature
- App module → Evaluations: imports · Registers evaluations feature
- App module → Reports: imports · Registers reports feature
- App module → Dashboard: imports · Registers dashboard feature
- App module → Mailer: imports · Registers mailer feature
- Auth → Auth API: exposes · HTTP API surface
- Auth → Auth service: provides · Business logic for auth flows
- Auth → JWT strategy: uses · Validates bearer tokens
- Auth service → Users: depends on · Coordinates identity/profile data
- Auth service → Roles: depends on · Uses roles and permissions for access-related flows
- Users → Roles: relates to · User profiles intersect with access control
- Roles → Security: feeds · Role and permission checks are enforced by shared guards
- Subscriptions → Security: gates · Subscription guard protects feature access
- Evaluations → Rosa calc: uses · Encapsulates scoring logic
- Evaluations → Companies: depends on · Evaluations likely reference company context
- Evaluations → Employees: depends on · Evaluations likely reference employee context
- Reports → Evaluations: reads · Reports aggregate evaluation data
- Reports → Companies: reads · Reports aggregate company data
- Dashboard → Reports: summarizes · Dashboard presents higher-level metrics
- Mailer → Auth: supports · Email flows can back auth workflows
- Mailer → Subscriptions: supports · Email flows can back subscription workflows