# alihamzaio/portfolio architecture

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

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

## Overview

#### Purpose and entry points
This is a Next.js 16 App Router portfolio with a public, SEO-oriented profile site and a CMS-style admin surface for updating portfolio data without code redeploys. Public routing begins under `app/(site)/page.tsx`; admin begins at `app/admin/page.tsx`; HTTP boundaries are implemented in `app/api/**/route.ts`.

#### Public site composition
The site route group supplies shared navigation, footer, providers, and page transitions through `app/(site)/layout.tsx` and `app/(site)/template.tsx`. The homepage is section-composed from `components/home/home-hero.tsx`, `components/home/home-projects.tsx`, and related content components. Dedicated routes render about, contact, experience, technology, blog, project gallery, and slug-addressed project detail, notably `app/(site)/projects/page.tsx` and `app/(site)/projects/[slug]/page.tsx`.

#### Content read model and fallbacks
Editable public content is served via settings, experience, projects, and skills APIs, with local JSON/default data as the baseline. Content/storage abstraction is centered in `lib/content.ts`, `lib/store.ts`, and `lib/settings.ts`. Editable source files include `lib/settings.json`, `lib/experience.json`, `lib/projects.json`, and `lib/skill.json`; code-owned fallback and curated content lives in `lib/site.ts`, `lib/featured-projects.ts`, and `lib/skills-data.ts`.

#### Admin and authentication flow
`app/admin/page.tsx` renders the dashboard or OTP login using `components/admin/admin-login.tsx` and `components/admin/admin-shell.tsx`. An administrator requests and verifies an email OTP through `app/api/auth/send-otp/route.ts` and `app/api/auth/verify-otp/route.ts`; the client keeps the resulting seven-day bearer session in local storage via `lib/auth-client.ts`. Server-side authorization/session validation is centralized by `lib/auth.ts` and `lib/admin.ts`. Resend delivers production OTP email through `lib/email.ts`.

#### Content-management API boundary
Public GET and authenticated mutation endpoints expose REST operations for portfolio data: `app/api/settings/route.ts`, `app/api/experience/route.ts`, `app/api/projects/route.ts`, and `app/api/skills/route.ts`, with entity operations under their dynamic `[id]` or `[name]` routes. Admin writes pass through this API boundary rather than directly coupling UI to files or KV. `app/api/resume/route.ts` manages PDFs and active selection; `app/api/resume/download/route.ts` resolves the publicly downloadable active CV from `public/resume/active.json`.

#### Persistence and deployment constraints
`lib/store.ts` selects filesystem/local JSON behavior or remote persistent storage using Vercel KV or Upstash Redis environment credentials. Filesystem-backed auth/session data is ephemeral under serverless deployment, while portfolio JSON should use KV/Upstash in production. Resume assets remain file-based in `public/resume/`. Deployment targets Vercel (`vercel.json`); `app/api/cron/keepalive/route.ts` plus `.github/workflows/keepalive.yml` support a keepalive path.

#### Presentation, enhancement, and discoverability
The root shell in `app/layout.tsx` applies global styling and shared SEO. Client-side visual enhancement is isolated from core content in `components/effects/hero-dev-scene.tsx`, `components/effects/enhancement-runtime.tsx`, and cursor/effect modules, using Framer Motion and React Three Fiber/Three.js. SEO is generated through `lib/seo.ts`, `lib/seo-structured.ts`, and route artifacts such as `app/opengraph-image.tsx`, `app/sitemap.ts`, and `app/robots.ts`. Google Analytics is deferred through `components/google-analytics.tsx`.

