# namidapoo/dev-recap architecture

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

- Interactive diagram: https://gitdiagram.com/namidapoo/dev-recap
- Repository: https://github.com/namidapoo/dev-recap

## Overview

##### Main Components
- Frontend/UI:
- The application is built using the Next.js App Router (you see “app/” directory) with a defined layout (layout.tsx), pages (page.tsx, profile-form.tsx, etc.), and a dedicated “recap” section (app/recap) with dynamic routes ([user] folders), components (graphs, headers, theme toggle, etc.), and loading/error states.
- A separate “components/ui” folder defines reusable UI subcomponents (buttons, cards, charts, etc.).
- Backend/API:
- The “app/api” directory contains API endpoints. Notably, the authentication routes are implemented under “app/api/auth” leveraging NextAuth (route defined in route.ts).
- Business Logic / Library Code:
- The “lib” directory contains utilities and authentication helpers.
- External Services & Integration:
- The project integrates with GitHub (e.g., fetchGitHubStats.ts) and uses a GITHUB_TOKEN for accessing private organization repositories.
- Deployment and hosting are configured through Cloudflare Pages (wrangler.toml, Cloudflare-specific workflows) and GitHub workflows (in the .github/workflows folder).
- Configuration & Environment:
- Environment variables (.env.example) and a variety of configuration files (next.config.ts, tailwind.config.ts, postcss.config.mjs, etc.) indicate customization and deployment settings.

##### Relationships and Data Flow
- The UI (frontend components in app/) communicates with API endpoints (app/api) to handle tasks like authentication and fetching data (e.g., GitHub activity data).
- Reusable UI components from the “components/ui” folder are consumed within the higher-level page components in “app/recap” and others.
- Utility functions from “lib” support both API endpoints and frontend components.
- Deployment tools (GitHub workflows & Cloudflare Pages) operate outside of runtime logic but impact how code changes are deployed and integrated.
- External requests to GitHub (using fetchGitHubStats and setting the GITHUB_TOKEN) are made from within server/API code, later feeding data into the user interface.

##### Architectural Patterns and Design Principles
- Next.js App Router: The project embraces the Next.js conventions for file-based routing (with dynamic [user] routes) and server-side rendering.
- Separation of Concerns: Clear demarcation between UI components, API endpoints, and utility libraries.
- Modular Design and Reusability: “components/ui” and “lib” showcase a modular approach to building maintainable UI and logic.
- CI/CD and Cloud Deployment: GitHub workflows are tailored to various tasks (auto-assign, conflict-finder, and deploy steps to Cloudflare), ensuring quality and smooth deployments for self-hosting.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A["Next.js Frontend (app/)"]:::frontend
        B["Recap Section (app/recap)"]:::frontend
        C["Reusable UI Components (components/ui)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        D["API Endpoints (app/api)"]:::backend
        E["Authentication (NextAuth)"]:::backend
        F["Utility Library (lib)"]:::utility
    end

    %% External Integrations
    subgraph "External Integrations"
        G["GitHub Integration (fetchGitHubStats)"]:::integration
        H["CI/CD Pipelines (GitHub Workflows)"]:::deployment
        I["Cloudflare Deployment"]:::deployment
    end

    %% Configuration & Environment
    subgraph "Configuration"
        J["Configuration & Environment"]:::config
    end

    %% Relationships
    A -->|"APIcalls"| D
    A -->|"UsesUI"| C
    B -->|"UsesUI"| C
    B -->|"FetchStats"| G
    D -->|"AuthHandling"| E
    D -->|"UsesUtilities"| F
    D -->|"FetchData"| G
    H -->|"DeploysTo"| I
    J -->|"Supports"| A
    J -->|"Supports"| D

    %% Click Events
    click A "https://github.com/namidapoo/dev-recap/blob/dev/app/layout.tsx"
    click B "https://github.com/namidapoo/dev-recap/tree/dev/app/recap"
    click C "https://github.com/namidapoo/dev-recap/tree/dev/components/ui"
    click D "https://github.com/namidapoo/dev-recap/tree/dev/app/api"
    click E "https://github.com/namidapoo/dev-recap/blob/dev/app/api/auth/[...nextauth]/route.ts"
    click F "https://github.com/namidapoo/dev-recap/tree/dev/lib"
    click G "https://github.com/namidapoo/dev-recap/blob/dev/app/recap/fetchGitHubStats.ts"
    click H "https://github.com/namidapoo/dev-recap/tree/dev/.github/workflows"
    click I "https://github.com/namidapoo/dev-recap/blob/dev/wrangler.toml"
    click J "https://github.com/namidapoo/dev-recap/blob/dev/.env.example"

    %% Styles
    classDef frontend fill:#aee1f9,stroke:#333,stroke-width:2px,color:#000;
    classDef backend fill:#c1f9c1,stroke:#333,stroke-width:2px,color:#000;
    classDef utility fill:#f9e1a9,stroke:#333,stroke-width:2px,color:#000;
    classDef integration fill:#f9c1c1,stroke:#333,stroke-width:2px,color:#000;
    classDef deployment fill:#d1c1f9,stroke:#333,stroke-width:2px,color:#000;
    classDef config fill:#c1f9f1,stroke:#333,stroke-width:2px,color:#000;
```
