# pranav-dwivedi1/my_portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/pranav-dwivedi1/my_portfolio
- Repository: https://github.com/pranav-dwivedi1/my_portfolio

## Overview

#### Purpose and runtime
This is a personal portfolio and content site with a public Next.js frontend and a separate Node/Express backend for blog management, contact capture, newsletter subscriptions, and administrator access. The frontend runs as a Next.js App Router application; the API is launched separately from `backend/src/server.js`. Deployment infrastructure is indicated by `render.yaml`; image hosting is configured through Cloudinary.

#### Frontend application shell and public routes
The root layout and homepage establish the site shell and landing experience:
- `src/app/layout.js`
- `src/app/page.js`
- `src/app/HomeClient.js`

Public route segments cover about, portfolio, services, contact, and blog content. Shared header/footer/sidebar and WhatsApp UI provide cross-page navigation and engagement:
- `src/app/blogs/page.jsx`
- `src/app/blogs/[slug]/page.jsx`
- `src/components/layout/Header.jsx`

#### Blog delivery pipeline
Blog listing and article pages render structured post data through dedicated presentation components, including Markdown, table of contents, related posts, sharing, and cover imagery:
- `src/components/blog/BlogListing.jsx`
- `src/components/blog/BlogArticle.jsx`
- `src/components/blog/Markdown.jsx`

The frontend has local JSON seed/fallback post content and blog access/normalization utilities:
- `src/data/blog/`
- `src/lib/blogData.js`
- `src/lib/blogUtils.js`

The backend owns persisted post APIs and post-oriented controller logic:
- `backend/src/routes/posts.routes.js`
- `backend/src/controllers/posts.controller.js`
- `backend/src/models/Post.js`

#### Administrative publishing boundary
Administrative pages are isolated under `/admin`, with a layout, login route, dashboard, new-post editor, and ID-based edit route:
- `src/app/admin/layout.js`
- `src/app/admin/page.jsx`
- `src/app/admin/edit/[id]/page.jsx`

Client-side admin access and API integration are encapsulated separately from public rendering:
- `src/components/admin/AdminGate.jsx`
- `src/components/admin/PostEditor.jsx`
- `src/lib/adminClient.js`

Requests cross to backend authentication and admin routes, where authentication middleware protects privileged operations:
- `backend/src/routes/auth.routes.js`
- `backend/src/routes/admin.routes.js`
- `backend/src/middleware/auth.js`

#### API service layer and persistence
Express app setup centralizes routing, middleware, and errors:
- `backend/src/app.js`
- `backend/src/middleware/error.js`
- `backend/src/middleware/rateLimit.js`

MongoDB-style model boundaries represent posts, inbound contacts, and newsletter subscribers, with connection setup isolated in backend configuration:
- `backend/src/config/db.js`
- `backend/src/models/Contact.js`
- `backend/src/models/Subscriber.js`

Contact and newsletter form flows terminate in dedicated route/controller pairs:
- `backend/src/routes/contact.routes.js`
- `backend/src/controllers/contact.controller.js`
- `backend/src/routes/newsletter.routes.js`

#### External integrations and content bootstrap
Cloudinary is the media-storage integration, likely used by post publishing/upload operations:
- `backend/src/config/cloudinary.js`
- `backend/src/controllers/admin.controller.js`

Backend seed scripts initialize post records from JSON; matching frontend seed data supports local/static content availability:
- `backend/src/seed/run.js`
- `backend/src/seed/index.js`
- `src/data/seedPosts.js`

SEO endpoints are generated through Next App Router conventions:
- `src/app/robots.js`
- `src/app/sitemap.js`

