# edgexhq/opbento architecture

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

- Interactive diagram: https://gitdiagram.com/edgexhq/opbento
- Repository: https://github.com/edgexhq/opbento

## Overview

##### Main System Components

A. Frontend Layer
- Pages (Home, About, Guide)
- UI Components
- Theme System
- Client Actions

B. API Layer
- Bento API
- Graph API
- Stats API
- Streak API

C. External Services
- GitHub Integration
- GraphQL API
- OAuth
- Firebase Integration

##### Component Relationships

- User interactions → Frontend
- Frontend → API Routes
- API Routes → External Services
- GitHub GraphQL → Data Processing
- Firebase → Data Persistence

##### Detailed Component Breakdown

A. Frontend Components (src/components):
- Core Components (Bento1, BioBlock, etc.)
- UI Components (buttons, cards, etc.)
- Theme System
- State Management

B. API Architecture:
- API routes structure:
- /api/bento
- /api/graph
- /api/stats
- /api/streak

C. Actions Layer:
- Data fetching layer:
- GitHub Data Fetching
- User Stats Processing
- Contribution Analysis

##### Data Flow

- User Input → Frontend
- Frontend → API Calls
- API → GitHub GraphQL
- Data Processing → Response
- Response → UI Update

##### Technical Elements

Create sections for:
- Next.js App Router
- TypeScript Types
- TailwindCSS Styling
- GitHub Actions Integration
- Puppeteer Services

##### Additional Details

- Authentication flow
- GitHub Actions workflow
- Data refresh mechanism
- Template generation process

##### The integration with GitHub's ecosystem

- Component relationships
- Data flow directions
- External service integrations
- Update mechanisms

This system design should reflect OP Bento's nature as a Next.js application that generates and maintains dynamic GitHub profile components through automated processes and API integrations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        FE[Frontend Layer]
        Pages[Pages]
        UI[UI Components]
        Theme[Theme System]
        ClientActions[Client Actions]
        
        FE --> Pages
        FE --> UI
        FE --> Theme
        FE --> ClientActions
        
        subgraph Pages
            Home["Home Page"]:::file
            About["About Page"]:::file
            Guide["Guide Page"]:::file
        end
        
        subgraph UI
            ThemeProvider["Theme Provider"]:::file
            BaseUI["Base UI Components"]:::dir
            CoreComponents["Core Components"]:::dir
        end
    end
    
    subgraph APILayer
        BentoAPI["Bento API"]:::file
        GraphAPI["Graph API"]:::file
        StatsAPI["Stats API"]:::file
        StreakAPI["Streak API"]:::file
    end
    
    subgraph DataProcessing
        StatsProc["Stats Processing"]:::file
        ContribAnalysis["Contribution Analysis"]:::file
        GraphGen["Graph Generation"]:::file
        Calc["Calculations"]:::file
    end
    
    subgraph ExternalServices
        GitHub[GitHub Integration]
        Firebase["Firebase"]:::file
        
        subgraph GitHubServices
            GraphQL["GraphQL Client"]:::file
            OAuth[OAuth]
            DataFetch["Data Fetching"]:::dir
        end
    end
    
    subgraph Infrastructure
        Types["Type Definitions"]:::file
        Styles["Global Styles"]:::file
        TailwindConfig["Tailwind Config"]:::file
        ColorConst["Color Constants"]:::file
    end
    
    subgraph Automation
        UpdateTemplate["Update Template"]:::file
        BentoTemplate["Bento Template"]:::file
    end
    
    Client --> APILayer
    APILayer --> ExternalServices
    APILayer --> DataProcessing
    DataProcessing --> ExternalServices
    GitHub --> DataProcessing
    
    %% Click Events
    click Home "https://github.com/edgexhq/opbento/blob/main/src/app/page.tsx"
    click About "https://github.com/edgexhq/opbento/blob/main/src/app/about/page.tsx"
    click Guide "https://github.com/edgexhq/opbento/blob/main/src/app/guide/page.tsx"
    click ThemeProvider "https://github.com/edgexhq/opbento/blob/main/src/components/ui/theme-provider.tsx"
    click BaseUI "https://github.com/edgexhq/opbento/tree/main/src/components/ui"
    click CoreComponents "https://github.com/edgexhq/opbento/blob/main/src/components/Bento1.tsx"
    click BentoAPI "https://github.com/edgexhq/opbento/blob/main/src/app/api/bento/route.ts"
    click GraphAPI "https://github.com/edgexhq/opbento/blob/main/src/app/api/graph/route.ts"
    click StatsAPI "https://github.com/edgexhq/opbento/blob/main/src/app/api/stats/route.ts"
    click StreakAPI "https://github.com/edgexhq/opbento/blob/main/src/app/api/streak/route.ts"
    click GraphQL "https://github.com/edgexhq/opbento/blob/main/src/actions/githubGraphql.ts"
    click DataFetch "https://github.com/edgexhq/opbento/blob/main/src/actions/fetchGithubData.ts"
    click StatsProc "https://github.com/edgexhq/opbento/blob/main/src/actions/getUserStats.ts"
    click ContribAnalysis "https://github.com/edgexhq/opbento/blob/main/src/actions/fetchYearContribution.ts"
    click GraphGen "https://github.com/edgexhq/opbento/blob/main/src/utils/generate-graph.ts"
    click Calc "https://github.com/edgexhq/opbento/blob/main/src/utils/calculations.ts"
    click Firebase "https://github.com/edgexhq/opbento/blob/main/src/lib/firebase.ts"
    click Types "https://github.com/edgexhq/opbento/blob/main/src/types/index.d.ts"
    click Styles "https://github.com/edgexhq/opbento/blob/main/src/app/globals.css"
    click TailwindConfig "https://github.com/edgexhq/opbento/blob/main/tailwind.config.ts"
    click ColorConst "https://github.com/edgexhq/opbento/blob/main/src/constant/color.ts"
    click UpdateTemplate "https://github.com/edgexhq/opbento/blob/main/public/update-bento.yml"
    click BentoTemplate "https://github.com/edgexhq/opbento/blob/main/public/getNewBento.ts.template"
    
    classDef file fill:#f9f,stroke:#333,stroke-width:2px
    classDef dir fill:#bbf,stroke:#333,stroke-width:2px
    classDef default fill:#fff,stroke:#333,stroke-width:2px
    
    %% Legend
    subgraph Legend
        File["File"]:::file
        Directory["Directory"]:::dir
        Component["Component"]:::default
    end
```
