# mc-bench/mc-bench-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/mc-bench/mc-bench-frontend
- Repository: https://github.com/mc-bench/mc-bench-frontend

## Overview

##### Main Components

A. Frontend Layer (React + TypeScript):
- Subdivide into key feature modules based on the components structure:
- Authentication (Auth components)
- Models Management
- Generations
- Prompts
- Runs
- Templates
- Samples

B. Backend Services:
- Main API Service (Port 8000)
- Admin API Service (Port 8001)
- Worker Services

C. Infrastructure Components:
- PostgreSQL Database
- Redis Message Queue
- MinIO Object Storage
- GitHub OAuth (External Service)

##### Component Relationships and Data Flow

- Frontend → API Services (REST/HTTP)
- API Services → PostgreSQL (Data persistence)
- API Services → Redis (Message queue)
- API Services → MinIO (Object storage)
- Workers ← Redis (Message consumption)
- Workers → MinIO (Asset processing)
- Frontend ↔ GitHub OAuth (Authentication flow)

##### Specific Implementation Details

For the Frontend section, highlight:
- Context-based state management (AuthContext)
- Protected routes architecture
- Component hierarchy
- Type definitions structure

For the Backend section, emphasize:
- API service separation (Main vs Admin)
- Worker architecture
- Database interactions
- File storage patterns

**[Client Layer (Browser)]**
- ↓
**[Frontend Application Layer]**
- ↓
**[API Services Layer]**
- ↓
**[Infrastructure Layer]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Frontend["Frontend Application (React + TypeScript)"]
        direction TB
        Auth["Authentication System"]:::frontend
        Models["Models Management"]:::frontend
        Generations["Generations Module"]:::frontend
        Prompts["Prompts Module"]:::frontend
        Runs["Runs Module"]:::frontend
        Templates["Templates Module"]:::frontend
        Samples["Samples Module"]:::frontend
        APIClient["API Client"]:::frontend
        ProtectedRoutes["Protected Routes"]:::frontend
        Config["Configuration"]:::frontend
        Types["Type Definitions"]:::frontend
        UIComponents["UI Components"]:::frontend
    end

    subgraph Backend["Backend Services"]
        MainAPI["Main API Service\n(Port 8000)"]:::backend
        AdminAPI["Admin API Service\n(Port 8001)"]:::backend
        Workers["Worker Services"]:::backend
    end

    subgraph Infrastructure["Infrastructure Layer"]
        PostgreSQL[(PostgreSQL)]:::infrastructure
        Redis[(Redis Queue)]:::infrastructure
        MinIO[(MinIO Storage)]:::infrastructure
    end

    subgraph External["External Services"]
        GitHub["GitHub OAuth"]:::external
    end

    %% Connections
    Browser --> Auth
    Auth --> GitHub
    GitHub --> Auth

    Auth --> APIClient
    Models --> APIClient
    Generations --> APIClient
    Prompts --> APIClient
    Runs --> APIClient
    Templates --> APIClient
    Samples --> APIClient

    APIClient --> MainAPI
    APIClient --> AdminAPI
    
    MainAPI --> PostgreSQL
    AdminAPI --> PostgreSQL
    
    MainAPI --> Redis
    AdminAPI --> Redis
    
    MainAPI --> MinIO
    AdminAPI --> MinIO
    
    Redis --> Workers
    Workers --> MinIO

    %% Click Events
    click Auth "https://github.com/mc-bench/mc-bench-frontend/blob/main/src/context/AuthContext.tsx"
    click Models "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/components/models"
    click Generations "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/components/generations"
    click Prompts "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/components/prompts"
    click Runs "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/components/runs"
    click Templates "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/components/templates"
    click Samples "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/components/samples"
    click APIClient "https://github.com/mc-bench/mc-bench-frontend/blob/main/src/api/client.ts"
    click ProtectedRoutes "https://github.com/mc-bench/mc-bench-frontend/blob/main/src/components/ProtectedRoute.tsx"
    click Config "https://github.com/mc-bench/mc-bench-frontend/blob/main/src/config/settings.ts"
    click Types "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/types"
    click UIComponents "https://github.com/mc-bench/mc-bench-frontend/tree/main/src/components/ui"

    %% Styles
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef infrastructure fill:#f1c40f,color:black
    classDef external fill:#e74c3c,color:white

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Service"]:::backend
        Infrastructure_L["Infrastructure"]:::infrastructure
        External_L["External Service"]:::external
    end
```
