# usjav/devlink architecture

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

- Interactive diagram: https://gitdiagram.com/usjav/devlink
- Repository: https://github.com/usjav/devlink

## Overview

1. **System shape**
   - DevLink is a two-tier application: a **React/Vite client** in `client/` and an **Express/MongoDB API server** in `server/`.
   - The frontend is the interactive product surface; the backend owns persistence, authentication, and all domain operations.

2. **Frontend application shell**
   - `client/src/main.jsx` and `client/src/App.jsx` boot the React app.
   - `client/src/routes.js` defines the page-level navigation, so the UI is organized as a route-driven single-page app rather than server-rendered pages.

3. **Role-based UI split**
   - The client is explicitly divided into two user experiences:
     - **Developer-facing** pages/components for search, recommendations, applications, and profile management.
     - **Company-facing** pages/components for job posting, applicant review, and company settings.
   - This is reflected in `client/src/pages/dev/*` and `client/src/pages/company/*`, plus role-specific navbars and cards.

4. **Shared frontend building blocks**
   - Reusable UI lives in `client/src/components/`, including job cards, navbars, footer, settings forms, and application review cards.
   - `AuthContext.jsx` and `useAuthContext.jsx` centralize auth state for the client, so login/session information is shared across route views.
   - `globalConstants.js`, `svgIcons.jsx`, and `joy_imports.jsx` suggest shared styling/icon/config helpers for the design system.

5. **Frontend feature surfaces**
   - Developer flows: job search, job details, apply, recommendations, dashboard, profile setup, settings, password change, delete account.
   - Company flows: company dashboard, post a job, job detail/applicant management, profile setup, settings.
   - The structure implies the UI is organized around these workflows more than around generic CRUD screens.

6. **Client-side data access pattern**
   - The frontend likely uses **Axios** to call the backend REST API.
   - Pages and components consume server data, then render role-specific cards and forms; state is kept in React and auth context rather than in a separate global store.

7. **Backend API boundary**
   - `server/index.js` is the Express entry point.
   - Routing is split by concern in `server/routes/`: `authRoute`, `jobRoute`, `companyRoute`, `devRoute`, `aiRoute`, and `testRoute`.
   - This means API responsibilities are partitioned by domain rather than by frontend page.

8. **Backend domain logic**
   - Controllers in `server/controllers/` hold the business logic:
     - `userController` for auth/user account operations
     - `devController` for developer profile/application actions
     - `companyController` for company profile and hiring actions
     - `jobController` for job post/search/application workflows
     - `aiController` for recommendation or AI-assisted features
   - The routes map to these controllers, keeping HTTP handling separate from domain logic.

9. **Persistence model**
   - MongoDB is accessed through Mongoose models in `server/models/`.
   - The domain is split into `user`, `dev`, `company`, and `jobpost` collections/models, which matches the role-based product design.
   - This implies a separation between account identity and role-specific profile data.

10. **Authentication and authorization**
   - The README and file structure indicate **JWT-based auth**.
   - Auth likely starts in the auth route/controller, then client auth state is stored in context and used to gate developer/company views and API calls.
   - Role separation is a key architectural boundary: a user is not just “logged in,” but logged in as a developer or company actor.

11. **Key data flow**
   - Typical flow: user action in a page/component → Axios request → Express route → controller → Mongoose model → MongoDB → JSON response → React state update/render.
   - For hiring flows, the same path is used for posting jobs, applying, reviewing applicants, and changing application status.

12. **AI/recommendation subsystem**
   - `aiRoute` and `aiController` are a distinct subsystem, likely supporting job recommendations or other AI-assisted matching features called out in the README.
   - Architecturally, it sits behind the same API layer as the rest of the backend, but it is separate from core CRUD/domain routes.

13. **Deployment/runtime boundaries**
   - The client is a Vite app and includes `vercel.json`, which suggests frontend deployment is decoupled from the backend.
   - The server is a standalone Node/Express process configured via environment variables, with MongoDB as an external dependency.

14. **What to draw in an architecture diagram**
   - Show two primary blocks: **browser/client SPA** and **API server**.
   - Inside the client, separate **developer UX** and **company UX**, both sharing auth context and common components.
   - Inside the server, separate **routes → controllers → Mongoose models → MongoDB**, with a distinct AI path and JWT auth cross-cutting the API.

