# zakirkun/to-be-software-engineer architecture

> Architecture diagram of the GitHub repository zakirkun/to-be-software-engineer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zakirkun/to-be-software-engineer
- Repository: https://github.com/zakirkun/to-be-software-engineer

## Overview

##### Main Components

- Main Application Service (from /cmd/app)
- Email Service (from /cmd/email_services)
- Payment Service (from /cmd/payment)

- Nginx (Reverse Proxy/Load Balancer)
- ELK Stack (Logging)
- Prometheus & Alertmanager (Monitoring)
- RabbitMQ (Message Queue)
- Redis (Cache)
- Database (SQL)
- Cortex (Metrics)

##### Specific Implementation Details

Annotations showing:
- Authentication flow (JWT)
- Domain model relationships
- API endpoints grouping (products, orders, customers, categories)
- Middleware chain (auth, logging)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client(["Client"])
        Nginx[/"Nginx Reverse Proxy"\]:::proxy
        click Nginx "https://github.com/zakirkun/to-be-software-engineer/tree/main/deploy/nginx/"
    end

    subgraph Microservices
        MainApp["Main Application Service"]:::service
        EmailService["Email Service"]:::service
        PaymentService["Payment Service"]:::service
        click MainApp "https://github.com/zakirkun/to-be-software-engineer/blob/main/cmd/app/main.go"
        click EmailService "https://github.com/zakirkun/to-be-software-engineer/blob/main/cmd/email_services/main.go"
        click PaymentService "https://github.com/zakirkun/to-be-software-engineer/blob/main/cmd/payment/main.go"

        subgraph "Main App Components"
            Controllers["Controllers Layer"]:::component
            Services["Services Layer"]:::component
            Repository["Repository Layer"]:::component
            Domain["Domain Layer"]:::component
            click Controllers "https://github.com/zakirkun/to-be-software-engineer/tree/main/app/controllers/"
            click Services "https://github.com/zakirkun/to-be-software-engineer/tree/main/app/services/"
            click Repository "https://github.com/zakirkun/to-be-software-engineer/tree/main/app/repository/"
            click Domain "https://github.com/zakirkun/to-be-software-engineer/tree/main/app/domains/"
        end
    end

    subgraph "Message Queue"
        RabbitMQ[("RabbitMQ")]:::queue
        click RabbitMQ "https://github.com/zakirkun/to-be-software-engineer/tree/main/pkg/rabbitmq/"
    end

    subgraph "Data Layer"
        Database[("SQL Database")]:::database
        Redis[("Redis Cache")]:::cache
        click Database "https://github.com/zakirkun/to-be-software-engineer/tree/main/pkg/database/"
        click Redis "https://github.com/zakirkun/to-be-software-engineer/tree/main/pkg/cache/"
    end

    subgraph "Monitoring & Logging"
        ELK["ELK Stack"]:::monitoring
        Prometheus["Prometheus"]:::monitoring
        Alertmanager["Alertmanager"]:::monitoring
        Cortex["Cortex"]:::monitoring
        click ELK "https://github.com/zakirkun/to-be-software-engineer/tree/main/deploy/elk/"
        click Prometheus "https://github.com/zakirkun/to-be-software-engineer/tree/main/deploy/prometheus/"
        click Alertmanager "https://github.com/zakirkun/to-be-software-engineer/tree/main/deploy/alertmanager/"
    end

    subgraph "Core Infrastructure"
        Router["Router"]:::infra
        Server["Server"]:::infra
        Config["Configuration"]:::infra
        JWT["JWT Handler"]:::infra
        click Router "https://github.com/zakirkun/to-be-software-engineer/blob/main/router/router.go"
        click Server "https://github.com/zakirkun/to-be-software-engineer/blob/main/pkg/server/server.go"
        click Config "https://github.com/zakirkun/to-be-software-engineer/blob/main/pkg/config/config.go"
        click JWT "https://github.com/zakirkun/to-be-software-engineer/blob/main/pkg/jwt/jwt.go"
    end

    %% Connections
    Client --> Nginx
    Nginx --> MainApp
    MainApp --> RabbitMQ
    RabbitMQ --> EmailService
    RabbitMQ --> PaymentService
    MainApp --> Database
    MainApp --> Redis
    MainApp --> Controllers
    Controllers --> Services
    Services --> Repository
    Repository --> Domain

    %% Monitoring Connections
    MainApp -.-> ELK
    EmailService -.-> ELK
    PaymentService -.-> ELK
    MainApp -.-> Prometheus
    Prometheus --> Alertmanager
    Prometheus --> Cortex

    %% Style Definitions
    classDef service fill:#2374ab,stroke:#2374ab,color:#fff
    classDef component fill:#457b9d,stroke:#457b9d,color:#fff
    classDef database fill:#004346,stroke:#004346,color:#fff
    classDef cache fill:#00798c,stroke:#00798c,color:#fff
    classDef queue fill:#2f6690,stroke:#2f6690,color:#fff
    classDef monitoring fill:#e76f51,stroke:#e76f51,color:#fff
    classDef proxy fill:#588157,stroke:#588157,color:#fff
    classDef infra fill:#6c757d,stroke:#6c757d,color:#fff

    %% Legend
    subgraph Legend
        Service["Service"]:::service
        Component["Component"]:::component
        DB["Database"]:::database
        CacheStore["Cache"]:::cache
        MessageQueue["Message Queue"]:::queue
        Monitor["Monitoring"]:::monitoring
        ProxyServer["Proxy"]:::proxy
        Infrastructure["Infrastructure"]:::infra
    end
```
