# ankurgajurel/portfolio-2025 architecture

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

- Interactive diagram: https://gitdiagram.com/ankurgajurel/portfolio-2025
- Repository: https://github.com/ankurgajurel/portfolio-2025

## Overview

##### Project Type and Purpose
- This is a full-stack, server-rendered SPA built with Next.js (app router) and TypeScript.
- It serves as a personal/portfolio site with pages for home, blog posts, galleries, projects, and an API-backed chat feature.

##### File Structure Analysis
- **app/**: Next.js routing layer (server & client components).
- page.tsx, layout.tsx at root – the global layout and entry point.
- /gallery, /blog/[id], /projects/[id] – nested routes, some with dynamic segments.
- /api/chat/route.ts – custom serverless API endpoint for chat.
- **components/**: reusable React UI pieces (footer, navbar, home sections, UI primitives in components/ui).
- **data/**: in-memory, file-based content (blog.ts, projects.ts, skills.ts, etc.).
- **lib/**: utility code and prompt definitions (prompts.ts, utils.ts).
- **store/**: client-side state management (console.ts, likely using Zustand or similar).
- **public/**: static assets (videos, sounds, resume PDF).
- Config & build files: next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs, package.json.

##### Key Architectural Insights from README
- Bootstrapped via create-next-app.
- Uses next/font for optimized loading.
- Deployed on Vercel (serverless hosting).

##### Main Components
a. Client Browser (user interface)
b. Next.js App Server (routes & server components)
c. Serverless Functions (app/api/chat → Chat handler)
d. Data Layer (static files under data/, public assets)
e. Component Library (components/ folder, UI primitives)
f. Client-side State Store (store/console.ts)
g. Deployment Platform (Vercel or equivalent)

##### Relationships & Data Flow
- Browser → Next.js Server: HTTP GET for pages (SSR/SSG).
- Next.js Server → Data Layer: imports from data/*.ts for static content.
- Browser → API Route (/api/chat): POST requests → route.ts → lib/prompts.ts → external service (e.g., OpenAI?).
- Next.js Server → Public Assets: serves from /public.
- Client Components → Store: UI components dispatch & read state from store/console.ts.

##### Architectural Patterns & Design Principles
- **Server Components vs. Client Components**: pages in app/ using ‘use client’ only where necessary (chat bubble, terminal).
- **File-based Routing**: Next.js app router organizes by folder/file names.
- **Modular UI**: components/ui for design system, components/home for page sections.
- **Layered Architecture**: Presentation (components) → Business Logic (lib, store) → Data (data/, public, external).
- **Serverless Functions** for on-demand chat processing.

##### Essential Elements
- Clear component labels (“Home Page Layout”, “Blog Post Page”, “Chat API”).
- Boundary lines showing browser, serverless, and file system layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser Layer
    subgraph "Client Browser" 
        direction TB
        Browser["User's Browser"]:::external
        subgraph "UI Components" 
            direction TB
            Navbar["Navbar"]:::frontend
            Footer["Footer"]:::frontend
            Hero["Home Hero"]:::frontend
            HomeBlog["Home Blog Section"]:::frontend
            ProjectsList["Home Projects Section"]:::frontend
            ProjectCard["Project Card"]:::frontend
            Experience["Experience Section"]:::frontend
            Skills["Skills Section"]:::frontend
            Spotify["Spotify Embed"]:::frontend
            ChatBubble["Chat Bubble"]:::frontend
            Terminal["Terminal"]:::frontend
        end
        subgraph "Component Library (UI Primitives)"
            direction TB
            Button["Button"]:::frontend
            Card["Card"]:::frontend
            Badge["Badge"]:::frontend
        end
        Store["Client State Store"]:::data
    end

    %% Next.js Server Layer
    subgraph "Next.js App Server" 
        direction TB
        Layout["Global Layout (app/layout.tsx)"]:::server
        HomePage["Home Page (app/page.tsx)"]:::server
        GlobalsCSS["Global Styles (app/globals.css)"]:::data
        subgraph "Blog Pages"
            direction TB
            BlogPost["Blog Post Page (app/blog/[id]/page.tsx)"]:::server
        end
        subgraph "Project Pages"
            direction TB
            ProjectPage["Project Detail Page (app/projects/[id]/page.tsx)"]:::server
        end
        subgraph "Gallery Section"
            direction TB
            GalleryLayout["Gallery Layout (app/(gallery)/layout.tsx)"]:::server
            GalleryList["Gallery Listing (app/(gallery)/gallery/page.tsx)"]:::server
            GalleryVideo["Gallery Video View (app/(gallery)/gallery/video.tsx)"]:::server
        end
    end

    %% Serverless API Layer
    subgraph "Serverless Functions"
        direction TB
        ChatAPI["Chat API Route (app/api/chat/route.ts)"]:::api
    end

    %% Data and Utilities Layer
    subgraph "Data Layer" 
        direction TB
        DataBlog["blog.ts"]:::data
        DataProjects["projects.ts"]:::data
        DataSkills["skills.ts"]:::data
        DataExperience["experience.ts"]:::data
        DataGeneral["general.ts"]:::data
    end

    subgraph "Utility & Prompts"
        direction TB
        Utils["utils.ts"]:::data
        Prompts["prompts.ts"]:::data
    end

    %% Public Assets
    subgraph "Public Assets" 
        direction TB
        AssetVideo["sailung-ghoda.mp4"]:::data
        AssetResume["resume.pdf"]:::data
        AssetSound["handgun-click.mp3"]:::data
    end

    %% Configuration & Deployment
    subgraph "Config & Build"
        direction TB
        SiteConfig["siteConfig.ts"]:::data
        NextConfig["next.config.ts"]:::data
        TSConfig["tsconfig.json"]:::data
        PostCSS["postcss.config.mjs"]:::data
        ESLint["eslint.config.mjs"]:::data
        Package["package.json"]:::data
    end

    Vercel["Vercel Deployment"]:::external
    OpenAI["External AI Service"]:::external

    %% Connections - HTTP Requests
    Browser -->|"GET /"| HomePage
    Browser -->|"GET /gallery"| GalleryList
    Browser -->|"GET /gallery/video"| GalleryVideo
    Browser -->|"GET /blog/:id"| BlogPost
    Browser -->|"GET /projects/:id"| ProjectPage
    Browser -->|"POST /api/chat"| ChatAPI
    HomePage -->|renders| Layout
    BlogPost -->|renders| Layout
    ProjectPage -->|renders| Layout
    GalleryList -->|renders| GalleryLayout
    GalleryVideo -->|renders| GalleryLayout

    %% Data Imports (Compile-time)
    Layout -.->|import data| DataGeneral
    BlogPost -.->|import data| DataBlog
    ProjectPage -.->|import data| DataProjects
    Experience -.->|import data| DataExperience
    Skills -.->|import data| DataSkills

    %% Public Assets Serving
    HomePage -->|"serves static"| AssetVideo
    HomePage -->|"serves static"| AssetResume
    HomePage -->|"serves static"| AssetSound

    %% Client Components Dependencies
    Navbar -.->|imports| Button
    Footer -.->|imports| Card
    Hero -.->|imports| Badge
    ChatBubble -.->|uses state| Store
    Terminal -.->|uses state| Store

    %% API Handler
    ChatAPI -->|uses| Prompts
    ChatAPI -->|uses| Utils
    ChatAPI -->|"calls"| OpenAI

    %% Deployment
    HomePage -->|deployed via| Vercel
    ChatAPI -->|serverless via| Vercel

    %% Click Events
    click Navbar "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/navbar.tsx"
    click Footer "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/footer.tsx"
    click Hero "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/hero.tsx"
    click HomeBlog "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/blog.tsx"
    click ProjectsList "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/projects.tsx"
    click ProjectCard "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/project-card.tsx"
    click Experience "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/experience.tsx"
    click Skills "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/skills.tsx"
    click Spotify "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/spotify-embed.tsx"
    click ChatBubble "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/home/chat-bubble.tsx"
    click Terminal "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/terminal.tsx"
    click Button "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/ui/button.tsx"
    click Card "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/ui/card.tsx"
    click Badge "https://github.com/ankurgajurel/portfolio-2025/blob/main/components/ui/badge.tsx"
    click HomePage "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/page.tsx"
    click Layout "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/layout.tsx"
    click GlobalsCSS "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/globals.css"
    click BlogPost "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/blog/[id]/page.tsx"
    click ProjectPage "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/projects/[id]/page.tsx"
    click GalleryList "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/(gallery)/gallery/page.tsx"
    click GalleryVideo "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/(gallery)/gallery/video.tsx"
    click GalleryLayout "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/(gallery)/layout.tsx"
    click ChatAPI "https://github.com/ankurgajurel/portfolio-2025/blob/main/app/api/chat/route.ts"
    click DataBlog "https://github.com/ankurgajurel/portfolio-2025/blob/main/data/blog.ts"
    click DataProjects "https://github.com/ankurgajurel/portfolio-2025/blob/main/data/projects.ts"
    click DataSkills "https://github.com/ankurgajurel/portfolio-2025/blob/main/data/skills.ts"
    click DataExperience "https://github.com/ankurgajurel/portfolio-2025/blob/main/data/experience.ts"
    click DataGeneral "https://github.com/ankurgajurel/portfolio-2025/blob/main/data/general.ts"
    click AssetVideo "https://github.com/ankurgajurel/portfolio-2025/blob/main/public/gallery/sailung-ghoda.mp4"
    click AssetResume "https://github.com/ankurgajurel/portfolio-2025/blob/main/public/resume/resume.pdf"
    click AssetSound "https://github.com/ankurgajurel/portfolio-2025/blob/main/public/sounds/handgun-click.mp3"
    click Store "https://github.com/ankurgajurel/portfolio-2025/blob/main/store/console.ts"
    click Utils "https://github.com/ankurgajurel/portfolio-2025/blob/main/lib/utils.ts"
    click Prompts "https://github.com/ankurgajurel/portfolio-2025/blob/main/lib/prompts.ts"
    click SiteConfig "https://github.com/ankurgajurel/portfolio-2025/blob/main/config/siteConfig.ts"
    click NextConfig "https://github.com/ankurgajurel/portfolio-2025/blob/main/next.config.ts"
    click TSConfig "https://github.com/ankurgajurel/portfolio-2025/blob/main/tsconfig.json"
    click PostCSS "https://github.com/ankurgajurel/portfolio-2025/blob/main/postcss.config.mjs"
    click ESLint "https://github.com/ankurgajurel/portfolio-2025/blob/main/eslint.config.mjs"
    click Package "https://github.com/ankurgajurel/portfolio-2025/blob/main/package.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef server fill:#DFFFE0,stroke:#28a745,color:#28a745
    classDef api fill:#FFF4D0,stroke:#cf8a00,color:#cf8a00
    classDef data fill:#F0F0F0,stroke:#666666,color:#333333
    classDef external fill:#E8E8E8,stroke:#999999,color:#555555
```
