How ankurgajurel/portfolio-2025 works
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.