How mutual-de-servicios-al-policia/microservice-gateway works
Based on our analysis of the file tree and README content, this project is a microservice gateway built with NestJS. Its purpose is to act as a central point that routes requests and communicates with various microservices via NATS (a lightweight messaging system). The codebase is organized using NestJS modules, controllers, and services, separating functionality into logical areas (such as affiliates, auth, general, kiosk, and persons). There’s also an integration with a Postgres database (as suggested by the database and migrations folders) and configurations for logging and environment variables.
Main Components
• Microservice Gateway (Core Application): This is the central application, built in NestJS. It is represented by src/app.module.ts and other feature modules (affiliates, auth, general, kiosk, persons).
• Feature Modules: Represent each domain by a separate module (e.g., affiliates, auth, persons, general, kiosk). Each one hosts its own controllers and services.
• Database: Represent the persistence layer (extracted from the src/database folder and associated migration files). Although this is not explicitly defined in the README, it is a core part of the data handling logic.
• External Microservices: Indicate the external microservices that need to be running (as mentioned in the README step “Tener levantados los microservicios que se van a consumir”). They communicate with the gateway via NATS.
Relationships and Interactions
• That external clients (or other consumers) interact with the Microservice Gateway through HTTP endpoints.
• The gateway then delegates various operations to its modules (auth, persons, etc.).
• Important: illustrate that the gateway uses NATS for asynchronous messaging to communicate with external microservices, forming a service mesh where messages are exchanged.
• That the Database is accessed by one or more of these modules (tracked in the src/database folder) for persistence and query operations.
• Optionally, include configuration and logging components (e.g., winston-audit-logger.ts) to show supporting services that help in diagnostics and monitoring.
Architectural Patterns and Design Principles
• Use of NestJS modular architecture, showing the separation of concerns via feature modules.
• Emphasis on microservices-based design using a message broker (NATS) for inter-service communication.
• Dockerization: Include Docker images (dockerfile, dockerfile.prod, and .dockerignore) that indicate containerization for development and production.
• Environment-driven configuration through .env files and configuration modules.