# ryanlegler/git-graph architecture

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

- Interactive diagram: https://gitdiagram.com/ryanlegler/git-graph
- Repository: https://github.com/ryanlegler/git-graph

## Overview

##### Main System Components

a) Client-Side (Frontend):
- Next.js Application Layer
- Component Layer
- State Management (indicated by atoms.ts)
- UI Components Library
- Data Visualization Layer (Graph component)

b) Server-Side:
- Next.js Server Components
- API Routes
- Data Fetching Layer

##### Detailed Component Breakdown

a) Page Components:
- Main Page (/)
- Preview Page (/preview/[username])
- Embed Page (/embed/[username])
- Theme Page (/theme)

b) Core Feature Components (show as interconnected modules):
- Builder Component
- Graph Component
- Controls Component
- Header Component
- EmbedCodeModal Component

c) Data Flow Layer:
- Data Fetching (dataLayer folder)
- Contribution Processing
- State Management

##### Interaction Flows

**User Input → Controls → Builder → Graph**
**Data Layer → Contributions Data → Graph**
**Theme Settings → Builder → Graph**

##### Technical Implementation Details

A section showing:
- Next.js App Router Architecture
- Server/Client Component Split
- Data Fetching Pattern
- State Management Flow

##### Specific Implementation Notes

- React Server Components (RSC)
- Client Components
- Data Fetching Boundaries
- State Management Boundaries

1. The app's modular architecture with clear separation between builder, controls, and visualization components
##### The theme customization system

Key Relationships to Highlight:
- Builder → Graph (visualization rendering)
- Controls → Builder (user input handling)
- DataLayer → Components (data flow)
- Theme → Builder (styling system)

Remember to:
- Keep components grouped by functionality
- Clear boundaries between client/server code
- State management flow
- Embedding feature's architecture

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        direction TB
        MainPage["Main Page"]:::client
        PreviewPage["Preview Page"]:::client
        EmbedPage["Embed Page"]:::client
        ThemePage["Theme Page"]:::client

        subgraph Components
            direction TB
            Builder["Builder Component"]:::client
            Graph["Graph Component"]:::client
            Controls["Controls Component"]:::client
            Header["Header Component"]:::client
            EmbedModal["Embed Code Modal"]:::client
            
            subgraph ControlComponents
                SliderControl["Slider Control"]:::client
                SwitchControl["Switch Control"]:::client
            end
            
            Controls --> ControlComponents
        end

        subgraph StateManagement
            Atoms["State Management"]:::state
        end
    end

    subgraph Server
        direction TB
        AppLayout["Application Layout"]:::server
        LoadingStates["Loading States"]:::server
        
        subgraph DataLayer
            DataFetching["Data Fetching"]:::data
            ContribProcessing["Contribution Processing"]:::data
            DataTypes["Data Types"]:::data
        end
    end

    subgraph Utilities
        Utils["Utility Functions"]:::util
        ComponentTypes["Component Types"]:::util
    end

    Controls --> Builder
    Builder --> Graph
    DataLayer --> Builder
    Atoms --> Components
    ComponentTypes --> Components

    %% Click events for file/directory mapping
    click MainPage "https://github.com/ryanlegler/git-graph/blob/main/src/app/page.tsx"
    click PreviewPage "https://github.com/ryanlegler/git-graph/blob/main/src/app/preview/[userName]/page.tsx"
    click EmbedPage "https://github.com/ryanlegler/git-graph/blob/main/src/app/embed/[username]/page.tsx"
    click ThemePage "https://github.com/ryanlegler/git-graph/blob/main/src/app/theme/page.tsx"
    click Builder "https://github.com/ryanlegler/git-graph/blob/main/src/components/builder/Builder.tsx"
    click Graph "https://github.com/ryanlegler/git-graph/blob/main/src/components/graph/Graph.tsx"
    click Controls "https://github.com/ryanlegler/git-graph/blob/main/src/components/controls/Controls.tsx"
    click Header "https://github.com/ryanlegler/git-graph/blob/main/src/components/header/Header.tsx"
    click EmbedModal "https://github.com/ryanlegler/git-graph/blob/main/src/components/embedCodeModal/EmbedCodeModal.tsx"
    click SliderControl "https://github.com/ryanlegler/git-graph/blob/main/src/components/controls/sliderControl/SliderControl.tsx"
    click SwitchControl "https://github.com/ryanlegler/git-graph/blob/main/src/components/controls/switchControl/SwitchControl.tsx"
    click Atoms "https://github.com/ryanlegler/git-graph/blob/main/src/app/atoms.ts"
    click AppLayout "https://github.com/ryanlegler/git-graph/blob/main/src/app/layout.tsx"
    click LoadingStates "https://github.com/ryanlegler/git-graph/blob/main/src/app/loading.tsx"
    click DataFetching "https://github.com/ryanlegler/git-graph/blob/main/src/dataLayer/getContributions.ts"
    click ContribProcessing "https://github.com/ryanlegler/git-graph/blob/main/src/dataLayer/utils.ts"
    click DataTypes "https://github.com/ryanlegler/git-graph/blob/main/src/dataLayer/types.ts"
    click Utils "https://github.com/ryanlegler/git-graph/blob/main/src/lib/utils.ts"
    click ComponentTypes "https://github.com/ryanlegler/git-graph/blob/main/src/components/builder/types.ts"

    %% Styling
    classDef client fill:#2374ab,color:#fff
    classDef server fill:#2a9d8f,color:#fff
    classDef data fill:#e9c46a,color:#000
    classDef state fill:#e76f51,color:#fff
    classDef util fill:#8338ec,color:#fff

    %% Legend
    subgraph Legend
        ClientComp["Client Component"]:::client
        ServerComp["Server Component"]:::server
        DataComp["Data Layer"]:::data
        StateComp["State Management"]:::state
        UtilComp["Utilities"]:::util
    end
```
