How davidchavess/clean-architecture-ride-api works
Based on both the file tree and the README, the project is a multi-service, full-stack API backend for a ride-hailing application—akin to services like Uber or 99. The project consists of four main APIs (account, payment, position, ride) that each follow Clean Architecture principles and Hexagonal Architecture (also known as Ports and Adapters). They are implemented using Node.js, leveraging tools like Express for HTTP, PostgreSQL and MongoDB for persistence, and RabbitMQ for message/event communication. The system also applies several design patterns (e.g., Factory, Adapter, Dependency Injection) and adheres to SOLID principles, TDD, and DDD.
Main components
• Account Service: Handles user signup and account management.
• Ride Service: Manages ride requests, acceptance, updates, and finishes.
• Payment Service: Processes payments for rides.
• Service: Updates and retrieves driver or ride positions.
• Shared or external components:
• Database systems (PostgreSQL for relational data in account, payment, and position services; MongoDB primarily in ride service for certain data types).
• Messaging/Event system: RabbitMQ (as seen in event adapters and connection components) to handle inter-service communication.
• External HTTP interfaces with Express-adapters serving as the entry point for API calls.
• Gateways: Components acting as external integrations (for example, Account Gateway HTTP in the ride service).
Relationships and interactions
• For instance, the Ride Service interacts with the Account Service (through a gateway) to obtain account details or verify user identity.
• The Payment Service can be triggered by a message/event from the Ride Service for processing payments.
• The Position Service interacts with the Ride Service via event-driven updates (and vice versa).
• That communication between services occurs both synchronously (HTTP API calls) and asynchronously (events via RabbitMQ).
Architectural patterns and design principles
• Separate the inner layers (Application, Domain) that contain business logic from the outer layers (Infrastructure, HTTP, Database, Event) that deal with external systems and frameworks.
• Separation of concerns (e.g., use cases vs. domain entities vs. infrastructure adapters) inside each service.
• Dependency injection and composition roots (e.g., the “Registry.ts” files in each service) that wire the components together.
Elements
• Provide clear labels for each microservice and its internal layers (e.g., Domain, Application, Infrastructure) if space allows.