# pungrumpy/v2-website architecture

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

- Interactive diagram: https://gitdiagram.com/pungrumpy/v2-website
- Repository: https://github.com/pungrumpy/v2-website

## Overview

##### Project Type & Purpose
- This is a monolithic full-stack Next.js 14 personal website with an App Router structure.
- It serves as a portfolio/blog site, styled with TailwindCSS + shadcn/ui, animated via Framer Motion, and content-driven by a Sanity headless CMS.
- It also exposes a small serverless API (`/api/github`) and uses Redis for caching via `lib/redis.ts`.

##### File-Structure Analysis
- **app/** – Next.js App Router entry points (page.tsx, layout.tsx), nested routes under `(app)` for about, projects, takes, plus `/api/github/route.ts`.
- **components/** – Reusable UI pieces (buttons, cards, layout, animations, sanity blocks, providers).
- **hooks/** – Custom React hooks (toast, filtered takes).
- **lib/** – Shared utilities (EXIF support, favicon generator, Redis client, generic utils).
- **sanity/** – Sanity Studio config, client, image helper, and content schemas.
- **public/** – Static assets (images, gallery).
- **config/**, **next.config.mjs**, **tailwind.config.ts**, **postcss.config.mjs**, **eslint.config.mjs**, **tsconfig.json**, and **bun.lockb** for build, lint, and package management.

##### Key Architecture Components
a. **Client (Browser)**
- Loads React pages and components from Next.js
- Executes client-side animations (Framer Motion)
- Switches themes (light/dark) via theme provider.
b. **Next.js Server**
- Renders pages SSR/SSG via the App Router.
- Serves static assets from `/public`.
- Hosts serverless function at `/api/github` that proxies GitHub API calls.
c. **Sanity CMS**
- Headless CMS for dynamic content (projects, takes, profile).
- Accessed via `sanity/lib/client.ts` and GROQ queries.
- Sanity Studio served under `/studio/[...tool]`.
d. **Redis Cache**
- Caches external data or computed values (via `lib/redis.ts`).
e. **External Services**
- GitHub API (via `/api/github`).
- Optional 3D service (Spline embedding).

##### Relationships & Data Flow
- Browser → Next.js Server (page request)
- Next.js Server → Sanity CMS (GROQ queries)
- Next.js Server → Redis (get/set cached values)
- Next.js Server (API route) → GitHub API
- Browser → Spline (client-side embed)
- Static assets served directly from `/public`

##### Architectural Patterns & Principles
- **App Router & Server Components** – separation of server/client code.
- **Headless CMS** – decoupled content management.
- **Serverless Functions** – lightweight backend for third-party API integration.
- **Caching** – Redis for performance.
- **Component-Driven UI** – atomic React components under `components/`.
- **Utility Layer** – generic helpers in `lib/`.
- **Custom Hooks** – encapsulate stateful logic.

##### Technologies & Frameworks
- Next.js 14 (App Router)
- TypeScript
- Tailwind CSS, shadcn/ui
- Framer Motion, Spline
- Sanity.io (headless CMS + Studio)
- Redis
- Bun (package manager)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Browser (Client)" 
        direction TB
        Browser["Browser"]:::frontend
        Spline["Spline Embed"]:::external
    end

    %% Next.js Server Layer
    subgraph "Next.js Server" 
        direction TB
        SSR["SSR/SSG via App Router"]:::server
        API["/api/github Function"]:::server
        StaticSrv["Static Assets Server"]:::server
        Studio["Sanity Studio"]:::server
    end

    %% Data & Cache Layer
    subgraph "Data & Cache" 
        direction TB
        Sanity["Sanity CMS"]:::data
        Redis["Redis Cache"]:::data
    end

    %% Static Assets
    PublicAssets["Static Assets (/public)"]:::data

    %% External Services
    subgraph "External Services"
        direction TB
        GitHub["GitHub API"]:::external
    end

    %% Data Flows
    Browser -->|"Request Page"| SSR
    SSR -->|"GROQ Query"| Sanity
    SSR -->|"get/set Cache"| Redis
    SSR -->|"Serve Asset"| StaticSrv
    StaticSrv --> PublicAssets
    SSR -->|"Render Response"| Browser

    Browser -->|"Fetch API"| API
    API -->|"Proxy Request"| GitHub
    GitHub --> API
    API -->|"Return Data"| Browser

    Browser -->|"Embed Content"| Spline

    Browser -->|"Fetch Static"| PublicAssets

    %% Click Events
    click SSR "https://github.com/pungrumpy/v2-website/blob/main/app/(app)/page.tsx"
    click SSR "https://github.com/pungrumpy/v2-website/blob/main/app/(app)/layout.tsx"
    click SSR "https://github.com/pungrumpy/v2-website/blob/main/app/(app)/about/page.tsx"
    click SSR "https://github.com/pungrumpy/v2-website/blob/main/app/(app)/projects/page.tsx"
    click SSR "https://github.com/pungrumpy/v2-website/blob/main/app/(app)/projects/[project]/page.tsx"
    click SSR "https://github.com/pungrumpy/v2-website/blob/main/app/(app)/takes/page.tsx"
    click API "https://github.com/pungrumpy/v2-website/blob/main/app/api/github/route.ts"
    click Sanity "https://github.com/pungrumpy/v2-website/blob/main/sanity/lib/client.ts"
    click Studio "https://github.com/pungrumpy/v2-website/blob/main/app/studio/[[...tool]]/page.tsx"
    click Redis "https://github.com/pungrumpy/v2-website/blob/main/lib/redis.ts"
    click PublicAssets "https://github.com/pungrumpy/v2-website/tree/main/public/"

    %% Styles
    classDef frontend fill:#DDEEFF,stroke:#888,stroke-width:1px
    classDef server fill:#AACCEE,stroke:#888,stroke-width:1px
    classDef data fill:#CCFFCC,stroke:#888,stroke-width:1px
    classDef external fill:#FFDDAA,stroke:#888,stroke-width:1px
```
