# ahmet-dedeler/ai-llm-comparison architecture

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

- Interactive diagram: https://gitdiagram.com/ahmet-dedeler/ai-llm-comparison
- Repository: https://github.com/ahmet-dedeler/ai-llm-comparison

## Overview

##### Main Components Identification

The system appears to be a modern web application with the following key components:

a) Frontend Layer (Next.js Application)
- Client-side components
- Server-side components
- Static assets

b) External Services
- BerriAI's LiteLLM (Data Source)
- Supabase (Database/Backend)
- v0 (Likely for deployment)

**[Client Browser] → [Next.js Application] → [External Services]**

##### Specific Elements

**┌─ Client Layer ─────────────────────────┐**
- Browser / User Interface               │
- ┬─────────────────────┘
- ↓
**┌─ Next.js Application ─────────────────┐**
- ┌─ Components ─┐  ┌─ Data Utils ────┐ │
- Header     │  │ - aiModels.ts   │ │
- Calculator │  │ - helpers.ts    │ │
- Comparison │  │ - providerMap   │ │
- ┘  └────────────────┘ │
- ┌─ UI Library ─┐  ┌─ State Mgmt ──┐ │
- Button     │  │ - TypeScript   │ │
- Card       │  │ - Types        │ │
- Table      │  └────────────────┘ │
- ┘                      │
- ┬─────────────────────┘
- ↓
**┌─ External Services ──────────────────┐**
- ┌─────────────┐  ┌────────────────┐ │
- LiteLLM    │  │    Supabase    │ │
- (Data)     │  │  (Backend)     │ │
- ┘  └────────────────┘ │
- ┘

##### Additional Notes

- A note about the GitHub Actions workflow for model updates
- Relationship with BerriAI's LiteLLM as the data source
- Role of Supabase in the application
- Public assets directory for static resources

## Diagram (Mermaid)

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

    subgraph "Next.js Application"
        MainLayout["Main Layout"]:::layout
        MainPage["Main Page"]:::page
        
        subgraph "Core Components"
            ModelComp["Model Comparison"]:::component
            PriceCalc["Pricing Calculator"]:::component
            ProviderSel["Provider Selection"]:::component
            ModelTables["Model Tables"]:::component
            Header["Header"]:::component
        end
        
        subgraph "UI Layer"
            UILib["UI Component Library"]:::ui
        end
        
        subgraph "Data Management"
            Utils["Utility Functions"]:::util
            Types["Type Definitions"]:::types
            StaticAssets["Static Assets"]:::static
        end
    end

    subgraph "Data Processing"
        ModelData["Model Prices & Context Window"]:::data
        DataTransform["Data Transformation"]:::process
        DataFetch["Data Fetching"]:::process
    end

    subgraph "External Services"
        LiteLLM["BerriAI LiteLLM"]:::external
        Supabase["Supabase"]:::external
        V0["v0 Platform"]:::external
    end

    subgraph "Automation"
        GHActions["GitHub Actions Workflow"]:::automation
    end

    %% Relationships
    Browser --> MainLayout
    MainLayout --> MainPage
    MainPage --> ModelComp
    MainPage --> PriceCalc
    MainPage --> ProviderSel
    MainPage --> ModelTables
    MainPage --> Header
    
    ModelComp & PriceCalc & ProviderSel & ModelTables --> UILib
    ModelComp & PriceCalc & ProviderSel --> Utils
    Utils --> Types
    
    GHActions --> DataFetch
    DataFetch --> DataTransform
    DataTransform --> ModelData
    
    Utils --> ModelData
    DataFetch --> LiteLLM

    %% Click Events
    click MainLayout "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/layout.tsx"
    click MainPage "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/page.tsx"
    click ModelComp "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/components/ModelComparison.tsx"
    click PriceCalc "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/components/PricingCalculator.tsx"
    click ProviderSel "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/components/ProviderSelect.tsx"
    click ModelTables "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/components/ModelTableForComparison.tsx"
    click Header "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/components/Header.tsx"
    click UILib "https://github.com/Ahmet-Dedeler/ai-llm-comparison/tree/master/components/ui/"
    click Utils "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/utils/aiModels.ts"
    click Types "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/app/types/index.ts"
    click StaticAssets "https://github.com/Ahmet-Dedeler/ai-llm-comparison/tree/master/public/logos/"
    click ModelData "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/model_prices_and_context_window.json"
    click DataTransform "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/transformModels.js"
    click DataFetch "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/fetchLatestJson.js"
    click GHActions "https://github.com/Ahmet-Dedeler/ai-llm-comparison/blob/master/.github/workflows/update-models.yml"

    %% Styles
    classDef component fill:#a8dadc,stroke:#457b9d
    classDef ui fill:#e9c46a,stroke:#f4a261
    classDef util fill:#2a9d8f,stroke:#264653
    classDef types fill:#8ecae6,stroke:#219ebc
    classDef static fill:#adb5bd,stroke:#495057
    classDef data fill:#06d6a0,stroke:#073b4c
    classDef process fill:#118ab2,stroke:#073b4c
    classDef external fill:#9d4edd,stroke:#5a189a
    classDef automation fill:#ff9f1c,stroke:#f77f00
    classDef layout fill:#caffbf,stroke:#9bf6ff
    classDef page fill:#bdb2ff,stroke:#7b2cbf

    %% Legend
    subgraph Legend
        L1["Component"]:::component
        L2["UI Library"]:::ui
        L3["Utility"]:::util
        L4["Types"]:::types
        L5["Static"]:::static
        L6["Data"]:::data
        L7["Process"]:::process
        L8["External"]:::external
        L9["Automation"]:::automation
        L10["Layout"]:::layout
        L11["Page"]:::page
    end
```
