How forkjustrubik/user_service-rubik_fork works
Project Type and Purpose
• This is a modular, server-side REST API built with the NestJS framework (Node.js + TypeScript).
• Its purpose is to provide user authentication (sign-up, sign-in, JWT issuance/refresh), user profile retrieval, and account-helper operations (password reset/update).
• It follows NestJS’s modules + dependency injection + TypeORM for Postgres.
File Structure Analysis
• Top level:
• Dockerfile, .github/workflows: CI/CD and containerization
• package.json, tsconfig.json, lint/ESLint/Prettier configs
• src/
• main.ts and app.module.ts: application entry and root DI container
• src/commons: cross-cutting concerns
– configuration (Postgres module), database layer (TypeORM entities, DTOs, repos), guards, middleware, security utils, strategies, wrappers
• src/modules: feature modules
– auth: sign-up, sign-in, refresh, JWT strategies
– user: get profile, change password
– account-helper: request/reset/update password flows
• test/: e2e suite
README Insights
• Generic Nest starter; confirms use of NestJS core, CLI, and recommended deployment practices.
Components
a. Main Components
• Client (browser/mobile/other service)
• NestJS REST API server
• Controllers (AuthController, UserController, AccountHelperController)
• Services (AuthService, UserService, AccountHelperService)
• Commons layer
– Guards (JWTAuthGuard, JWTAdminGuard)
– Strategies (JWT, local)
– Middleware (BasicAuth)
– Database Repositories (UserRepo, TokenRepo, OtpCodeRepo)
• PostgreSQL database
• (Optional) External Email Service for password reset notifications
b. Relationships & Data Flow
1. Client issues HTTP requests → appropriate Controller endpoint
2. Controller calls Service methods
3. Service applies business logic, calls Repo to query/write Entities via TypeORM
4. Repos interact with Postgres
5. Service returns data/DTO to Controller → Controller wraps in ResponseWrapper → HTTP response
6. Guards/Strategies intercept requests for authentication/authorization
c. Architectural Patterns
• Layered architecture:
Presentation (controllers) → Business (services) → Data (repos/entities)
• Modular segmentation: commons vs. feature modules
• Dependency Injection (Nest’s DI container)
• Use of DTOs for validation and typing
• Guards & Strategies for cross-cutting security
d. Key Technologies
• NestJS (Framework, Modules, Controllers, Providers)
• TypeScript
• TypeORM (Entities, DTOs, Repositories)
• PostgreSQL
• JWT for auth, bcrypt or similar for password encoding
• Docker for containerization, GitHub Actions for CI/CD