Main entry points: [`client/src/App.jsx`](https://github.com/usjav/devlink/blob/main/client/src/App.jsx) (App shell), [`client/src/routes.js`](https://github.com/usjav/devlink/blob/main/client/src/routes.js) (Routes), [`server/controllers`](https://github.com/usjav/devlink/tree/main/server/controllers) (Controllers), [`server/routes/authRoute.js`](https://github.com/usjav/devlink/blob/main/server/routes/authRoute.js) (Auth route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client SPA"]
  node_client_main["App boot<br/>react entry<br/>[main.jsx]"]
  node_client_app["App shell<br/>react shell<br/>[App.jsx]"]
  node_client_routes["Routes<br/>spa router<br/>[routes.js]"]
  node_client_auth["Auth context<br/>client state<br/>[AuthContext.jsx]"]
  node_client_components["Shared UI<br/>ui kit"]
  node_client_dev["Developer UX<br/>role UI"]
  node_client_company["Company UX<br/>role UI"]
  node_client_pages["Public pages<br/>auth pages<br/>[Login.jsx]"]
  node_client_constants["UI helpers<br/>shared config<br/>[globalConstants.js]"]
end

subgraph group_server["API Server"]
  node_server_index["Server entry<br/>express entry<br/>[index.js]"]
  node_server_routes["API routes<br/>route layer"]
  node_server_auth_route["Auth route<br/>auth endpoint<br/>[authRoute.js]"]
  node_server_domain_routes["Domain routes<br/>feature endpoints<br/>[jobRoute.js]"]
  node_server_controllers["Controllers<br/>business logic"]
  node_server_ai["AI subsystem<br/>ai feature<br/>[aiController.js]"]
end

subgraph group_data["Persistence"]
  node_server_models["Models"]
  node_server_user_model[("User<br/>account model<br/>[user.js]")]
  node_server_role_models[("Role profiles<br/>profile models<br/>[dev.js]")]
  node_server_job_model[("Job posts<br/>job model<br/>[jobpost.js]")]
  node_mongodb[("MongoDB<br/>database")]
end

node_browser(("Browser<br/>user entry"))

node_browser -->|"opens"| node_client_main
node_client_main -->|"boots"| node_client_app
node_client_app -->|"navigates"| node_client_routes
node_client_routes -->|"includes"| node_client_pages
node_client_routes -->|"includes"| node_client_dev
node_client_routes -->|"includes"| node_client_company
node_client_app -->|"shares state"| node_client_auth
node_client_app -->|"uses"| node_client_components
node_client_app -->|"imports"| node_client_constants
node_client_dev -->|"reads session"| node_client_auth
node_client_company -->|"reads session"| node_client_auth
node_client_dev -->|"calls api"| node_server_auth_route
node_client_company -->|"calls api"| node_server_auth_route
node_server_index -->|"mounts"| node_server_routes
node_server_routes -->|"exposes"| node_server_auth_route
node_server_routes -->|"exposes"| node_server_domain_routes
node_server_auth_route -->|"delegates"| node_server_controllers
node_server_domain_routes -->|"delegates"| node_server_controllers
node_server_controllers -->|"queries"| node_server_models
node_server_models -->|"persists"| node_mongodb
node_server_controllers -->|"includes"| node_server_ai
node_server_ai -->|"uses data"| node_server_models

click node_client_main "https://github.com/usjav/devlink/blob/main/client/src/main.jsx"
click node_client_app "https://github.com/usjav/devlink/blob/main/client/src/App.jsx"
click node_client_routes "https://github.com/usjav/devlink/blob/main/client/src/routes.js"
click node_client_auth "https://github.com/usjav/devlink/blob/main/client/src/components/AuthContext.jsx"
click node_client_components "https://github.com/usjav/devlink/tree/main/client/src/components"
click node_client_dev "https://github.com/usjav/devlink/tree/main/client/src/pages/dev"
click node_client_company "https://github.com/usjav/devlink/tree/main/client/src/pages/company"
click node_client_pages "https://github.com/usjav/devlink/blob/main/client/src/pages/Login.jsx"
click node_client_constants "https://github.com/usjav/devlink/blob/main/client/src/globalConstants.js"
click node_server_index "https://github.com/usjav/devlink/blob/main/server/index.js"
click node_server_routes "https://github.com/usjav/devlink/tree/main/server/routes"
click node_server_auth_route "https://github.com/usjav/devlink/blob/main/server/routes/authRoute.js"
click node_server_domain_routes "https://github.com/usjav/devlink/blob/main/server/routes/jobRoute.js"
click node_server_controllers "https://github.com/usjav/devlink/tree/main/server/controllers"
click node_server_models "https://github.com/usjav/devlink/tree/main/server/models"
click node_server_ai "https://github.com/usjav/devlink/blob/main/server/controllers/aiController.js"
click node_server_user_model "https://github.com/usjav/devlink/blob/main/server/models/user.js"
click node_server_role_models "https://github.com/usjav/devlink/blob/main/server/models/dev.js"
click node_server_job_model "https://github.com/usjav/devlink/blob/main/server/models/jobpost.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_client_main,node_client_app,node_client_routes,node_client_auth,node_client_components,node_client_dev,node_client_company,node_client_pages,node_client_constants toneBlue
class node_server_index,node_server_routes,node_server_auth_route,node_server_domain_routes,node_server_controllers,node_server_ai toneAmber
class node_server_models,node_server_user_model,node_server_role_models,node_server_job_model,node_mongodb toneMint
class node_browser toneNeutral
```

## Components

### Client SPA

React/Vite browser application with role-based experiences.

- [App boot](https://github.com/usjav/devlink/blob/main/client/src/main.jsx): react entry · Bootstraps the React application. · `client/src/main.jsx`
- [App shell](https://github.com/usjav/devlink/blob/main/client/src/App.jsx): react shell · Top-level client container and layout. · `client/src/App.jsx`
- [Routes](https://github.com/usjav/devlink/blob/main/client/src/routes.js): spa router · Defines page-level navigation for the single-page app. · `client/src/routes.js`
- [Auth context](https://github.com/usjav/devlink/blob/main/client/src/components/AuthContext.jsx): client state · Shared login/session state for the frontend. · `client/src/components/AuthContext.jsx`
- [Shared UI](https://github.com/usjav/devlink/tree/main/client/src/components): ui kit · Reusable cards, navbars, settings forms, and helpers. · `client/src/components`
- [Developer UX](https://github.com/usjav/devlink/tree/main/client/src/pages/dev): role UI · Developer-facing search, recommendations, applications, and profile flows. · `client/src/pages/dev`
- [Company UX](https://github.com/usjav/devlink/tree/main/client/src/pages/company): role UI · Company-facing job posting, review, and settings flows. · `client/src/pages/company`
- [Public pages](https://github.com/usjav/devlink/blob/main/client/src/pages/Login.jsx): auth pages · Login and signup entry screens. · `client/src/pages/Login.jsx`
- [UI helpers](https://github.com/usjav/devlink/blob/main/client/src/globalConstants.js): shared config · Constants, icons, and design-system imports used across the client. · `client/src/globalConstants.js`

### API Server

Express application with domain routes, controllers, and persistence.

- [Server entry](https://github.com/usjav/devlink/blob/main/server/index.js): express entry · Starts the Node/Express API server. · `server/index.js`
- [API routes](https://github.com/usjav/devlink/tree/main/server/routes): route layer · Domain-partitioned HTTP endpoints. · `server/routes`
- [Auth route](https://github.com/usjav/devlink/blob/main/server/routes/authRoute.js): auth endpoint · Login and account authentication endpoints. · `server/routes/authRoute.js`
- [Domain routes](https://github.com/usjav/devlink/blob/main/server/routes/jobRoute.js): feature endpoints · Job, company, developer, and AI endpoints. · `server/routes/jobRoute.js`
- [Controllers](https://github.com/usjav/devlink/tree/main/server/controllers): business logic · Holds domain operations behind the HTTP layer. · `server/controllers`
- [AI subsystem](https://github.com/usjav/devlink/blob/main/server/controllers/aiController.js): ai feature · Recommendation and AI-assisted matching workflow. · `server/controllers/aiController.js`

### Persistence

MongoDB-backed domain models.

- [Models](https://github.com/usjav/devlink/tree/main/server/models): mongoose models · MongoDB data models for users, roles, and job posts. · `server/models`
- [User](https://github.com/usjav/devlink/blob/main/server/models/user.js): account model · Core identity and account record. · `server/models/user.js`
- [Role profiles](https://github.com/usjav/devlink/blob/main/server/models/dev.js): profile models · Developer and company profile data. · `server/models/dev.js`
- [Job posts](https://github.com/usjav/devlink/blob/main/server/models/jobpost.js): job model · Job posting and application data. · `server/models/jobpost.js`
- **MongoDB**: database · External persistence backing the application.

### Other components

- **Browser**: user entry · End-user access point for the SPA.

## Connections

- Browser → App boot: opens · User loads the SPA in the browser.
- App boot → App shell: boots · React mounts the root application shell.
- App shell → Routes: navigates · App shell delegates view selection to the route map.
- Routes → Public pages: includes · Public auth screens are part of routing.
- Routes → Developer UX: includes · Developer role views are routed here.
- Routes → Company UX: includes · Company role views are routed here.
- App shell → Auth context: shares state · Top-level app provides auth/session context.
- App shell → Shared UI: uses · Shell and pages reuse shared UI building blocks.
- App shell → UI helpers: imports · Shared UI helpers support the client shell.
- Developer UX → Auth context: reads session · Developer views use shared authentication state.
- Company UX → Auth context: reads session · Company views use shared authentication state.
- Developer UX → Auth route: calls api · Developer flows authenticate and fetch protected data.
- Company UX → Auth route: calls api · Company flows authenticate and fetch protected data.
- Server entry → API routes: mounts · Express entry wires up route modules.
- API routes → Auth route: exposes · Authentication endpoints are registered here.
- API routes → Domain routes: exposes · Domain feature endpoints are registered here.
- Auth route → Controllers: delegates · Auth routes forward to user/account logic.
- Domain routes → Controllers: delegates · Domain routes forward to business logic.
- Controllers → Models: queries · Controllers read and write through the model layer.
- Models → MongoDB: persists · Mongoose models store data in MongoDB.
- Controllers → AI subsystem: includes · AI-driven matching/recommendation logic is separated from core CRUD.
- AI subsystem → Models: uses data · AI features rely on stored user/job records.
