# ayush-pandey1/karmsetu architecture

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

- Interactive diagram: https://gitdiagram.com/ayush-pandey1/karmsetu
- Repository: https://github.com/ayush-pandey1/karmsetu

## Overview

#### Purpose and Runtime
This is a Next.js App Router marketplace application connecting clients and freelancers. It combines public marketing/authentication, role-specific dashboards, project applications and delivery, chat, nearby-user discovery, and payments. The runtime is Node.js/Next.js with React, Tailwind/PostCSS, MongoDB-oriented model files, NextAuth, Redux client state, Cloudinary uploads, and payment integration.

#### Entry Points and Route Domains
The public site is rooted at `src/app/(site)/page.jsx` under the shared site shell in `src/app/(site)/layout.jsx`. Authentication and role selection begin under `src/app/auth/signin/page.jsx`, `src/app/auth/signup/page.jsx`, and `src/app/auth/select/page.jsx`. Onboarding branches by account type at `src/app/onboarding/client/page.jsx` and `src/app/onboarding/freelancer/page.jsx`.

#### Role-Specific Application Shells
Client and freelancer workspaces are isolated by route groups and each has a dedicated layout/navigation composition:
- Client: `src/app/(client)/cl/layout.jsx`, `src/components/mainClient/side-nav.jsx`
- Freelancer: `src/app/(freelancer)/fl/layout.jsx`, `src/components/mainFreelancer/side-nav.jsx`

These boundaries organize distinct lifecycle views while sharing underlying APIs and reusable UI. Client routes focus on job creation, applications, and hired projects; freelancer routes focus on available projects, portfolio, rewards, and notifications.

#### Marketplace and Project Lifecycle
Clients create and manage jobs through `src/app/(client)/cl/createjob/page.jsx` and job/project dashboards at `src/app/(client)/cl/projectDashboard/[...jobId]/page.jsx`. Freelancers browse and track work via `src/app/(freelancer)/fl/projects/page.jsx` and `src/app/(freelancer)/fl/projectDashboard/[...jobId]/page.jsx`. Server-side resource boundaries are implemented by project and application routes: `src/app/api/project/route.js`, `src/app/api/application/route.js`, and `src/app/api/applicationAccepted/[id]/route.js`. Domain persistence representations reside in `src/app/(models)/project.js` and `src/app/(models)/application.js`.

#### Identity, Profiles, and Authorization
NextAuth is exposed through `src/app/api/auth/[...nextauth]/route.js`, with provider/session configuration in `src/app/api/auth/[...nextauth]/options.js`. User records and role/profile retrieval are handled by `src/app/(models)/User.js`, `src/app/api/user/[id]/route.js`, and `src/app/api/userInfoByEmail/route.js`. Middleware in `src/middleware.js` is the likely cross-route access-control boundary. Separate personal-detail APIs preserve client/freelancer profile flows.

#### Messaging and Real-Time-Oriented State
Conversation and message persistence are separated from dashboard pages: `src/app/api/chat/route.js`, `src/app/api/message/route.js`, `src/app/(models)/ChatModel.js`, and `src/app/(models)/MessageModel.js`. Client views consume this through `src/app/(client)/cl/chat/page.jsx` and freelancer views through `src/app/(freelancer)/fl/chat/page.jsx`. Redux coordinates browser-side chat, socket, project, freelancer-project, and language state in `src/app/(redux)/store/store.js` and feature slices such as `src/app/(redux)/features/socketSlice.js`.

#### External Service Boundaries
MongoDB connectivity is centralized in `src/config/db.js` and `src/lib/db.js`. Media upload is abstracted behind `src/app/api/imageUpload/route.js` and `src/lib/cloudinary.js`. Payment creation is isolated at `src/app/api/create-payment/route.js`, with checkout support in `src/checkout.js`. Geographic discovery is exposed through role-specific nearby APIs, including `src/app/api/nearby/client/[id]/route.js` and `src/app/api/nearby/freelancer/[id]/route.js`; map presentation is provided by `src/components/CmapComponent/index.jsx` and `src/components/FmapComponent/index.js`.

Main entry points: [`src/app/(client)/cl/layout.jsx`](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/layout.jsx) (Client dashboard shell), [`src/app/(client)/cl/projectDashboard/[...jobId]/page.jsx`](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/projectDashboard/%5B...jobId%5D/page.jsx) (Client project dashboard), [`src/app/(freelancer)/fl/layout.jsx`](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(freelancer)/fl/layout.jsx) (Freelancer dashboard shell), [`src/app/api/project/[id]/route.js`](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/project/%5Bid%5D/route.js) (Projects)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public &amp; identity"]
  node_site["Marketing site shell<br/>Next.js route<br/>[layout.jsx]"]
  node_auth["Auth and role selection<br/>Next.js routes<br/>[page.jsx]"]
  node_onboarding["Role onboarding<br/>Next.js routes<br/>[page.jsx]"]
  node_middleware{{"Route access control<br/>Next.js middleware<br/>[middleware.js]"}}
