# ov111/devs_website architecture

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

- Interactive diagram: https://gitdiagram.com/ov111/devs_website
- Repository: https://github.com/ov111/devs_website

## Overview

1. **High-level split**
   - This repo is a **full-stack developer blog platform** with a clear client/server boundary: a **React 19 + Vite SPA** in `src/` and an **Express 5 API** in `backend/`.
   - The frontend handles routing, presentation, and client state; the backend owns authentication, persistence, chat, and async notification processing.

2. **Frontend application shell**
   - `src/main.jsx`, `src/App.jsx`, `src/router.jsx`, and `src/layouts/MainLayout.jsx` form the app shell.
   - Route protection is explicit via `src/routes/ProtectedRoutes.jsx` and `src/routes/ProtectedMyProfile.jsx`, indicating authenticated areas such as profile, notifications, favorites, and chat.

3. **Frontend feature domains**
   - The UI is organized by product area rather than technical layer:
     - `src/pages/` for route-level pages like Home, About, Contact, category pages, and user/profile pages.
     - `src/features/` for larger feature modules such as **Roadmap**, **CodingLibs**, **CodingChallenges**, and **profile actions**.
     - `src/components/` for reusable widgets, layout, search, blog cards, feedback/loading states, and visual effects.
   - This suggests the frontend is a composition of several mostly independent experience modules under one SPA.

4. **Client state and API access**
   - Global state is managed with **Zustand** stores in `src/stores/`:
     - auth/session state
     - notifications
     - profile data
     - roadmap state
     - theme preference
   - Server communication is isolated in small service modules like `src/services/SearchApi.js` and `src/services/notificationsApi.js`, which keeps API access separate from UI components.

5. **Backend API layer**
   - `backend/server.js` is the entry point for the Express app.
   - Route modules in `backend/routes/` split the API by domain:
     - `auth` behavior via `backend/controllers/authController.js`
     - post/default-post handling
     - notifications
   - This is a conventional REST/API boundary: the frontend calls these routes, and controllers/services handle the domain logic.

6. **Authentication and user relationships**
   - Authentication is JWT-based, with token helpers in `backend/utils/jwtToken.js`.
   - User relationship logic is separated into `backend/services/followService.js`, indicating follow/follower operations are a first-class domain concern.
   - The protected-route structure on the frontend mirrors this backend auth boundary.

7. **Notifications as an asynchronous subsystem**
   - Notifications are not handled purely inline; they use **BullMQ + Redis**:
     - queue config in `backend/config/queues.js` and `backend/config/redis.js`
     - queue definition in `backend/queues/notificationQueue.js`
     - worker in `backend/workers/notificationWorker.js`
     - orchestration logic in `backend/services/notificationService.js`
   - Architecture-wise, user actions can enqueue notification jobs, which are processed separately from the request/response path.

8. **Real-time chat subsystem**
   - Live chat is handled through **WebSockets** in `backend/websocket/`.
   - `backend/websocket/index.js` likely wires the socket server, while `backend/websocket/chatHandler.js` encapsulates message/event handling.
   - This is a distinct real-time channel alongside the REST API, used by the profile/chat pages in `src/pages/My-Profile/chat/`.

9. **Persistence and infrastructure**
   - `backend/config/db.js` shows a MongoDB/Mongoose-backed data layer.
   - Redis is used as the supporting infrastructure for background work and queuing rather than as the primary app database.
   - Seed data in `backend/seeders/posts-default.js` suggests the app can bootstrap default blog content/categories for a fresh environment.

10. **Primary data flows**
   - Typical flow: browser action → React page/component → Zustand/service call → Express route/controller/service → MongoDB.
   - For notifications: browser action → backend service → Redis/BullMQ queue → worker → persisted/emitted notification.
   - For chat: browser socket client → WebSocket handler → message distribution to connected clients.

11. **Feature set mapping to architecture**
   - Content browsing is centered around **developer categories** (`constants/Categories.js`, category pages, roadmap constants).
   - User engagement features span **favorites, notifications, follows, profile editing, and chat**, which is why the backend is split into auth, follow, notification, and websocket subsystems rather than a single monolith.

12. **Testing and quality boundaries**
   - The repo has strong separation in tests: unit, integration, API contract, concurrency, queue, security, websocket, performance, and Playwright-style end-to-end specs in `tests/`.
   - That test layout reflects the architecture: REST API, async queue, WebSocket chat, and frontend route behavior are all treated as distinct boundaries.

13. **Deployment/runtime shape**
   - The presence of `Dockerfile`, `railway.json`, `vercel.json`, and `nixpacks.toml` indicates the repo is designed for split deployment or platform-specific hosting.
   - In practice, the frontend is Vite-built static output, while the backend runs as a Node/Express service with MongoDB, Redis, and websocket support.

