# gabriel-pineda/git-wrapped-api architecture

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

- Interactive diagram: https://gitdiagram.com/gabriel-pineda/git-wrapped-api
- Repository: https://github.com/gabriel-pineda/git-wrapped-api

## Overview

##### Main Components

A. Frontend Layer:
- Next.js Client Application
- Pages Component (/src/pages)
- Static Assets (public directory)

B. API Layer:
- Next.js API Routes (/src/pages/api)
- Stats Endpoint (stats.ts)

C. External Services:
- GitHub API Integration
- GitHub OAuth Authentication

D. Data Flow Components:
- GitHub Personal Access Token Handler
- Data Processing Pipeline
- Visualization Generator

**[User Browser] → [Next.js Frontend]**
- ↓
- [API Layer]
- ↓
- [GitHub API Client]
- ↓
- [GitHub API]

##### Specific Implementation Details

- Rectangles: Core application components
- Clouds: External services
- Diamonds: Decision points

- Blue: Frontend components
- Green: API components
- Purple: External services
- Orange: Authentication flow

c) Connections:
- User request flow
- API communication paths
- Data transformation pipeline
- Authentication flow

##### Key Elements to Highlight

a) Frontend Layer:
- Next.js pages structure
- Static and dynamic routes
- Visualization rendering component

b) API Layer:
- Stats.ts endpoint
- GitHub API integration points
- Token management

c) External Integrations:
- GitHub API connection
- Authentication flow
- Data fetching pipeline

##### Implementation Notes

- Request/Response Flow
- Authentication Process
- Data Processing Pipeline
- Visualization Generation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Legend"
        L1[Frontend Component]:::frontend
        L2[API Component]:::api
        L3((External Service)):::external
        L4{Decision Point}:::decision
    end

    subgraph "Frontend Layer"
        Browser[Browser]:::frontend
        NextApp["Next.js Client Application"]:::frontend
        Pages["Pages Component"]:::frontend
        Static["Static Assets"]:::frontend
        Styles["Global Styles"]:::frontend
    end

    subgraph "API Layer"
        APIRoutes["API Routes"]:::api
        StatsEndpoint["Stats Endpoint"]:::api
        TokenHandler["GitHub Token Handler"]:::api
    end

    subgraph "External Services"
        GitHubAPI((GitHub API)):::external
        GitHubOAuth((GitHub OAuth)):::external
    end

    subgraph "Data Processing"
        DataPipeline["Data Processing Pipeline"]:::process
        VisGenerator["Visualization Generator"]:::process
    end

    Browser --> NextApp
    NextApp --> Pages
    NextApp --> Static
    NextApp --> Styles
    
    Pages --> APIRoutes
    APIRoutes --> StatsEndpoint
    StatsEndpoint --> TokenHandler
    
    TokenHandler --> GitHubAPI
    TokenHandler --> GitHubOAuth
    
    GitHubAPI --> DataPipeline
    DataPipeline --> VisGenerator
    VisGenerator --> Pages

    %% Click Events
    click NextApp "https://github.com/gabriel-pineda/git-wrapped-api/blob/main/src/pages/_app.tsx"
    click Pages "https://github.com/gabriel-pineda/git-wrapped-api/blob/main/src/pages/index.tsx"
    click Static "https://github.com/gabriel-pineda/git-wrapped-api/tree/main/public/"
    click APIRoutes "https://github.com/gabriel-pineda/git-wrapped-api/tree/main/src/pages/api/"
    click StatsEndpoint "https://github.com/gabriel-pineda/git-wrapped-api/blob/main/src/pages/api/stats.ts"
    click Styles "https://github.com/gabriel-pineda/git-wrapped-api/blob/main/src/styles/globals.css"

    %% Styles
    classDef frontend fill:#3b82f6,color:#fff
    classDef api fill:#22c55e,color:#fff
    classDef external fill:#a855f7,color:#fff
    classDef process fill:#f97316,color:#fff
    classDef decision fill:#eab308,color:#fff
```
