008. Migrate Backend Services to Nest.js and TypeScript¶
- Status: Accepted
- Date: 2025-09-15
Context¶
The current backend services (auth and api_gateway) are implemented in Node.js with plain JavaScript. This approach has led to several challenges:
* Lack of Type Safety: JavaScript's dynamic typing allows for common data-related errors that are only caught at runtime.
* Inconsistent Architecture: Without a strong framework, the code structure is inconsistent, making it difficult to maintain and onboard new developers.
* Maintenance Overhead: As the codebase grows, refactoring and ensuring quality becomes progressively harder and more time-consuming.
Decision¶
We will migrate the existing auth and api_gateway services from Node.js/JavaScript to a modern, standardized stack using Nest.js and TypeScript.
This migration will be conducted in a phased approach to minimize disruption. New projects will be scaffolded, and logic will be ported incrementally.
Consequences¶
Positive¶
- Improved Type Safety: TypeScript will catch many common errors during development, reducing runtime bugs and improving code quality.
- Enhanced Maintainability: A strongly-typed and well-structured codebase is easier to understand, refactor, and scale.
- Standardized Architecture: Nest.js provides an opinionated, modular framework that enforces consistency and best practices (e.g., Modules, Controllers, Services, Dependency Injection).
- Better Developer Experience: Features like decorators, a powerful CLI, and first-class support for modern tools will improve developer productivity.
- Future-Proofing: Aligns our backend with a modern, robust, and widely-adopted technology stack.
- Configuration Management: The new services will adhere to the standards for managing sensitive data as outlined in ADR-009.
Negative¶
- Initial Time Investment: There will be an upfront effort to scaffold the new projects, port existing logic, and rewrite tests.
- Learning Curve: Developers unfamiliar with Nest.js will require a brief period to adapt to its concepts and patterns.
- Temporary Infrastructure Complexity: During the phased migration, both the old and new services will coexist, requiring temporary adjustments to CI/CD pipelines and local development environments.