Main entry points: [`src/main.jsx`](https://github.com/ov111/devs_website/blob/master/src/main.jsx) (App shell), [`backend/routes/postHandling.js`](https://github.com/ov111/devs_website/blob/master/backend/routes/postHandling.js) (API routes), [`backend/controllers/authController.js`](https://github.com/ov111/devs_website/blob/master/backend/controllers/authController.js) (Auth flow), [`backend/config/db.js`](https://github.com/ov111/devs_website/blob/master/backend/config/db.js) (Data layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_spa_shell["App shell<br/>react entry/router<br/>[main.jsx]"]
  node_route_guards["Route guards<br/>protected routes"]
  node_pages["Pages<br/>route views<br/>[Home.jsx]"]
  node_features["Features<br/>feature modules<br/>[RoadmapPage.jsx]"]
  node_shared_ui["Shared UI<br/>components<br/>[Navbar.jsx]"]
  node_client_state["State stores<br/>zustand state<br/>[useAuthStore.js]"]
  node_client_services["API clients<br/>service adapters<br/>[SearchApi.js]"]
end

subgraph group_backend["Backend API"]
  node_backend_entry["Server<br/>express app<br/>[server.js]"]
  node_api_routes["API routes<br/>rest routes<br/>[postHandling.js]"]
  node_auth_logic["Auth flow<br/>controller+jwt<br/>[authController.js]"]
  node_content_flow["Content flow<br/>post handling<br/>[handleDefPosts.js]"]
  node_follow_logic["Follow service<br/>social graph<br/>[followService.js]"]
  node_notification_core["Notifications<br/>async subsystem"]
  node_realtime_chat["Chat<br/>websocket subsystem<br/>[index.js]"]
  node_persistence["Data layer<br/>mongo+redis<br/>[db.js]"]
end

subgraph group_quality["Quality"]
  node_test_suite["Tests<br/>multi-suite<br/>[navigation.spec.js]"]
end

node_spa_shell -->|"protects"| node_route_guards
node_spa_shell -->|"renders"| node_pages
node_spa_shell -->|"mounts"| node_features
node_spa_shell -->|"uses"| node_shared_ui
node_spa_shell -->|"reads/writes"| node_client_state
node_spa_shell -->|"calls"| node_client_services
node_backend_entry -->|"mounts"| node_api_routes
node_backend_entry -->|"starts"| node_realtime_chat
node_api_routes -->|"delegates"| node_auth_logic
node_api_routes -->|"delegates"| node_content_flow
node_api_routes -->|"delegates"| node_notification_core
node_auth_logic -->|"uses"| node_persistence
node_auth_logic -->|"coordinates"| node_follow_logic
node_content_flow -->|"stores"| node_persistence
node_notification_core -->|"enqueues/persists"| node_persistence
node_notification_core -->|"serves"| node_client_services
node_realtime_chat -->|"uses"| node_persistence
node_route_guards -->|"depends on"| node_auth_logic
node_features -->|"uses"| node_client_state
node_pages -->|"composes"| node_features
node_test_suite -->|"verifies"| node_backend_entry
node_test_suite -->|"verifies"| node_spa_shell

click node_spa_shell "https://github.com/ov111/devs_website/blob/master/src/main.jsx"
click node_route_guards "https://github.com/ov111/devs_website/blob/master/src/routes/ProtectedRoutes.jsx"
click node_pages "https://github.com/ov111/devs_website/blob/master/src/pages/Home.jsx"
click node_features "https://github.com/ov111/devs_website/blob/master/src/features/Roadmap/RoadmapPage.jsx"
click node_shared_ui "https://github.com/ov111/devs_website/blob/master/src/components/layout/Navbar.jsx"
click node_client_state "https://github.com/ov111/devs_website/blob/master/src/stores/useAuthStore.js"
click node_client_services "https://github.com/ov111/devs_website/blob/master/src/services/SearchApi.js"
click node_backend_entry "https://github.com/ov111/devs_website/blob/master/backend/server.js"
click node_api_routes "https://github.com/ov111/devs_website/blob/master/backend/routes/postHandling.js"
click node_auth_logic "https://github.com/ov111/devs_website/blob/master/backend/controllers/authController.js"
click node_content_flow "https://github.com/ov111/devs_website/blob/master/backend/routes/handleDefPosts.js"
click node_follow_logic "https://github.com/ov111/devs_website/blob/master/backend/services/followService.js"
click node_notification_core "https://github.com/ov111/devs_website/blob/master/backend/services/notificationService.js"
click node_realtime_chat "https://github.com/ov111/devs_website/blob/master/backend/websocket/index.js"
click node_persistence "https://github.com/ov111/devs_website/blob/master/backend/config/db.js"
click node_test_suite "https://github.com/ov111/devs_website/blob/master/tests/navigation.spec.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_spa_shell,node_route_guards,node_pages,node_features,node_shared_ui,node_client_state,node_client_services toneBlue
class node_backend_entry,node_api_routes,node_auth_logic,node_content_flow,node_follow_logic,node_notification_core,node_realtime_chat,node_persistence toneAmber
class node_test_suite toneMint
```

## Components

### Frontend SPA

React/Vite client application and its feature modules

- [App shell](https://github.com/ov111/devs_website/blob/master/src/main.jsx): react entry/router · Main client bootstrap, router, and layout composition · `src/main.jsx`
- [Route guards](https://github.com/ov111/devs_website/blob/master/src/routes/ProtectedRoutes.jsx): protected routes · Authenticated route wrappers for profile and private areas · `src/routes/ProtectedRoutes.jsx`
- [Pages](https://github.com/ov111/devs_website/blob/master/src/pages/Home.jsx): route views · Route-level screens for browsing, profiles, and account flows · `src/pages/Home.jsx`
- [Features](https://github.com/ov111/devs_website/blob/master/src/features/Roadmap/RoadmapPage.jsx): feature modules · Major product modules like roadmap, coding libs, challenges, and profile actions · `src/features/Roadmap/RoadmapPage.jsx`
- [Shared UI](https://github.com/ov111/devs_website/blob/master/src/components/layout/Navbar.jsx): components · Reusable cards, layout, search, feedback, and visual effects · `src/components/layout/Navbar.jsx`
- [State stores](https://github.com/ov111/devs_website/blob/master/src/stores/useAuthStore.js): zustand state · Global client state for auth, profile, notifications, roadmap, and theme · `src/stores/useAuthStore.js`
- [API clients](https://github.com/ov111/devs_website/blob/master/src/services/SearchApi.js): service adapters · Small client-side wrappers for search and notifications APIs · `src/services/SearchApi.js`

### Backend API

Express server, domain services, and infrastructure

- [Server](https://github.com/ov111/devs_website/blob/master/backend/server.js): express app · Backend runtime entrypoint and middleware wiring · `backend/server.js`
- [API routes](https://github.com/ov111/devs_website/blob/master/backend/routes/postHandling.js): rest routes · Domain route modules for auth, posts, and notifications · `backend/routes/postHandling.js`
- [Auth flow](https://github.com/ov111/devs_website/blob/master/backend/controllers/authController.js): controller+jwt · Authentication controller and JWT token helpers · `backend/controllers/authController.js`
- [Content flow](https://github.com/ov111/devs_website/blob/master/backend/routes/handleDefPosts.js): post handling · Default post handling and seeded blog content · `backend/routes/handleDefPosts.js`
- [Follow service](https://github.com/ov111/devs_website/blob/master/backend/services/followService.js): social graph · Follower/following domain logic used by profile relationships · `backend/services/followService.js`
- [Notifications](https://github.com/ov111/devs_website/blob/master/backend/services/notificationService.js): async subsystem · Notification orchestration, queueing, and background processing · `backend/services/notificationService.js`
- [Chat](https://github.com/ov111/devs_website/blob/master/backend/websocket/index.js): websocket subsystem · WebSocket connection setup and chat event handling · `backend/websocket/index.js`
- [Data layer](https://github.com/ov111/devs_website/blob/master/backend/config/db.js): mongo+redis · MongoDB connection plus Redis queue infrastructure · `backend/config/db.js`

### Quality

Automated tests and validation boundaries

- [Tests](https://github.com/ov111/devs_website/blob/master/tests/navigation.spec.js): multi-suite · API, integration, queue, websocket, security, performance, and UI specs · `tests/navigation.spec.js`

## Connections

- App shell → Route guards: protects · App shell composes guarded and public routes
- App shell → Pages: renders · Routes resolve to page-level screens
- App shell → Features: mounts · Pages assemble larger product features
- App shell → Shared UI: uses · Common UI is shared across the SPA
- App shell → State stores: reads/writes · Client state coordinates auth, profile, and UI preferences
- App shell → API clients: calls · Client service modules handle backend requests
- Server → API routes: mounts · Express server registers domain route modules
- Server → Chat: starts · Server also hosts the WebSocket channel
- API routes → Auth flow: delegates · Auth routes and controllers handle login/session concerns
- API routes → Content flow: delegates · Post and default-content routes manage blog data
- API routes → Notifications: delegates · Notification endpoints feed the async subsystem
- Auth flow → Data layer: uses · Auth reads and writes persistent user data
- Auth flow → Follow service: coordinates · User relationship actions are part of account flows
- Content flow → Data layer: stores · Blog content is backed by MongoDB
- Notifications → Data layer: enqueues/persists · Notifications use Redis queues and stored records
- Notifications → API clients: serves · Frontend notification UI consumes notification APIs
- Chat → Data layer: uses · Chat infrastructure runs alongside the backend data layer
- Route guards → Auth flow: depends on · Protected client routes mirror backend auth boundaries
- Features → State stores: uses · Feature modules consume shared stores
- Pages → Features: composes · Route pages embed feature modules where needed
- Tests → Server: verifies · Tests cover API, integration, queue, and websocket behavior
- Tests → App shell: verifies · End-to-end specs exercise navigation and protected routes
