# omar-khecharem/portfolio architecture

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

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

## Overview

This is a full-stack portfolio: visitors browse profile, projects, and contact content; admins sign in to manage portfolio content and configuration, while the site records visits and offers an AI assistant. The React app calls an Express API backed by MongoDB, with Cloudflare Workers AI documented for chatbot inference. The graph preserves public, administration, analytics, and chatbot capabilities. Some route/controller wiring and frontend calls are unsampled, so those links are omitted or marked unverified rather than inferred.

Main entry points: [`backend/src/config/db.js`](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/config/db.js) (MongoDB), [`frontend/src/App.jsx`](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/App.jsx) (SPA router and layout), [`frontend/src/services/api.js`](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/services/api.js) (HTTP API client), [`frontend/src/pages/AdminDashboard.jsx`](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/pages/AdminDashboard.jsx) (Dashboard page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public portfolio"]
  node_app["SPA router and layout<br/>[App.jsx]"]
  node_about["Profile and certifications<br/>[About.jsx]"]
  node_projects["Project browsing<br/>[Projects.jsx]"]
  node_chatui["Chat interface<br/>[ChatBot.jsx]"]
  node_visitortracker["Visit tracking<br/>[VisitTracker.jsx]"]
  node_theming["Theme state<br/>[ThemeContext.jsx]"]
end

subgraph group_admin["Admin dashboard"]
  node_adminpage["Dashboard page<br/>[AdminDashboard.jsx]"]
  node_projectspanel["Project management<br/>[ProjectsPanel.jsx]"]
  node_analytics["Analytics panels<br/>[AnalyticsPanel.jsx]"]
end

subgraph group_backend["API and persistence"]
  node_api["HTTP API client<br/>[api.js]"]
  node_server["Express API server<br/>[server.js]"]
  node_authroutes["Authentication routes<br/>[auth.js]"]
  node_authcontroller["Authentication logic<br/>[authController.js]"]
  node_authmiddleware["Token protection<br/>[auth.js]"]
  node_profilecontroller["Profile operations"]
  node_projectcontroller["Project operations"]
  node_messagecontroller["Contact messages"]
  node_visitorcontroller["Visitor analytics"]
  node_mongodb[("MongoDB<br/>[db.js]")]
end

subgraph group_assistant["AI assistant"]
  node_chatcontroller["Chat orchestration"]
  node_worker["AI worker<br/>[index.js]"]
end

node_visitor(("Site visitor"))
node_adminuser(("Administrator"))
node_cloudflare{{"Cloudflare Workers AI"}}

node_visitor -->|"browses"| node_app
node_adminuser -->|"manages content"| node_adminpage
node_app -->|"routes to"| node_about
node_app -->|"routes to"| node_projects
node_app -->|"renders"| node_chatui
node_app -->|"renders"| node_visitortracker
node_adminpage -.->|"manages projects"| node_projectspanel
node_adminpage -.->|"shows analytics"| node_analytics
node_about -->|"fetches profile data"| node_api
node_projects -->|"fetches projects"| node_api
node_chatui -->|"sends chat requests"| node_api
node_theming -->|"loads and updates themes"| node_api
node_api -->|"calls REST API"| node_server
node_server -->|"mounts routes"| node_authroutes
node_server -->|"connects"| node_mongodb
node_authroutes -->|"dispatches login"| node_authcontroller
node_authroutes -->|"protects identity route"| node_authmiddleware
node_authcontroller -->|"reads user"| node_mongodb
node_authmiddleware -->|"loads user"| node_mongodb
node_profilecontroller -->|"reads and writes profile"| node_mongodb
node_projectcontroller -->|"reads and writes projects"| node_mongodb
node_messagecontroller -->|"stores messages"| node_mongodb
node_visitorcontroller -->|"records and aggregates visits"| node_mongodb
node_chatcontroller -->|"loads portfolio context"| node_mongodb
node_chatcontroller -->|"requests inference"| node_cloudflare
node_worker -.->|"runs model inference"| node_cloudflare

click node_app "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/App.jsx"
click node_about "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/pages/About.jsx"
click node_projects "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/pages/Projects.jsx"
click node_chatui "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/sections/ChatBot.jsx"
click node_visitortracker "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/ui/VisitTracker.jsx"
click node_theming "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/contexts/ThemeContext.jsx"
click node_adminpage "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/pages/AdminDashboard.jsx"
click node_projectspanel "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/admin/ProjectsPanel.jsx"
click node_analytics "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/admin/AnalyticsPanel.jsx"
click node_api "https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/server.js"
click node_authroutes "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/routes/auth.js"
click node_authcontroller "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/authController.js"
click node_authmiddleware "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/middleware/auth.js"
click node_profilecontroller "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/profileController.js"
click node_projectcontroller "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/projectController.js"
click node_messagecontroller "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/messageController.js"
click node_visitorcontroller "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/visitorController.js"
click node_chatcontroller "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/chatbotController.js"
click node_worker "https://github.com/omar-khecharem/portfolio/blob/main/chatbot-worker/src/index.js"
click node_mongodb "https://github.com/omar-khecharem/portfolio/blob/main/backend/src/config/db.js"

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_about,node_projects,node_chatui,node_visitortracker,node_theming toneBlue
class node_adminpage,node_projectspanel,node_analytics toneAmber
class node_api,node_server,node_authroutes,node_authcontroller,node_authmiddleware,node_profilecontroller,node_projectcontroller,node_messagecontroller,node_visitorcontroller,node_mongodb toneMint
class node_chatcontroller,node_worker,node_cloudflare toneRose
class node_visitor,node_adminuser toneIndigo
```

## Components

### Public portfolio

- [SPA router and layout](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Profile and certifications](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/pages/About.jsx): `frontend/src/pages/About.jsx`
- [Project browsing](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/pages/Projects.jsx): `frontend/src/pages/Projects.jsx`
- [Chat interface](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/sections/ChatBot.jsx): `frontend/src/components/sections/ChatBot.jsx`
- [Visit tracking](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/ui/VisitTracker.jsx): `frontend/src/components/ui/VisitTracker.jsx`
- [Theme state](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/contexts/ThemeContext.jsx): `frontend/src/contexts/ThemeContext.jsx`

### Admin dashboard

- [Dashboard page](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/pages/AdminDashboard.jsx): `frontend/src/pages/AdminDashboard.jsx`
- [Project management](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/admin/ProjectsPanel.jsx): `frontend/src/components/admin/ProjectsPanel.jsx`
- [Analytics panels](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/components/admin/AnalyticsPanel.jsx): `frontend/src/components/admin/AnalyticsPanel.jsx`

### API and persistence

- [HTTP API client](https://github.com/omar-khecharem/portfolio/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Express API server](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/server.js): `backend/src/server.js`
- [Authentication routes](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Authentication logic](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Token protection](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [Profile operations](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/profileController.js): `backend/src/controllers/profileController.js`
- [Project operations](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/projectController.js): `backend/src/controllers/projectController.js`
- [Contact messages](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/messageController.js): `backend/src/controllers/messageController.js`
- [Visitor analytics](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/visitorController.js): `backend/src/controllers/visitorController.js`
- [MongoDB](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/config/db.js): `backend/src/config/db.js`

### AI assistant

- [Chat orchestration](https://github.com/omar-khecharem/portfolio/blob/main/backend/src/controllers/chatbotController.js): `backend/src/controllers/chatbotController.js`
- [AI worker](https://github.com/omar-khecharem/portfolio/blob/main/chatbot-worker/src/index.js): `chatbot-worker/src/index.js`

### Other components

- **Site visitor**
- **Administrator**
- **Cloudflare Workers AI**

## Connections

- Site visitor → SPA router and layout: browses (evidence: `README.md`)
- Administrator → Dashboard page: manages content (evidence: `README.md`)
- SPA router and layout → Profile and certifications: routes to (evidence: `frontend/src/App.jsx`)
- SPA router and layout → Project browsing: routes to (evidence: `frontend/src/App.jsx`)
- SPA router and layout → Chat interface: renders (evidence: `frontend/src/App.jsx`)
- SPA router and layout → Visit tracking: renders (evidence: `frontend/src/App.jsx`)
- Dashboard page → Project management: manages projects
- Dashboard page → Analytics panels: shows analytics
- Profile and certifications → HTTP API client: fetches profile data (evidence: `frontend/src/pages/About.jsx`)
- Project browsing → HTTP API client: fetches projects (evidence: `frontend/src/pages/Projects.jsx`)
- Chat interface → HTTP API client: sends chat requests (evidence: `frontend/src/components/sections/ChatBot.jsx`)
- Theme state → HTTP API client: loads and updates themes (evidence: `frontend/src/contexts/ThemeContext.jsx`)
- HTTP API client → Express API server: calls REST API (evidence: `README.md`)
- Express API server → Authentication routes: mounts routes (evidence: `backend/src/server.js`)
- Express API server → MongoDB: connects (evidence: `backend/src/server.js`)
- Authentication routes → Authentication logic: dispatches login (evidence: `backend/src/routes/auth.js`)
- Authentication routes → Token protection: protects identity route (evidence: `backend/src/routes/auth.js`)
- Authentication logic → MongoDB: reads user (evidence: `backend/src/controllers/authController.js`)
- Token protection → MongoDB: loads user (evidence: `backend/src/middleware/auth.js`)
- Profile operations → MongoDB: reads and writes profile (evidence: `backend/src/controllers/profileController.js`)
- Project operations → MongoDB: reads and writes projects (evidence: `backend/src/controllers/projectController.js`)
- Contact messages → MongoDB: stores messages (evidence: `backend/src/controllers/messageController.js`)
- Visitor analytics → MongoDB: records and aggregates visits (evidence: `backend/src/controllers/visitorController.js`)
- Chat orchestration → MongoDB: loads portfolio context (evidence: `backend/src/controllers/chatbotController.js`)
- Chat orchestration → Cloudflare Workers AI: requests inference (evidence: `backend/src/controllers/chatbotController.js`)
- AI worker → Cloudflare Workers AI: runs model inference
