# sonusatya/portfolio architecture

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

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

## Overview

Sonu Kumar’s portfolio combines a public React site, contact and AI features, and an authenticated content-management dashboard backed by an Express API and MongoDB. Visitors browse portfolio content, open project details, ask the assistant questions, or submit a message; administrators sign in and maintain published content and the inbox. The graph preserves the README’s documented capabilities, while unsampled controller and page internals are represented at their known source paths; those implementation-level links are omitted where evidence is unavailable.

Main entry points: [`client/src/App.tsx`](https://github.com/sonusatya/portfolio/blob/main/client/src/App.tsx) (App routing), [`server/src/routes/admin.routes.ts`](https://github.com/sonusatya/portfolio/blob/main/server/src/routes/admin.routes.ts) (Admin and auth routes), [`server/src/controllers/public.controller.ts`](https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/public.controller.ts) (Public handlers), [`server/src/controllers/admin.controller.ts`](https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/admin.controller.ts) (Admin handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Portfolio website"]
  node_app["App routing<br/>[App.tsx]"]
  node_home["Portfolio home<br/>[Home.tsx]"]
  node_sections["Profile sections"]
  node_projectdetail["Project details<br/>[ProjectDetails.tsx]"]
  node_adminui["Admin dashboard<br/>[Admin.tsx]"]
  node_aichat["AI chat panel<br/>[AIChat.tsx]"]
  node_components["Site components"]
end

subgraph group_clientdata["Client data access"]
  node_datahook["Portfolio data hook"]
  node_apiclient["Typed API client<br/>[api.ts]"]
  node_fallback["Fallback profile data<br/>[content.ts]"]
end

subgraph group_api["API and access control"]
  node_serverapp["HTTP application<br/>[app.ts]"]
  node_publicroutes["Public routes<br/>[public.routes.ts]"]
  node_adminroutes["Admin and auth routes<br/>[admin.routes.ts]"]
  node_publicctrl["Public handlers"]
  node_authctrl["Authentication handlers<br/>[auth.controller.ts]"]
  node_adminctrl["Admin handlers"]
  node_auth["JWT protection<br/>[auth.ts]"]
  node_validation["Request validation<br/>[schemas.ts]"]
  node_ratelimit["Rate limiting<br/>[rateLimit.ts]"]
end

subgraph group_domain["Content and persistence"]
  node_models["Portfolio models"]
  node_messages["Contact messages<br/>[Message.ts]"]
  node_database[("MongoDB<br/>[db.ts]")]
end

subgraph group_intelligence["AI assistant"]
  node_aiservice["AI chat service<br/>[ai.ts]"]
  node_context["Portfolio context"]
end

node_visitor(("Visitor"))
node_adminuser(("Administrator"))
node_gemini{{"Google Gemini"}}

node_visitor -->|"browses"| node_app
node_adminuser -->|"manages content"| node_adminui
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_projectdetail
node_app -->|"routes to"| node_adminui
node_app -->|"renders"| node_aichat
node_app -->|"renders"| node_components
node_home -->|"presents"| node_sections
node_home -.->|"loads content"| node_datahook
node_datahook -->|"fetches"| node_apiclient
node_datahook -->|"falls back to"| node_fallback
node_apiclient -->|"calls API"| node_publicroutes
node_aichat -->|"sends chat"| node_aiservice
node_serverapp -->|"mounts"| node_publicroutes
node_serverapp -->|"mounts"| node_adminroutes
node_publicroutes -->|"dispatches"| node_publicctrl
node_publicroutes -->|"limits requests"| node_ratelimit
node_adminroutes -->|"dispatches"| node_authctrl
node_adminroutes -->|"dispatches"| node_adminctrl
node_adminroutes -->|"guards routes"| node_auth
node_authctrl -->|"sets session"| node_auth
node_adminctrl -->|"validates input"| node_validation
node_adminctrl -->|"reads and writes"| node_models
node_adminctrl -->|"manages inbox"| node_messages
node_publicctrl -->|"uses status"| node_database
node_publicctrl -.->|"reads content"| node_models
node_publicctrl -.->|"stores submissions"| node_messages
node_aiservice -.->|"grounds answers"| node_context
node_aiservice -.->|"requests generation"| node_gemini

click node_app "https://github.com/sonusatya/portfolio/blob/main/client/src/App.tsx"
click node_home "https://github.com/sonusatya/portfolio/blob/main/client/src/pages/Home.tsx"
click node_sections "https://github.com/sonusatya/portfolio/tree/main/client/src/sections"
click node_projectdetail "https://github.com/sonusatya/portfolio/blob/main/client/src/pages/ProjectDetails.tsx"
click node_adminui "https://github.com/sonusatya/portfolio/blob/main/client/src/pages/Admin.tsx"
click node_aichat "https://github.com/sonusatya/portfolio/blob/main/client/src/components/AIChat.tsx"
click node_components "https://github.com/sonusatya/portfolio/tree/main/client/src/components"
click node_datahook "https://github.com/sonusatya/portfolio/blob/main/client/src/hooks/usePortfolioData.ts"
click node_apiclient "https://github.com/sonusatya/portfolio/blob/main/client/src/services/api.ts"
click node_fallback "https://github.com/sonusatya/portfolio/blob/main/client/src/lib/content.ts"
click node_serverapp "https://github.com/sonusatya/portfolio/blob/main/server/src/app.ts"
click node_publicroutes "https://github.com/sonusatya/portfolio/blob/main/server/src/routes/public.routes.ts"
click node_adminroutes "https://github.com/sonusatya/portfolio/blob/main/server/src/routes/admin.routes.ts"
click node_publicctrl "https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/public.controller.ts"
click node_authctrl "https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/auth.controller.ts"
click node_adminctrl "https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/admin.controller.ts"
click node_auth "https://github.com/sonusatya/portfolio/blob/main/server/src/middleware/auth.ts"
click node_validation "https://github.com/sonusatya/portfolio/blob/main/server/src/validators/schemas.ts"
click node_ratelimit "https://github.com/sonusatya/portfolio/blob/main/server/src/middleware/rateLimit.ts"
click node_models "https://github.com/sonusatya/portfolio/tree/main/server/src/models"
click node_messages "https://github.com/sonusatya/portfolio/blob/main/server/src/models/Message.ts"
click node_database "https://github.com/sonusatya/portfolio/blob/main/server/src/config/db.ts"
click node_aiservice "https://github.com/sonusatya/portfolio/blob/main/server/src/services/ai.ts"
click node_context "https://github.com/sonusatya/portfolio/blob/main/server/src/services/portfolioContext.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_app,node_home,node_sections,node_projectdetail,node_adminui,node_aichat,node_components toneBlue
class node_datahook,node_apiclient,node_fallback toneAmber
class node_serverapp,node_publicroutes,node_adminroutes,node_publicctrl,node_authctrl,node_adminctrl,node_auth,node_validation,node_ratelimit toneMint
class node_models,node_messages,node_database toneRose
class node_aiservice,node_context,node_visitor,node_adminuser,node_gemini toneIndigo
```

## Components

### Portfolio website

- [App routing](https://github.com/sonusatya/portfolio/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Portfolio home](https://github.com/sonusatya/portfolio/blob/main/client/src/pages/Home.tsx): `client/src/pages/Home.tsx`
- [Profile sections](https://github.com/sonusatya/portfolio/tree/main/client/src/sections): `client/src/sections`
- [Project details](https://github.com/sonusatya/portfolio/blob/main/client/src/pages/ProjectDetails.tsx): `client/src/pages/ProjectDetails.tsx`
- [Admin dashboard](https://github.com/sonusatya/portfolio/blob/main/client/src/pages/Admin.tsx): `client/src/pages/Admin.tsx`
- [AI chat panel](https://github.com/sonusatya/portfolio/blob/main/client/src/components/AIChat.tsx): `client/src/components/AIChat.tsx`
- [Site components](https://github.com/sonusatya/portfolio/tree/main/client/src/components): `client/src/components`

### Client data access

- [Portfolio data hook](https://github.com/sonusatya/portfolio/blob/main/client/src/hooks/usePortfolioData.ts): `client/src/hooks/usePortfolioData.ts`
- [Typed API client](https://github.com/sonusatya/portfolio/blob/main/client/src/services/api.ts): `client/src/services/api.ts`
- [Fallback profile data](https://github.com/sonusatya/portfolio/blob/main/client/src/lib/content.ts): `client/src/lib/content.ts`

### API and access control

- [HTTP application](https://github.com/sonusatya/portfolio/blob/main/server/src/app.ts): `server/src/app.ts`
- [Public routes](https://github.com/sonusatya/portfolio/blob/main/server/src/routes/public.routes.ts): `server/src/routes/public.routes.ts`
- [Admin and auth routes](https://github.com/sonusatya/portfolio/blob/main/server/src/routes/admin.routes.ts): `server/src/routes/admin.routes.ts`
- [Public handlers](https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/public.controller.ts): `server/src/controllers/public.controller.ts`
- [Authentication handlers](https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/auth.controller.ts): `server/src/controllers/auth.controller.ts`
- [Admin handlers](https://github.com/sonusatya/portfolio/blob/main/server/src/controllers/admin.controller.ts): `server/src/controllers/admin.controller.ts`
- [JWT protection](https://github.com/sonusatya/portfolio/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`
- [Request validation](https://github.com/sonusatya/portfolio/blob/main/server/src/validators/schemas.ts): `server/src/validators/schemas.ts`
- [Rate limiting](https://github.com/sonusatya/portfolio/blob/main/server/src/middleware/rateLimit.ts): `server/src/middleware/rateLimit.ts`

### Content and persistence

- [Portfolio models](https://github.com/sonusatya/portfolio/tree/main/server/src/models): `server/src/models`
- [Contact messages](https://github.com/sonusatya/portfolio/blob/main/server/src/models/Message.ts): `server/src/models/Message.ts`
- [MongoDB](https://github.com/sonusatya/portfolio/blob/main/server/src/config/db.ts): `server/src/config/db.ts`

### AI assistant

- [AI chat service](https://github.com/sonusatya/portfolio/blob/main/server/src/services/ai.ts): `server/src/services/ai.ts`
- [Portfolio context](https://github.com/sonusatya/portfolio/blob/main/server/src/services/portfolioContext.ts): `server/src/services/portfolioContext.ts`

### Other components

- **Visitor**
- **Administrator**
- **Google Gemini**

## Connections

- Visitor → App routing: browses (evidence: `README.md`)
- Administrator → Admin dashboard: manages content (evidence: `README.md`)
- App routing → Portfolio home: routes to (evidence: `client/src/App.tsx`)
- App routing → Project details: routes to (evidence: `client/src/App.tsx`)
- App routing → Admin dashboard: routes to (evidence: `client/src/App.tsx`)
- App routing → AI chat panel: renders (evidence: `client/src/App.tsx`)
- App routing → Site components: renders (evidence: `client/src/App.tsx`)
- Portfolio home → Profile sections: presents (evidence: `README.md`)
- Portfolio home → Portfolio data hook: loads content
- Portfolio data hook → Typed API client: fetches (evidence: `client/src/hooks/usePortfolioData.ts`)
- Portfolio data hook → Fallback profile data: falls back to (evidence: `client/src/hooks/usePortfolioData.ts`)
- Typed API client → Public routes: calls API (evidence: `README.md`)
- AI chat panel → AI chat service: sends chat (evidence: `README.md`)
- HTTP application → Public routes: mounts (evidence: `server/src/app.ts`)
- HTTP application → Admin and auth routes: mounts (evidence: `server/src/app.ts`)
- Public routes → Public handlers: dispatches (evidence: `server/src/routes/public.routes.ts`)
- Public routes → Rate limiting: limits requests (evidence: `server/src/routes/public.routes.ts`)
- Admin and auth routes → Authentication handlers: dispatches (evidence: `server/src/routes/admin.routes.ts`)
- Admin and auth routes → Admin handlers: dispatches (evidence: `server/src/routes/admin.routes.ts`)
- Admin and auth routes → JWT protection: guards routes (evidence: `server/src/routes/admin.routes.ts`)
- Authentication handlers → JWT protection: sets session (evidence: `server/src/controllers/auth.controller.ts`)
- Admin handlers → Request validation: validates input (evidence: `server/src/controllers/admin.controller.ts`)
- Admin handlers → Portfolio models: reads and writes (evidence: `server/src/controllers/admin.controller.ts`)
- Admin handlers → Contact messages: manages inbox (evidence: `server/src/controllers/admin.controller.ts`)
- Public handlers → MongoDB: uses status (evidence: `server/src/routes/public.routes.ts`)
- Public handlers → Portfolio models: reads content
- Public handlers → Contact messages: stores submissions (evidence: `README.md`)
- AI chat service → Portfolio context: grounds answers (evidence: `README.md`)
- AI chat service → Google Gemini: requests generation (evidence: `README.md`)
