# poemsforaphrodite/eval architecture

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

- Interactive diagram: https://gitdiagram.com/poemsforaphrodite/eval
- Repository: https://github.com/poemsforaphrodite/eval

## Overview

##### Main Components

a. Frontend Layer:
- Pages (Dashboard, Playground, Settings, etc.)
- UI Components (from app/components)
- Client-side State Management
- Use blue coloring for frontend components

b. API Layer:
- Authentication APIs (/api/auth/*)
- Admin APIs (/api/admin/*)
- Model Management APIs (/api/manage-models/*)
- Evaluation APIs (/api/evaluations/*)
- Use green coloring for API components

c. Authentication System:
- Google OAuth integration
- Local authentication flow
- To User Management
- Use yellow coloring for auth components

d. Database Layer:
- MongoDB connection (indicated by mongodb.ts)
- Indexes and schemas
- Use purple coloring for database components

e. External Services:
- OpenAI API integration
- Google OAuth service
- Use orange coloring for external services

##### Connection Flows

**Client Components → API Routes → Database**
- ↘ External Services
**Authentication Flow → User Sessions → Protected Routes**

##### Specific Implementation Details

a. Frontend Architecture:
- Next.js App Router structure
- Server and client components
- Shared UI components library

b. API Structure:
- Related endpoints (auth, admin, models)
- Middleware layers
- Protected routes

c. Data Flow:
- User authentication flow
- Model management pipeline
- Evaluation process flow

##### Special Features to Highlight

- AB Testing System
- Model Management Interface
- UMAP Visualization
- Performance Analytics

##### Technical Specifications

A technical stack section showing:
- Next.js 13+ (App Router)
- MongoDB
- TypeScript
- TailwindCSS
- Authentication Providers

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        FE_Pages{"Frontend Pages"}
        FE_Pages --> Dashboard["Dashboard"]:::frontend
        FE_Pages --> Playground["Playground"]:::frontend
        FE_Pages --> Settings["Settings"]:::frontend
        FE_Pages --> ABTesting["AB Testing"]:::frontend
        FE_Pages --> UMAP["UMAP Visualization"]:::frontend
        
        UI{"UI Components"}
        UI --> CoreUI["Core UI Library"]:::frontend
        UI --> CustomComps["Custom Components"]:::frontend
        UI --> ModelUI["Model Management UI"]:::frontend
        UI --> EvalUI["Evaluation Display"]:::frontend
    end

    subgraph API
        APIRoutes{"API Routes"}
        APIRoutes --> AdminAPI["/api/admin"]:::api
        APIRoutes --> ModelAPI["/api/manage-models"]:::api
        APIRoutes --> EvalAPI["/api/evaluations"]:::api
        APIRoutes --> UserAPI["/api/user"]:::api
    end

    subgraph Auth
        AuthSystem{"Authentication"}
        AuthSystem --> GoogleOAuth["Google OAuth"]:::auth
        AuthSystem --> LocalAuth["Local Auth"]:::auth
        AuthSystem --> AuthUtils["Auth Utils"]:::auth
    end

    subgraph Database
        DB[(MongoDB)]:::db
        DBIndexes["MongoDB Indexes"]:::db
    end

    subgraph External
        ExtServices{"External Services"}
        ExtServices --> OpenAI["OpenAI API"]:::external
        ExtServices --> GoogleAPI["Google OAuth API"]:::external
    end

    subgraph Core
        CoreApp{"Core Application"}
        CoreApp --> RootLayout["Root Layout"]:::core
        CoreApp --> GlobalStyles["Global Styles"]:::core
        CoreApp --> Types["Type Definitions"]:::core
        CoreApp --> Utils["Utility Functions"]:::core
    end

    Client --> API
    API --> Database
    API --> External
    Auth --> API
    Auth --> External

    classDef frontend fill:#3b82f6,color:#fff
    classDef api fill:#22c55e,color:#fff
    classDef auth fill:#eab308,color:#fff
    classDef db fill:#a855f7,color:#fff
    classDef external fill:#f97316,color:#fff
    classDef core fill:#64748b,color:#fff

    click Dashboard "https://github.com/poemsforaphrodite/eval/blob/main/app/dashboard/page.tsx"
    click Playground "https://github.com/poemsforaphrodite/eval/blob/main/app/playground/page.tsx"
    click Settings "https://github.com/poemsforaphrodite/eval/blob/main/app/settings/page.tsx"
    click ABTesting "https://github.com/poemsforaphrodite/eval/blob/main/app/ab-testing/page.tsx"
    click UMAP "https://github.com/poemsforaphrodite/eval/blob/main/app/umap/page.tsx"
    click CoreUI "https://github.com/poemsforaphrodite/eval/tree/main/app/components/ui/"
    click CustomComps "https://github.com/poemsforaphrodite/eval/tree/main/app/components/"
    click ModelUI "https://github.com/poemsforaphrodite/eval/blob/main/app/components/ManageModels.tsx"
    click EvalUI "https://github.com/poemsforaphrodite/eval/blob/main/app/components/EvaluationResult.tsx"
    click AuthUtils "https://github.com/poemsforaphrodite/eval/blob/main/app/lib/auth.ts"
    click DB "https://github.com/poemsforaphrodite/eval/blob/main/app/lib/mongodb.ts"
    click DBIndexes "https://github.com/poemsforaphrodite/eval/blob/main/app/lib/mongodb-indexes.ts"
    click AdminAPI "https://github.com/poemsforaphrodite/eval/tree/main/app/api/admin/"
    click ModelAPI "https://github.com/poemsforaphrodite/eval/tree/main/app/api/manage-models/"
    click EvalAPI "https://github.com/poemsforaphrodite/eval/tree/main/app/api/evaluations/"
    click UserAPI "https://github.com/poemsforaphrodite/eval/tree/main/app/api/user/"
    click RootLayout "https://github.com/poemsforaphrodite/eval/blob/main/app/layout.tsx"
    click GlobalStyles "https://github.com/poemsforaphrodite/eval/blob/main/app/globals.css"
    click Types "https://github.com/poemsforaphrodite/eval/tree/main/app/types/"
    click Utils "https://github.com/poemsforaphrodite/eval/blob/main/app/lib/utils.ts"
```
