# alexeynikitin01/lms architecture

> Architecture diagram of the GitHub repository alexeynikitin01/lms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexeynikitin01/lms
- Repository: https://github.com/alexeynikitin01/lms

## Overview

##### High-Level System Components

- 5 Core Microservices:
- User Microservice
- Course Microservice
- Calculate Microservice
- Microservice
- Info Microservice
- Message Broker (RabbitMQ) - evident from the 'rabb' directory
- Databases (PostgreSQL and MongoDB) - visible in adapters
- Cloud Storage - seen in storage adapters
- Monitoring (Prometheus) - visible in configuration files

##### Detailed Architecture Representation

a) Client Layer
- External client connections (REST/gRPC)
- Load balancer/API gateway (if present)

b) Service Layer (for each microservice):
- Internal layers (based on clean architecture):
- Ports (HTTP/gRPC)
- Application Core
- Adapters
- Domain Entities

c) Data Layer:
- PostgreSQL databases
- MongoDB instances
- Cloud storage
- Message queues

##### Specific Implementation Details

For each microservice, show:

User Microservice:
- HTTP (Gin) and gRPC endpoints
- Authentication/Authorization flows
- PostgreSQL connection
- Cloud storage for avatars

Course Microservice:
- MongoDB and PostgreSQL connections
- Cloud storage for course materials
- gRPC/REST endpoints

Calculate, Map, and Info Microservices:
- Their specific database connections
- Their primary responsibilities

##### Cross-Cutting Concerns

- Prometheus monitoring
- Logging
- Error handling
- Configuration management

##### Additional Elements

Include:
- Version information
- Database schema references
- Service discovery mechanism (if present)

##### Notes Section

Notes about:
- Clean architecture implementation
- Security measures
- Scaling approaches
- Deployment considerations

Remember to maintain a balance between detail and clarity, focusing on the clean architecture implementation within each microservice while showing the overall system interaction patterns.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Client
        REST[REST Clients]
        GRPC[gRPC Clients]
    end

    %% Service Layer
    subgraph Services
        subgraph UserService[User Microservice]
            UserHTTP["HTTP/Gin Interface"]:::port
            UserGRPC["gRPC Interface"]:::port
            UserCore["Core Logic"]:::core
            UserDB["PostgreSQL Adapter"]:::adapter
            UserStorage["Storage Adapter"]:::adapter
        end

        subgraph CourseService[Course Microservice]
            CourseHTTP["HTTP/Gin Interface"]:::port
            CourseGRPC["gRPC Interface"]:::port
            CourseCore["Core Logic"]:::core
            CourseMongo["MongoDB Adapter"]:::adapter
            CoursePostgres["PostgreSQL Adapter"]:::adapter
            CourseStorage["Cloud Storage Adapter"]:::adapter
        end

        subgraph CalcService[Calculate Microservice]
            CalcCore["Core Logic"]:::core
        end

        subgraph MapService[Map Microservice]
            MapCore["Core Logic"]:::core
        end

        subgraph InfoService[Info Microservice]
            InfoCore["Core Logic"]:::core
        end
    end

    %% Data Layer
    subgraph Storage
        PostgreSQL[(PostgreSQL)]:::database
        MongoDB[(MongoDB)]:::database
        CloudStorage[Cloud Storage]:::storage
        RabbitMQ{{"Message Broker<br>(RabbitMQ)"}}:::queue
    end

    %% Monitoring
    subgraph Monitoring
        Prometheus[Prometheus]:::monitoring
    end

    %% Connections
    REST --> UserHTTP & CourseHTTP
    GRPC --> UserGRPC & CourseGRPC

    %% User Service Connections
    UserHTTP --> UserCore
    UserGRPC --> UserCore
    UserCore --> UserDB
    UserCore --> UserStorage
    UserDB -.-> PostgreSQL
    UserStorage -.-> CloudStorage

    %% Course Service Connections
    CourseHTTP --> CourseCore
    CourseGRPC --> CourseCore
    CourseCore --> CourseMongo & CoursePostgres & CourseStorage
    CourseMongo -.-> MongoDB
    CoursePostgres -.-> PostgreSQL
    CourseStorage -.-> CloudStorage

    %% Other Service Connections
    CalcCore --> RabbitMQ
    MapCore --> RabbitMQ
    InfoCore --> RabbitMQ

    %% Monitoring Connections
    UserHTTP & CourseHTTP -.-> Prometheus

    %% Click Events
    click UserService "https://github.com/AlexeyNikitin01/lms/tree/main//userMicroservice"
    click UserCore "https://github.com/AlexeyNikitin01/lms/tree/main//userMicroservice/internal/app"
    click UserDB "https://github.com/AlexeyNikitin01/lms/tree/main//userMicroservice/internal/adapters/postgres"
    click UserStorage "https://github.com/AlexeyNikitin01/lms/tree/main//userMicroservice/internal/adapters/storage"
    click UserHTTP "https://github.com/AlexeyNikitin01/lms/tree/main//userMicroservice/internal/ports/httpgin"
    click UserGRPC "https://github.com/AlexeyNikitin01/lms/tree/main//userMicroservice/internal/ports/grpc"

    click CourseService "https://github.com/AlexeyNikitin01/lms/tree/main//courseMicroservice"
    click CourseCore "https://github.com/AlexeyNikitin01/lms/tree/main//courseMicroservice/internal/app"
    click CourseMongo "https://github.com/AlexeyNikitin01/lms/tree/main//courseMicroservice/internal/adapters/mongo"
    click CoursePostgres "https://github.com/AlexeyNikitin01/lms/tree/main//courseMicroservice/internal/adapters/postgres"
    click CourseStorage "https://github.com/AlexeyNikitin01/lms/tree/main//courseMicroservice/internal/adapters/cloud"
    click CourseHTTP "https://github.com/AlexeyNikitin01/lms/tree/main//courseMicroservice/internal/ports/httpgin"
    click CourseGRPC "https://github.com/AlexeyNikitin01/lms/tree/main//courseMicroservice/internal/ports/grpc"

    click CalcService "https://github.com/AlexeyNikitin01/lms/tree/main//calculateMicroservice"
    click CalcCore "https://github.com/AlexeyNikitin01/lms/tree/main//calculateMicroservice/internal/entity"

    click MapService "https://github.com/AlexeyNikitin01/lms/tree/main//mapMicroservice"
    click MapCore "https://github.com/AlexeyNikitin01/lms/tree/main//mapMicroservice/internal/mapEntity"

    click InfoService "https://github.com/AlexeyNikitin01/lms/tree/main//infoMicroservice"
    click InfoCore "https://github.com/AlexeyNikitin01/lms/tree/main//infoMicroservice/internal/info"

    click RabbitMQ "https://github.com/AlexeyNikitin01/lms/tree/main//rabb/pkg/server"
    click Prometheus "https://github.com/AlexeyNikitin01/lms/blob/main//etc/prometheus.yml"

    %% Styles
    classDef port fill:#4B89DC,stroke:#2E5C9C,color:white
    classDef core fill:#37BC9B,stroke:#259B76,color:white
    classDef adapter fill:#967ADC,stroke:#7652D1,color:white
    classDef database fill:#F6BB42,stroke:#E8A52C,color:white
    classDef storage fill:#DA4453,stroke:#B02B38,color:white
    classDef queue fill:#3BAFDA,stroke:#2494BE,color:white
    classDef monitoring fill:#D770AD,stroke:#C86196,color:white
```
