# rimanshu11/loopback-microservices architecture

> Architecture diagram of the GitHub repository rimanshu11/loopback-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rimanshu11/loopback-microservices
- Repository: https://github.com/rimanshu11/loopback-microservices

## Overview

##### Main Components
- API Gateway (bms-api-gateway): Acts as the central entry point (running on port 3005). It’s responsible for token validation, routing client requests, and handling cross-service interactions.
- Microservices:
- Author Service – Manages authors and runs on port 3001.
- Book Service – Manages books and runs on port 3002.
- Category Service – Manages categories and runs on port 3003.
- Auth Service – Although not present in the file tree, the README indicates an authentication service for handling user authentication (likely running on port 3004).

##### File Structure for Each Microservice
- Each service (e.g., AuthorServices, BookServices, CategoryServices, and bms-api-gateway) has a similar internal structure:
- A ‘src’ directory containing application entry points, controllers, datasources, models, repositories, and API specification files.
- Testing directories (i.e., __tests__) indicate an emphasis on correctness and acceptance testing.
- This common structure suggests the use of a well-defined separation of concerns. For instance, controllers handle HTTP routes, models represent the data structures, datasources manage database interactions, and repositories abstract data access.

##### Relationships and Interactions
- External services or message brokers can be represented if event-driven communication is incorporated (the README suggests the possibility, for example, mentioning RabbitMQ or Kafka).

##### Architectural Patterns and Design Principles
- Microservices Architecture: Emphasize that services are independently deployable and adhere to a “split by business capability” philosophy.
- Clear Separation of Concerns: Within each microservice, highlight separation between controllers, datasources, models, and repositories.
- API Gateway Pattern: Illustrate how the gateway abstracts the complexity of multiple microservices and enforces cross-cutting concerns (e.g., authentication, logging, rate limiting).

##### Technologies and Frameworks
- That each service is built using Node.js and follows similar configurations (indicated by consistent use of tools like ESLint, Prettier, Docker, and testing frameworks like Mocha).
- That the API specifications (openapi-spec.ts) are used to manage and document API contracts, which can be highlighted as part of the overall design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Client["External Client"]:::client
    APIGateway["API Gateway (3005)"]:::api

    %% Microservices Subgraph
    subgraph "Domain Microservices"
        AuthorService["Author Service (3001)"]:::micro
        BookService["Book Service (3002)"]:::micro
        CategoryService["Category Service (3003)"]:::micro
        AuthService["Auth Service (3004)"]:::micro
    end

    %% Relationships
    Client -->|"sendsRequest"| APIGateway
    APIGateway -->|"routesTo"| AuthorService
    APIGateway -->|"routesTo"| BookService
    APIGateway -->|"routesTo"| CategoryService
    APIGateway -->|"routesTo"| AuthService

    %% Click Events
    click APIGateway "https://github.com/rimanshu11/loopback-microservices/tree/main/bms-api-gateway/"
    click AuthorService "https://github.com/rimanshu11/loopback-microservices/tree/main/AuthorServices/"
    click BookService "https://github.com/rimanshu11/loopback-microservices/tree/main/BookServices/"
    click CategoryService "https://github.com/rimanshu11/loopback-microservices/tree/main/CategoryServices/"

    %% Styles
    classDef client fill:#FDF6E3,stroke:#586e75,stroke-width:2px;
    classDef api fill:#268BD2,stroke:#073642,stroke-width:2px,color:#fff;
    classDef micro fill:#2AA198,stroke:#073642,stroke-width:2px,color:#fff;
    
    %% Layout adjustments to favor vertical orientation
    style Client margin:20px, padding:10px;
    style APIGateway margin:20px, padding:10px;
    style AuthorService margin:10px, padding:10px;
    style BookService margin:10px, padding:10px;
    style CategoryService margin:10px, padding:10px;
    style AuthService margin:10px, padding:10px;
```
