# kykim88/galaxy-mk2 architecture

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

- Interactive diagram: https://gitdiagram.com/kykim88/galaxy-mk2
- Repository: https://github.com/kykim88/galaxy-mk2

## Overview

##### Main Components

a. Application Layer:
- FastAPI Web Server (ASGI/WSGI)
- Controllers Layer
- Views Layer
- Models Layer
- Router
- Utilities
- Configuration Management

b. Infrastructure Components:
- Redis (indicated by redis.py utility)
- Kubernetes Deployment (evident from Helm charts)
- HTTP Client (shown by aiohttp_client.py)

**[Client Layer]**
- ↓ ↑
**[Application Layer]**
- ↓ ↑
**[Infrastructure Layer]**

##### Detailed Component Breakdown

a. Client Layer:
- External API Consumers
- Ingress Controller (from Helm charts)

b. Application Layer (show as interconnected components):
- FastAPI ASGI Server
- Router (app/router.py)
- Controllers:
- Ready Controller
- Error Handling
- Views Layer
- Models Layer
- Utility Services:
- Redis Client
- HTTP Client

c. Infrastructure Layer:
- Redis Database
- Kubernetes Resources:
- Pods
- Services
- ConfigMaps
- HPA (Horizontal Pod Autoscaler)

##### Key Relationships to Highlight

- How the Router directs requests to Controllers
- MVC pattern flow:
Controller → Model → View
- Connection between the application and Redis
- How the Kubernetes components interact

##### Additional Elements

- Configuration management flow
- Test infrastructure
- CI/CD pipeline components (from GitHub Actions)
- Monitoring and health check endpoints

##### Specific Implementation Details

- Use rectangles for services
- Use hexagons for external interfaces
- Version information for key components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        API_CONSUMERS["External API Consumers"]
        INGRESS["Ingress Controller"]:::k8s
    end

    subgraph Application
        ASGI["ASGI Server"]:::app
        WSGI["WSGI Server"]:::app
        ROUTER["Router"]:::app
        
        subgraph Controllers
            READY_CTRL["Ready Controller"]:::controller
            ERROR_CTRL["Error Controller"]:::controller
        end
        
        subgraph Views
            READY_VIEW["Ready View"]:::view
            ERROR_VIEW["Error View"]:::view
        end
        
        subgraph Models
            MODEL["Data Models"]:::model
        end
        
        subgraph Utils
            REDIS_CLIENT["Redis Client"]:::util
            HTTP_CLIENT["HTTP Client"]:::util
        end
        
        subgraph Config
            APP_CONFIG["Application Config"]:::config
            REDIS_CONFIG["Redis Config"]:::config
            GUNICORN_CONFIG["Gunicorn Config"]:::config
        end
    end

    subgraph Infrastructure
        subgraph "Kubernetes Resources"
            K8S_DEPLOY["Deployment"]:::k8s
            K8S_SVC["Service"]:::k8s
            K8S_CM["ConfigMap"]:::k8s
            K8S_HPA["HPA"]:::k8s
        end
        
        REDIS["Redis Database"]:::db
    end

    %% Relationships
    API_CONSUMERS --> INGRESS
    INGRESS --> ASGI
    ASGI --> WSGI
    WSGI --> ROUTER
    ROUTER --> READY_CTRL
    ROUTER --> ERROR_CTRL
    READY_CTRL --> READY_VIEW
    ERROR_CTRL --> ERROR_VIEW
    READY_CTRL --> MODEL
    ERROR_CTRL --> MODEL
    READY_CTRL --> REDIS_CLIENT
    REDIS_CLIENT --> REDIS
    READY_CTRL --> HTTP_CLIENT
    
    APP_CONFIG --> ASGI
    REDIS_CONFIG --> REDIS_CLIENT
    GUNICORN_CONFIG --> WSGI
    
    K8S_DEPLOY --> ASGI
    K8S_SVC --> K8S_DEPLOY
    K8S_CM --> K8S_DEPLOY
    K8S_HPA --> K8S_DEPLOY

    %% Click Events
    click ASGI "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/app/asgi.py"
    click WSGI "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/wsgi.py"
    click ROUTER "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/app/router.py"
    click READY_CTRL "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/app/controllers/ready.py"
    click ERROR_VIEW "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/app/views/error.py"
    click READY_VIEW "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/app/views/ready.py"
    click MODEL "https://github.com/kykim88/galaxy-mk2/tree/main/galaxy_mk2/app/models/"
    click REDIS_CLIENT "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/app/utils/redis.py"
    click HTTP_CLIENT "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/app/utils/aiohttp_client.py"
    click APP_CONFIG "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/config/application.py"
    click REDIS_CONFIG "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/config/redis.py"
    click GUNICORN_CONFIG "https://github.com/kykim88/galaxy-mk2/blob/main/galaxy_mk2/config/gunicorn.py"
    click K8S_DEPLOY "https://github.com/kykim88/galaxy-mk2/blob/main/charts/galaxy-mk2/templates/deployment.yaml"
    click K8S_SVC "https://github.com/kykim88/galaxy-mk2/blob/main/charts/galaxy-mk2/templates/service.yaml"
    click INGRESS "https://github.com/kykim88/galaxy-mk2/blob/main/charts/galaxy-mk2/templates/ingress.yaml"
    click K8S_HPA "https://github.com/kykim88/galaxy-mk2/blob/main/charts/galaxy-mk2/templates/hpa.yaml"
    click K8S_CM "https://github.com/kykim88/galaxy-mk2/blob/main/charts/galaxy-mk2/templates/configmap.yml"
    click REDIS "https://github.com/kykim88/galaxy-mk2/blob/main/manifests/all-redis-operator-resources.yaml"

    %% Styles
    classDef app fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef controller fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef view fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef model fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef util fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef config fill:#f7b723,stroke:#000,stroke-width:2px,color:#000
    classDef k8s fill:#326ce5,stroke:#000,stroke-width:2px,color:#fff
    classDef db fill:#23f723,stroke:#000,stroke-width:2px,color:#000
```