Main entry points: [`src/app/layout.js`](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/layout.js) (Next app shell), [`src/lib/blogData.js`](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/lib/blogData.js) (Blog data access), [`backend/src/app.js`](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/app.js) (Express app), [`backend/src/routes/admin.routes.js`](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/routes/admin.routes.js) (Auth and admin API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Public Frontend"]
  node_next_shell["Next app shell<br/>Next.js App Router<br/>[layout.js]"]
  node_home["Landing page<br/>public route<br/>[page.js]"]
  node_public_blog_routes["Blog routes<br/>public routes<br/>[page.jsx]"]
  node_site_navigation["Shared navigation<br/>layout component<br/>[Header.jsx]"]
  node_blog_presentation["Blog presentation<br/>content components<br/>[BlogArticle.jsx]"]
  node_blog_access["Blog data access<br/>frontend library<br/>[blogData.js]"]
  node_local_posts["Local post fallback<br/>JSON content"]
  node_seo["SEO endpoints<br/>Next metadata routes<br/>[robots.js]"]
  node_frontend_seed["Frontend seed posts<br/>seed content<br/>[seedPosts.js]"]
end

subgraph group_admin["Admin Publishing"]
  node_admin_routes["Admin routes<br/>protected routes<br/>[layout.js]"]
  node_admin_gate["Admin access gate<br/>client auth<br/>[AdminGate.jsx]"]
  node_post_editor["Post editor<br/>publishing UI<br/>[PostEditor.jsx]"]
  node_admin_client["Admin API client<br/>frontend library<br/>[adminClient.js]"]
end

subgraph group_backend["Express API"]
  node_api_server["API server<br/>Express entrypoint<br/>[server.js]"]
  node_express_app["Express app<br/>routing and middleware<br/>[app.js]"]
  node_post_api["Post API<br/>routes and controller<br/>[posts.routes.js]"]
  node_admin_api["Auth and admin API<br/>protected routes<br/>[admin.routes.js]"]
  node_form_api["Contact and newsletter API<br/>form endpoints<br/>[contact.routes.js]"]
end

subgraph group_data["Data &amp; Integrations"]
  node_database[("MongoDB persistence<br/>database<br/>[db.js]")]
  node_post_model["Post model<br/>data model<br/>[Post.js]"]
  node_contact_models["Contact and subscriber models<br/>data models<br/>[Contact.js]"]
  node_cloudinary{{"Cloudinary media<br/>external media storage<br/>[cloudinary.js]"}}
  node_seed_bootstrap["Content bootstrap<br/>seed scripts<br/>[run.js]"]
end

node_next_shell -->|"renders"| node_home
node_next_shell -->|"hosts"| node_public_blog_routes
node_next_shell -->|"uses"| node_site_navigation
node_next_shell -->|"publishes"| node_seo
node_public_blog_routes -->|"renders"| node_blog_presentation
node_blog_presentation -->|"loads posts"| node_blog_access
node_blog_access -.->|"falls back to"| node_local_posts
node_blog_access -.->|"uses seed content"| node_frontend_seed
node_blog_access -->|"fetches persisted posts"| node_post_api
node_admin_routes -->|"enforces access"| node_admin_gate
node_admin_routes -->|"hosts editor"| node_post_editor
node_post_editor -->|"publishes through"| node_admin_client
node_admin_client -->|"auth and post requests"| node_admin_api
node_api_server -->|"starts"| node_express_app
node_express_app -->|"mounts"| node_post_api
node_express_app -->|"mounts"| node_admin_api
node_express_app -->|"mounts"| node_form_api
node_post_api -->|"reads and writes"| node_post_model
node_admin_api -->|"manages posts"| node_post_model
node_admin_api -->|"uploads media"| node_cloudinary
node_form_api -->|"persists submissions"| node_contact_models
node_post_model -->|"persists to"| node_database
node_contact_models -->|"persist to"| node_database
node_seed_bootstrap -->|"initializes"| node_post_model

click node_next_shell "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/layout.js"
click node_home "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/page.js"
click node_public_blog_routes "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/blogs/page.jsx"
click node_site_navigation "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/layout/Header.jsx"
click node_blog_presentation "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/blog/BlogArticle.jsx"
click node_blog_access "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/lib/blogData.js"
click node_local_posts "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/data/blog/post-chatgpt-business-2026.json"
click node_seo "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/robots.js"
click node_admin_routes "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/admin/layout.js"
click node_admin_gate "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/admin/AdminGate.jsx"
click node_post_editor "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/admin/PostEditor.jsx"
click node_admin_client "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/lib/adminClient.js"
click node_api_server "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/server.js"
click node_express_app "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/app.js"
click node_post_api "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/routes/posts.routes.js"
click node_admin_api "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/routes/admin.routes.js"
click node_form_api "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/routes/contact.routes.js"
click node_database "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/config/db.js"
click node_post_model "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/models/Post.js"
click node_contact_models "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/models/Contact.js"
click node_cloudinary "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/config/cloudinary.js"
click node_seed_bootstrap "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/seed/run.js"
click node_frontend_seed "https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/data/seedPosts.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_next_shell,node_home,node_public_blog_routes,node_site_navigation,node_blog_presentation,node_blog_access,node_local_posts,node_seo,node_frontend_seed toneBlue
class node_admin_routes,node_admin_gate,node_post_editor,node_admin_client toneAmber
class node_api_server,node_express_app,node_post_api,node_admin_api,node_form_api toneMint
class node_database,node_post_model,node_contact_models,node_cloudinary,node_seed_bootstrap toneRose
```

## Components

### Public Frontend

Next.js App Router site and blog rendering.

- [Next app shell](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/layout.js): Next.js App Router · `src/app/layout.js`
- [Landing page](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/page.js): public route · `src/app/page.js`
- [Blog routes](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/blogs/page.jsx): public routes · Listing and slug article pages. · `src/app/blogs/page.jsx`
- [Shared navigation](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/layout/Header.jsx): layout component · `src/components/layout/Header.jsx`
- [Blog presentation](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/blog/BlogArticle.jsx): content components · Listing, article, Markdown, sharing, and related-content UI. · `src/components/blog/BlogArticle.jsx`
- [Blog data access](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/lib/blogData.js): frontend library · Normalizes API and fallback post content. · `src/lib/blogData.js`
- [Local post fallback](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/data/blog/post-chatgpt-business-2026.json): JSON content · `src/data/blog/post-chatgpt-business-2026.json`
- [SEO endpoints](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/robots.js): Next metadata routes · Robots and sitemap generation. · `src/app/robots.js`
- [Frontend seed posts](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/data/seedPosts.js): seed content · `src/data/seedPosts.js`

### Admin Publishing

Privileged publishing UI and API boundary.

- [Admin routes](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/app/admin/layout.js): protected routes · Login, dashboard, new-post, and ID-based editing. · `src/app/admin/layout.js`
- [Admin access gate](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/admin/AdminGate.jsx): client auth · `src/components/admin/AdminGate.jsx`
- [Post editor](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/components/admin/PostEditor.jsx): publishing UI · `src/components/admin/PostEditor.jsx`
- [Admin API client](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/src/lib/adminClient.js): frontend library · `src/lib/adminClient.js`

### Express API

Separately launched service for data and forms.

- [API server](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/server.js): Express entrypoint · `backend/src/server.js`
- [Express app](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/app.js): routing and middleware · Centralizes routes, errors, and rate limiting. · `backend/src/app.js`
- [Post API](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/routes/posts.routes.js): routes and controller · Serves persisted blog posts. · `backend/src/routes/posts.routes.js`
- [Auth and admin API](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/routes/admin.routes.js): protected routes · Authentication middleware guards publishing operations. · `backend/src/routes/admin.routes.js`
- [Contact and newsletter API](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/routes/contact.routes.js): form endpoints · Captures inbound contacts and subscriptions. · `backend/src/routes/contact.routes.js`

### Data & Integrations

- [MongoDB persistence](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/config/db.js): database · Stores posts, contacts, and subscribers. · `backend/src/config/db.js`
- [Post model](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/models/Post.js): data model · `backend/src/models/Post.js`
- [Contact and subscriber models](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/models/Contact.js): data models · `backend/src/models/Contact.js`
- [Cloudinary media](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/config/cloudinary.js): external media storage · Used by publishing and image upload operations. · `backend/src/config/cloudinary.js`
- [Content bootstrap](https://github.com/pranav-dwivedi1/my_portfolio/blob/main/backend/src/seed/run.js): seed scripts · Initializes persisted posts from JSON. · `backend/src/seed/run.js`

## Connections

- Next app shell → Landing page: renders
- Next app shell → Blog routes: hosts
- Next app shell → Shared navigation: uses
- Next app shell → SEO endpoints: publishes
- Blog routes → Blog presentation: renders
- Blog presentation → Blog data access: loads posts
- Blog data access → Local post fallback: falls back to
- Blog data access → Frontend seed posts: uses seed content
- Blog data access → Post API: fetches persisted posts
- Admin routes → Admin access gate: enforces access
- Admin routes → Post editor: hosts editor
- Post editor → Admin API client: publishes through
- Admin API client → Auth and admin API: auth and post requests
- API server → Express app: starts
- Express app → Post API: mounts
- Express app → Auth and admin API: mounts
- Express app → Contact and newsletter API: mounts
- Post API → Post model: reads and writes
- Auth and admin API → Post model: manages posts
- Auth and admin API → Cloudinary media: uploads media
- Contact and newsletter API → Contact and subscriber models: persists submissions
- Post model → MongoDB persistence: persists to
- Contact and subscriber models → MongoDB persistence: persist to
- Content bootstrap → Post model: initializes