end

subgraph group_client["Client workspace"]
  node_client_shell["Client dashboard shell<br/>Next.js layout<br/>[layout.jsx]"]
  node_job_creation["Job creation<br/>Next.js page<br/>[page.jsx]"]
  node_client_projects["Client project dashboard<br/>Next.js page<br/>[page.jsx]"]
end

subgraph group_freelancer["Freelancer workspace"]
  node_freelancer_shell["Freelancer dashboard shell<br/>Next.js layout<br/>[layout.jsx]"]
  node_project_browse["Project browsing<br/>Next.js page<br/>[page.jsx]"]
  node_freelancer_projects["Freelancer project dashboard<br/>Next.js page<br/>[page.jsx]"]
end

subgraph group_platform["Platform services"]
  node_nextauth{{"NextAuth handler<br/>auth API<br/>[route.js]"}}
  node_user[("Users and profiles<br/>user API + model<br/>[route.js]")]
  node_projects[("Projects<br/>project API + model<br/>[route.js]")]
  node_applications[("Applications and hiring<br/>application APIs + model<br/>[route.js]")]
  node_messaging[("Chats and messages<br/>messaging APIs + models<br/>[route.js]")]
  node_redux["Browser state<br/>Redux store<br/>[store.js]"]
  node_media{{"Media uploads<br/>upload API<br/>[route.js]"}}
  node_payments{{"Payment creation<br/>payment API<br/>[route.js]"}}
  node_nearby{{"Nearby-user discovery<br/>nearby API<br/>[route.js]"}}
  node_mongodb[("MongoDB connection<br/>database connection<br/>[db.js]")]
end

node_chat_ui["Role chat views<br/>Next.js pages<br/>[page.jsx]"]

node_site -->|"sign in or sign up"| node_auth
node_auth -->|"select role"| node_onboarding
node_middleware -.->|"guards"| node_client_shell
node_middleware -.->|"guards"| node_freelancer_shell
node_auth -->|"authenticates via"| node_nextauth
node_nextauth -->|"loads sessions and users"| node_user
node_onboarding -->|"creates profile"| node_user
node_client_shell -->|"hosts"| node_job_creation
node_client_shell -->|"hosts"| node_client_projects
node_freelancer_shell -->|"hosts"| node_project_browse
node_freelancer_shell -->|"hosts"| node_freelancer_projects
node_job_creation -->|"creates jobs"| node_projects
node_client_projects -->|"manages"| node_projects
node_project_browse -->|"browses"| node_projects
node_freelancer_projects -->|"tracks application"| node_applications
node_project_browse -->|"applies"| node_applications
node_client_projects -->|"reviews and accepts"| node_applications
node_chat_ui -->|"sends and reads"| node_messaging
node_redux -.->|"coordinates chat state"| node_messaging
node_client_shell -->|"discovers freelancers"| node_nearby
node_freelancer_shell -->|"discovers clients"| node_nearby
node_client_projects -->|"creates payment"| node_payments
node_projects -->|"persists in"| node_mongodb
node_applications -->|"persists in"| node_mongodb
node_messaging -->|"persists in"| node_mongodb
node_user -->|"persists in"| node_mongodb
node_job_creation -->|"uploads media"| node_media

