The context
Quizzam is a REST backend API developed with NestJS, demonstrating mastery of modern software architecture patterns. This project was developed from scratch as part of training, with a particular focus on modular architecture and separation of concerns.
NestJS was chosen over pure Node.js for its predefined architecture and native TypeScript support, facilitating team development and ensuring better code maintainability. Unlike Node.js which lacks a standard software architecture, NestJS imposes rules and conventions that structure the project.
The application implements an architecture allowing to switch between different databases using dependency injection (MongoDB, Firebase) without modifying business logic, with an In-Memory adapter for tests. The CQRS pattern separates read and write operations, which can improve performance, scalability, and security of an application (even though in our case, it's a small fictional project that doesn't scale).
The authentication system is also flexible, supporting JWT and Firebase Auth depending on configuration. Complete E2E tests with Supertest and unit tests with Jest ensure code quality.
What I learn :
- Architecture and Patterns:
- Ports & Adapters pattern: database abstraction (MongoDB, Firebase) with In-Memory adapter for tests
- CQRS (Command Query Responsibility Segregation): separation of read/write operations to improve performance, scalability, and security
- Inversion of Control (IoC) and Dependency Injection (DI) via NestJS
- Modular architecture: organization into functional modules (Quiz, User, Auth, Chat)
- Backend Technologies:
- NestJS: progressive framework with native TypeScript support
- TypeScript: static typing for better maintainability
- Express: HTTP server for REST routes
- Socket.io: real-time communication for chat and quiz execution
- Data Management:
- Multi-database support: MongoDB, Firebase Firestore, with In-Memory adapter for tests
- Repository pattern: abstraction of data access
- Dynamic database selection via environment variables
- Authentication and Security:
- JWT authentication: tokens based on email/password
- Firebase Authentication: managed authentication service
- Bcrypt: secure password hashing
- Authentication middleware: API route protection
- Testing and Quality:
- End-to-End (E2E) tests: complete API tests with Supertest
- Unit tests: isolated tests of components and services with Jest
- Mocks and Stubs: simulation of dependencies for tests
- Reusable test helpers: AuthHelper, QuizHelper
- Tools and DevOps:
- Docker: MongoDB containerization for development
- Nx: monorepo to manage multiple projects
- Swagger: automatic API documentation
- Class-validator and class-transformer: DTO validation
