# thykp/esm_team8 architecture

> Architecture diagram of the GitHub repository thykp/esm_team8, 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/thykp/esm_team8
- Repository: https://github.com/thykp/esm_team8

## Overview

##### Main Components
- Frontend: A React application (with Vite, Tailwind, etc.) handling the user interface and interacting with the backend via REST or gRPC APIs.
- API Gateway: Kong is used as an aggregation layer to handle incoming client requests, enforce policies (e.g., CORS, rate-limiting), and route to appropriate services.
- Backend Microservices: Organized under the “backend/services” directory, you have both “complex” and “simple” microservices (e.g., chatgpt, credit, order, payment, menu, recommendation, etc.). Note that each microservice may use its own language and framework.
- Infrastructure & Messaging:
- RabbitMQ components for message brokering (see the “backend/rabbitmq-setup”).
- Deployment and orchestration via Docker (docker-compose for local development) and Kubernetes (manifests in “backend/kubernetes”).
- Monitoring and Logging: Grafana dashboards, Prometheus configurations, and related monitoring setups.
- CI/CD Pipelines: GitHub Actions workflows are set up to automate testing, container/image building and deployment.
- Cloud & Infrastructure Provisioning: Terraform scripts under the “terraform” directory that provision resources (GKE clusters, load balancers, etc.).

##### Relationships and Interactions
- The Frontend communicates with the API Gateway (Kong), which then routes requests to specific backend microservices.
- Microservices operate independently using REST APIs or gRPC to communicate with each other as needed.
- RabbitMQ acts as the message broker to facilitate real-time communications or asynchronous processing between services.
- Monitoring systems (Grafana/Prometheus) collect metrics from different services and infrastructure components.
- Deployment dependencies such as Kubernetes deployments, configmaps, services, jobs, and persistent volumes form another layer of the architecture where infrastructure components communicate.

##### Highlighting Architectural Patterns and Design Principles
- Microservices Architecture: Emphasize the decoupled, independently deployable services (with both “complex” and “simple” categorizations).
- Atomic Microservice design: Each service is built using language-agnostic technologies to showcase concurrency (in Go) and flexibility.
- Containerization and Orchestration: Docker for container builds and Kubernetes for orchestration, including CI/CD automation.
- API Gateway: Use of Kong to aggregate and secure the APIs.
- Asynchronous Communication: Integration of RabbitMQ for messaging between services.
- Observability: Monitoring through Prometheus and Grafana, which forms an integral part of the operational aspect of the system.

##### Final Recommendations
- Every component is clearly labeled.
- Annotations for the technology stacks (e.g., React + Tailwind for frontend; Go, Node.js, Python for microservices; Kong, RabbitMQ, Grafana, Prometheus, Kubernetes, Terraform; and CI/CD pipelines managed via GitHub Actions).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        FE["Front-End UI (React, Vite, Tailwind)"]:::frontend
    end

    subgraph "API Layer"
        KG["Kong API Gateway"]:::api
    end

    subgraph "Microservices Layer"
        MS["Backend Microservices"]:::service
    end

    subgraph "Messaging & Monitoring"
        RMQ["RabbitMQ"]:::msg
        GRAF["Grafana"]:::monitoring
        PROM["Prometheus"]:::monitoring
    end

    subgraph "Infrastructure Layer"
        K8S["Kubernetes"]:::infr
        CICD["CI/CD Pipelines"]:::cicd
        TF["Terraform Provisioning"]:::infr
    end

    %% Connections
    FE -->|"APIRequest"| KG
    KG -->|"Routes"| MS
    MS -->|"MessageAsync"| RMQ
    MS -->|"Metrics"| GRAF
    MS -->|"Metrics"| PROM
    CICD -->|"Deploys"| K8S
    CICD -->|"Deploys"| MS
    K8S -->|"Hosts"| MS
    TF -->|"Creates"| K8S

    %% Click Events
    click FE "https://github.com/thykp/esm_team8/tree/main/frontend/"
    click KG "https://github.com/thykp/esm_team8/blob/main/backend/kong/kong.yml"
    click MS "https://github.com/thykp/esm_team8/tree/main/backend/services/"
    click RMQ "https://github.com/thykp/esm_team8/tree/main/backend/rabbitmq-setup/"
    click K8S "https://github.com/thykp/esm_team8/tree/main/backend/kubernetes/"
    click GRAF "https://github.com/thykp/esm_team8/tree/main/backend/grafana/"
    click PROM "https://github.com/thykp/esm_team8/blob/main/backend/monitoring/prometheus.yml"
    click CICD "https://github.com/thykp/esm_team8/tree/main/.github/workflows/"
    click TF "https://github.com/thykp/esm_team8/tree/main/terraform/"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef api fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20;
    classDef service fill:#ffe082,stroke:#ff6f00,color:#ff6f00;
    classDef msg fill:#ffccbc,stroke:#bf360c,color:#bf360c;
    classDef infr fill:#d7ccc8,stroke:#4e342e,color:#4e342e;
    classDef cicd fill:#e1bee7,stroke:#6a1b9a,color:#6a1b9a;
    classDef monitoring fill:#c5e1a5,stroke:#33691e,color:#33691e;
```