Main entry points: [`app/api/projects/route.ts`](https://github.com/alihamzaio/portfolio/blob/main/app/api/projects/route.ts) (Portfolio content API), [`app/(site)/layout.tsx`](https://github.com/alihamzaio/portfolio/blob/main/app/(site)/layout.tsx) (Site shell), [`lib/content.ts`](https://github.com/alihamzaio/portfolio/blob/main/lib/content.ts) (Content abstraction), [`app/layout.tsx`](https://github.com/alihamzaio/portfolio/blob/main/app/layout.tsx) (Root shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public site"]
  node_root["Root shell<br/>Next.js layout<br/>[layout.tsx]"]
  node_site_shell["Site shell<br/>route layout<br/>[layout.tsx]"]
  node_site_template["Page transitions<br/>route template<br/>[template.tsx]"]
  node_home["Homepage<br/>public route<br/>[page.tsx]"]
  node_home_sections["Home sections<br/>React components<br/>[home-projects.tsx]"]
  node_project_routes["Project gallery &amp; detail<br/>public routes<br/>[page.tsx]"]
  node_visual_effects["Visual enhancement<br/>client effects"]
end

subgraph group_admin["Admin &amp; API"]
  node_admin_page["Admin entry<br/>admin route<br/>[page.tsx]"]
  node_admin_ui["Admin UI<br/>React components<br/>[admin-shell.tsx]"]
  node_otp_api["OTP authentication<br/>API routes<br/>[route.ts]"]
  node_auth["Server authorization<br/>auth service<br/>[auth.ts]"]
  node_content_api["Portfolio content API<br/>REST API routes<br/>[route.ts]"]
  node_resume_api["Resume API<br/>API routes<br/>[route.ts]"]
end

subgraph group_content["Content &amp; storage"]
  node_content_layer["Content abstraction<br/>content service<br/>[content.ts]"]
  node_store[("Adaptive store<br/>persistence adapter<br/>[store.ts]")]
  node_editable_json["Editable JSON<br/>local content<br/>[projects.json]"]
  node_code_fallbacks["Code fallbacks<br/>curated content<br/>[site.ts]"]
  node_resume_files["Resume assets<br/>public files<br/>[active.json]"]
end

subgraph group_platform["Delivery &amp; discoverability"]
  node_seo["SEO generation<br/>SEO utilities<br/>[seo.ts]"]
  node_seo_artifacts["SEO route artifacts<br/>Next.js metadata routes<br/>[sitemap.ts]"]
  node_analytics["Google Analytics<br/>deferred client integration"]
  node_keepalive["Keepalive endpoint<br/>cron API route<br/>[route.ts]"]
end

node_root -->|"wraps"| node_site_shell
node_site_shell -->|"applies"| node_site_template
node_site_shell -->|"renders"| node_home
node_home -->|"composes"| node_home_sections
node_home -->|"reads content"| node_content_api
node_project_routes -->|"reads projects"| node_content_api
node_site_shell -.->|"enhances"| node_visual_effects
node_admin_page -->|"renders"| node_admin_ui
node_admin_page -->|"requests login"| node_otp_api
node_otp_api -->|"creates session"| node_auth
node_admin_ui -->|"manages content"| node_content_api
node_content_api -->|"authorizes mutations"| node_auth
node_content_api -->|"reads and writes"| node_content_layer
node_content_layer -->|"persists through"| node_store
node_content_layer -.->|"uses baseline"| node_editable_json
node_content_layer -.->|"falls back to"| node_code_fallbacks
node_resume_api -->|"authorizes management"| node_auth
node_resume_api -->|"serves active CV"| node_resume_files
node_root -->|"uses"| node_seo
node_seo -->|"feeds"| node_seo_artifacts
node_root -.->|"defers"| node_analytics

click node_root "https://github.com/alihamzaio/portfolio/blob/main/app/layout.tsx"
click node_site_shell "https://github.com/alihamzaio/portfolio/blob/main/app/(site)/layout.tsx"
click node_site_template "https://github.com/alihamzaio/portfolio/blob/main/app/(site)/template.tsx"
click node_home "https://github.com/alihamzaio/portfolio/blob/main/app/(site)/page.tsx"
click node_home_sections "https://github.com/alihamzaio/portfolio/blob/main/components/home/home-projects.tsx"
click node_project_routes "https://github.com/alihamzaio/portfolio/blob/main/app/(site)/projects/%5Bslug%5D/page.tsx"
click node_visual_effects "https://github.com/alihamzaio/portfolio/blob/main/components/effects/enhancement-runtime.tsx"
click node_admin_page "https://github.com/alihamzaio/portfolio/blob/main/app/admin/page.tsx"
click node_admin_ui "https://github.com/alihamzaio/portfolio/blob/main/components/admin/admin-shell.tsx"
click node_otp_api "https://github.com/alihamzaio/portfolio/blob/main/app/api/auth/verify-otp/route.ts"
click node_auth "https://github.com/alihamzaio/portfolio/blob/main/lib/auth.ts"
click node_content_api "https://github.com/alihamzaio/portfolio/blob/main/app/api/projects/route.ts"
click node_resume_api "https://github.com/alihamzaio/portfolio/blob/main/app/api/resume/download/route.ts"
click node_content_layer "https://github.com/alihamzaio/portfolio/blob/main/lib/content.ts"
click node_store "https://github.com/alihamzaio/portfolio/blob/main/lib/store.ts"
click node_editable_json "https://github.com/alihamzaio/portfolio/blob/main/lib/projects.json"
click node_code_fallbacks "https://github.com/alihamzaio/portfolio/blob/main/lib/site.ts"
click node_resume_files "https://github.com/alihamzaio/portfolio/blob/main/public/resume/active.json"
click node_seo "https://github.com/alihamzaio/portfolio/blob/main/lib/seo.ts"
click node_seo_artifacts "https://github.com/alihamzaio/portfolio/blob/main/app/sitemap.ts"
click node_analytics "https://github.com/alihamzaio/portfolio/blob/main/components/google-analytics.tsx"
click node_keepalive "https://github.com/alihamzaio/portfolio/blob/main/app/api/cron/keepalive/route.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root,node_site_shell,node_site_template,node_home,node_home_sections,node_project_routes,node_visual_effects toneBlue
class node_admin_page,node_admin_ui,node_otp_api,node_auth,node_content_api,node_resume_api toneAmber
class node_content_layer,node_store,node_editable_json,node_code_fallbacks,node_resume_files toneMint
class node_seo,node_seo_artifacts,node_analytics,node_keepalive toneRose
```

## Components

### Public site

- [Root shell](https://github.com/alihamzaio/portfolio/blob/main/app/layout.tsx): Next.js layout · Global styling and shared SEO. · `app/layout.tsx`
- [Site shell](https://github.com/alihamzaio/portfolio/blob/main/app/(site)/layout.tsx): route layout · Shared navigation, footer, providers, and transitions. · `app/(site)/layout.tsx`
- [Page transitions](https://github.com/alihamzaio/portfolio/blob/main/app/(site)/template.tsx): route template · `app/(site)/template.tsx`
- [Homepage](https://github.com/alihamzaio/portfolio/blob/main/app/(site)/page.tsx): public route · Section-composed portfolio landing page. · `app/(site)/page.tsx`
- [Home sections](https://github.com/alihamzaio/portfolio/blob/main/components/home/home-projects.tsx): React components · `components/home/home-projects.tsx`
- [Project gallery & detail](https://github.com/alihamzaio/portfolio/blob/main/app/(site)/projects/%5Bslug%5D/page.tsx): public routes · Gallery and slug-addressed project pages. · `app/(site)/projects/[slug]/page.tsx`
- [Visual enhancement](https://github.com/alihamzaio/portfolio/blob/main/components/effects/enhancement-runtime.tsx): client effects · Optional Motion and Three.js presentation layer. · `components/effects/enhancement-runtime.tsx`

### Admin & API

- [Admin entry](https://github.com/alihamzaio/portfolio/blob/main/app/admin/page.tsx): admin route · Selects OTP login or dashboard. · `app/admin/page.tsx`
- [Admin UI](https://github.com/alihamzaio/portfolio/blob/main/components/admin/admin-shell.tsx): React components · `components/admin/admin-shell.tsx`
- [OTP authentication](https://github.com/alihamzaio/portfolio/blob/main/app/api/auth/verify-otp/route.ts): API routes · Email OTP issuance and verification. · `app/api/auth/verify-otp/route.ts`
- [Server authorization](https://github.com/alihamzaio/portfolio/blob/main/lib/auth.ts): auth service · Validates sessions and admin access. · `lib/auth.ts`
- [Portfolio content API](https://github.com/alihamzaio/portfolio/blob/main/app/api/projects/route.ts): REST API routes · Public reads and authenticated portfolio mutations. · `app/api/projects/route.ts`
- [Resume API](https://github.com/alihamzaio/portfolio/blob/main/app/api/resume/download/route.ts): API routes · Manages PDFs and resolves the active download. · `app/api/resume/download/route.ts`

### Content & storage

- [Content abstraction](https://github.com/alihamzaio/portfolio/blob/main/lib/content.ts): content service · Unifies settings, entities, fallbacks, and storage. · `lib/content.ts`
- [Adaptive store](https://github.com/alihamzaio/portfolio/blob/main/lib/store.ts): persistence adapter · Uses local filesystem or Vercel KV/Upstash Redis. · `lib/store.ts`
- [Editable JSON](https://github.com/alihamzaio/portfolio/blob/main/lib/projects.json): local content · Baseline settings, experience, projects, and skills. · `lib/projects.json`
- [Code fallbacks](https://github.com/alihamzaio/portfolio/blob/main/lib/site.ts): curated content · `lib/site.ts`
- [Resume assets](https://github.com/alihamzaio/portfolio/blob/main/public/resume/active.json): public files · File-based PDFs and active selection. · `public/resume/active.json`

### Delivery & discoverability

- [SEO generation](https://github.com/alihamzaio/portfolio/blob/main/lib/seo.ts): SEO utilities · Metadata and structured data generation. · `lib/seo.ts`
- [SEO route artifacts](https://github.com/alihamzaio/portfolio/blob/main/app/sitemap.ts): Next.js metadata routes · Open Graph image, sitemap, and robots output. · `app/sitemap.ts`
- [Google Analytics](https://github.com/alihamzaio/portfolio/blob/main/components/google-analytics.tsx): deferred client integration · `components/google-analytics.tsx`
- [Keepalive endpoint](https://github.com/alihamzaio/portfolio/blob/main/app/api/cron/keepalive/route.ts): cron API route · Supports scheduled deployment keepalive. · `app/api/cron/keepalive/route.ts`

## Connections

- Root shell → Site shell: wraps
- Site shell → Page transitions: applies
- Site shell → Homepage: renders
- Homepage → Home sections: composes
- Homepage → Portfolio content API: reads content
- Project gallery & detail → Portfolio content API: reads projects
- Site shell → Visual enhancement: enhances
- Admin entry → Admin UI: renders
- Admin entry → OTP authentication: requests login
- OTP authentication → Server authorization: creates session
- Admin UI → Portfolio content API: manages content
- Portfolio content API → Server authorization: authorizes mutations
- Portfolio content API → Content abstraction: reads and writes
- Content abstraction → Adaptive store: persists through
- Content abstraction → Editable JSON: uses baseline
- Content abstraction → Code fallbacks: falls back to
- Resume API → Server authorization: authorizes management
- Resume API → Resume assets: serves active CV
- Root shell → SEO generation: uses
- SEO generation → SEO route artifacts: feeds
- Root shell → Google Analytics: defers