click node_site "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(site)/layout.jsx"
click node_auth "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/auth/signin/page.jsx"
click node_onboarding "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/onboarding/client/page.jsx"
click node_middleware "https://github.com/ayush-pandey1/karmsetu/blob/main/src/middleware.js"
click node_nextauth "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/auth/%5B...nextauth%5D/route.js"
click node_user "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/user/%5Bid%5D/route.js"
click node_client_shell "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/layout.jsx"
click node_job_creation "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/createjob/page.jsx"
click node_client_projects "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/projectDashboard/%5B...jobId%5D/page.jsx"
click node_freelancer_shell "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(freelancer)/fl/layout.jsx"
click node_project_browse "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(freelancer)/fl/projects/page.jsx"
click node_freelancer_projects "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(freelancer)/fl/projectDashboard/%5B...jobId%5D/page.jsx"
click node_projects "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/project/%5Bid%5D/route.js"
click node_applications "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/application/%5Bid%5D/route.js"
click node_chat_ui "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/chat/page.jsx"
click node_messaging "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/chat/route.js"
click node_redux "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(redux)/store/store.js"
click node_media "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/imageUpload/route.js"
click node_payments "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/create-payment/route.js"
click node_nearby "https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/nearby/client/%5Bid%5D/route.js"
click node_mongodb "https://github.com/ayush-pandey1/karmsetu/blob/main/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_site,node_auth,node_onboarding,node_middleware toneBlue
class node_client_shell,node_job_creation,node_client_projects toneAmber
class node_freelancer_shell,node_project_browse,node_freelancer_projects toneMint
class node_nextauth,node_user,node_projects,node_applications,node_messaging,node_redux,node_media,node_payments,node_nearby,node_mongodb toneRose
class node_chat_ui toneNeutral
```

## Components

### Public & identity

- [Marketing site shell](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(site)/layout.jsx): Next.js route · `src/app/(site)/layout.jsx`
- [Auth and role selection](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/auth/signin/page.jsx): Next.js routes · `src/app/auth/signin/page.jsx`
- [Role onboarding](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/onboarding/client/page.jsx): Next.js routes · Client and freelancer onboarding branches. · `src/app/onboarding/client/page.jsx`
- [Route access control](https://github.com/ayush-pandey1/karmsetu/blob/main/src/middleware.js): Next.js middleware · `src/middleware.js`

### Client workspace

- [Client dashboard shell](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/layout.jsx): Next.js layout · Composes client navigation and lifecycle views. · `src/app/(client)/cl/layout.jsx`
- [Job creation](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/createjob/page.jsx): Next.js page · `src/app/(client)/cl/createjob/page.jsx`
- [Client project dashboard](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/projectDashboard/%5B...jobId%5D/page.jsx): Next.js page · `src/app/(client)/cl/projectDashboard/[...jobId]/page.jsx`

### Freelancer workspace

- [Freelancer dashboard shell](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(freelancer)/fl/layout.jsx): Next.js layout · Composes freelancer navigation and lifecycle views. · `src/app/(freelancer)/fl/layout.jsx`
- [Project browsing](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(freelancer)/fl/projects/page.jsx): Next.js page · `src/app/(freelancer)/fl/projects/page.jsx`
- [Freelancer project dashboard](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(freelancer)/fl/projectDashboard/%5B...jobId%5D/page.jsx): Next.js page · `src/app/(freelancer)/fl/projectDashboard/[...jobId]/page.jsx`

### Platform services

- [NextAuth handler](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/auth/%5B...nextauth%5D/route.js): auth API · `src/app/api/auth/[...nextauth]/route.js`
- [Users and profiles](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/user/%5Bid%5D/route.js): user API + model · `src/app/api/user/[id]/route.js`
- [Projects](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/project/%5Bid%5D/route.js): project API + model · Job creation and project lifecycle resource. · `src/app/api/project/[id]/route.js`
- [Applications and hiring](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/application/%5Bid%5D/route.js): application APIs + model · Handles applications and acceptance. · `src/app/api/application/[id]/route.js`
- [Chats and messages](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/chat/route.js): messaging APIs + models · `src/app/api/chat/route.js`
- [Browser state](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(redux)/store/store.js): Redux store · Coordinates chat, socket, project, and language state. · `src/app/(redux)/store/store.js`
- [Media uploads](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/imageUpload/route.js): upload API · Abstracts Cloudinary uploads. · `src/app/api/imageUpload/route.js`
- [Payment creation](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/create-payment/route.js): payment API · `src/app/api/create-payment/route.js`
- [Nearby-user discovery](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/api/nearby/client/%5Bid%5D/route.js): nearby API · Role-specific geographic discovery. · `src/app/api/nearby/client/[id]/route.js`
- [MongoDB connection](https://github.com/ayush-pandey1/karmsetu/blob/main/src/config/db.js): database connection · `src/config/db.js`

### Other components

- [Role chat views](https://github.com/ayush-pandey1/karmsetu/blob/main/src/app/(client)/cl/chat/page.jsx): Next.js pages · Shared messaging experience in both workspaces. · `src/app/(client)/cl/chat/page.jsx`

## Connections

- Marketing site shell → Auth and role selection: sign in or sign up
- Auth and role selection → Role onboarding: select role
- Route access control → Client dashboard shell: guards
- Route access control → Freelancer dashboard shell: guards
- Auth and role selection → NextAuth handler: authenticates via
- NextAuth handler → Users and profiles: loads sessions and users
- Role onboarding → Users and profiles: creates profile
- Client dashboard shell → Job creation: hosts
- Client dashboard shell → Client project dashboard: hosts
- Freelancer dashboard shell → Project browsing: hosts
- Freelancer dashboard shell → Freelancer project dashboard: hosts
- Job creation → Projects: creates jobs
- Client project dashboard → Projects: manages
- Project browsing → Projects: browses
- Freelancer project dashboard → Applications and hiring: tracks application
- Project browsing → Applications and hiring: applies
- Client project dashboard → Applications and hiring: reviews and accepts
- Role chat views → Chats and messages: sends and reads
- Browser state → Chats and messages: coordinates chat state
- Client dashboard shell → Nearby-user discovery: discovers freelancers
- Freelancer dashboard shell → Nearby-user discovery: discovers clients
- Client project dashboard → Payment creation: creates payment
- Projects → MongoDB connection: persists in
- Applications and hiring → MongoDB connection: persists in
- Chats and messages → MongoDB connection: persists in
- Users and profiles → MongoDB connection: persists in
- Job creation → Media uploads: uploads media
