# sahanmedhawa/crosslink architecture

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

- Interactive diagram: https://gitdiagram.com/sahanmedhawa/crosslink
- Repository: https://github.com/sahanmedhawa/crosslink

## Overview

#### Purpose and topology
CrossLink is a MERN collaboration platform for NGOs, volunteers, and corporates. It supports NGO project delivery, volunteer applications and skill matching, corporate proposals/direct funding/resource donations, and notifications. The React SPA is served independently from the Express API; MongoDB is the system of record.

#### Entry points and composition
- Backend startup and HTTP/Socket composition: `backend/src/server.js`, `backend/src/app.js`.
- Frontend Vite/React bootstrap and route-bearing application shell: `frontend/src/main.jsx`, `frontend/src/App.jsx`.
- API follows routes → controllers → Mongoose models/services. Route groups map to domain ownership, e.g. `backend/src/routes/ngo_management/Projectroutes.js` and `backend/src/routes/volunteer_management/participation.routes.js`.

#### Identity, access, and role boundary
Authentication registers/logs in users and issues JWTs; users are typed as volunteer, NGO, or corporate. JWT validation and role-aware protection form the boundary before protected controllers.
- `backend/src/controllers/auth.controller.js`
- `backend/src/middleware/auth.middleware.js`
- `backend/src/models/user.model.js`
- Client-side identity/session state is supplied through `frontend/src/context/AuthContext.jsx`.

#### NGO project lifecycle
NGOs create, update, publish/status-manage, and delete projects, including optional project image upload. Projects expose public discovery and provide the central target for participation, proposals, funding, and resources.
- `backend/src/controllers/ngo_management/projectcontroller.js`
- `backend/src/routes/ngo_management/Projectroutes.js`
- `backend/src/models/project.js`
- NGO dashboards and project management views are under `frontend/src/pages/ngo/myprojects.jsx` and `frontend/src/pages/ngo/createproject.jsx`.

#### Volunteer matching and participation
The matchmaking service evaluates volunteer profile skills/interests against active projects, returning matched projects. Volunteers submit and manage participation applications; NGOs approve/reject them and view project volunteers. Participation is persisted separately from users/projects, allowing application status and statistics.
- `backend/src/services/volunteer_management/matchmaking.service.js`
- `backend/src/controllers/volunteer_management/participation.controller.js`
- `backend/src/models/participation.model.js`
- `frontend/src/pages/volunteer/MatchedProjects.jsx`, `frontend/src/pages/volunteer/MyApplications.jsx`.

#### Corporate collaboration and contribution flows
Corporates discover NGOs/projects, submit proposals for NGO review, send direct funding, and donate/manage physical resources. Proposal, funding, and resource documents are separate transaction-like records linked to projects and actor identities; corporate reporting aggregates impact from these domains.
- `backend/src/controllers/corporate_management/proposal.controller.js`
- `backend/src/controllers/corporate_management/funding.controller.js`
- `backend/src/controllers/resource_management/resorceController.js`
- `backend/src/models/proposal.js`, `backend/src/models/funding.js`, `backend/src/models/resorce.js`.

#### Notification and asynchronous delivery
Domain actions can create persisted notifications, emit real-time Socket.IO events, and use email utilities. The frontend consumes socket and notification API channels, storing notification/UI state in Redux.
- `backend/src/services/notification.service.js`
- `backend/src/socket/socket.service.js`
- `backend/src/models/notification.model.js`
- `frontend/src/services/socket.js`, `frontend/src/store/slices/notificationsSlice.js`.

#### Runtime infrastructure and integrations
Node/Express uses Mongoose with MongoDB Atlas/local MongoDB, JWT, CORS/security controls, and multipart upload middleware. Cloudinary stores project/profile images; Gmail SMTP sends email; NewsAPI supplies CSR news; the UN SDG API provides goals/targets/data. React 19/Vite uses Tailwind, MUI, Leaflet, and Recharts. Deployment targets are Render for API (`render.yaml`) and Vercel for frontend (`frontend/vercel.json`).

Main entry points: [`frontend/src/App.jsx`](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/App.jsx) (Application shell), [`backend/src/app.js`](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/app.js) (HTTP application), [`backend/src/services/notification.service.js`](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/services/notification.service.js) (Notification delivery), [`backend/src/middleware/auth.middleware.js`](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/middleware/auth.middleware.js) (JWT role guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_web_bootstrap["Vite bootstrap<br/>React entry<br/>[main.jsx]"]
  node_web_app["Application shell<br/>React routes<br/>[App.jsx]"]
  node_auth_context["Session state<br/>Auth context<br/>[AuthContext.jsx]"]
  node_ngo_views["NGO project views<br/>React pages<br/>[myprojects.jsx]"]
  node_volunteer_views["Volunteer views<br/>React pages"]
  node_notification_ui["Notification UI state<br/>Redux slice"]
  node_socket_client["Socket client<br/>Socket.IO client<br/>[socket.js]"]
end

subgraph group_api["Express API"]
  node_server["Server startup<br/>Node entry<br/>[server.js]"]
  node_app["HTTP application<br/>Express composition<br/>[app.js]"]
  node_auth["Authentication<br/>Auth controller<br/>[auth.controller.js]"]
  node_access["JWT role guard<br/>Express middleware<br/>[auth.middleware.js]"]
  node_projects["Project lifecycle<br/>Project routes/controller<br/>[Projectroutes.js]"]
  node_matching["Skill matching<br/>Matchmaking service"]
  node_participation["Participation workflow<br/>Participation controller"]
  node_contributions["Corporate contributions<br/>Domain controllers"]
  node_notifications["Notification delivery<br/>Notification service"]
  node_socket_server["Real-time events<br/>Socket.IO service<br/>[socket.service.js]"]
end

subgraph group_data["Data &amp; integrations"]
  node_mongodb[("MongoDB<br/>System of record")]
  node_cloudinary["Cloudinary<br/>Image storage"]
  node_external_apis{{"External content APIs"}}
  node_email{{"Gmail SMTP<br/>Email delivery"}}
end

node_web_bootstrap -->|"mounts"| node_web_app
node_web_app -->|"provides session"| node_auth_context
node_web_app -->|"routes to"| node_ngo_views
node_web_app -->|"routes to"| node_volunteer_views
node_web_app -->|"uses"| node_notification_ui
node_web_app -->|"connects"| node_socket_client
node_server -->|"starts"| node_app
node_app -->|"auth endpoints"| node_auth
node_app -->|"protects requests with"| node_access
node_access -->|"authorizes"| node_projects
node_access -->|"authorizes"| node_participation
node_access -->|"authorizes"| node_contributions
node_projects -->|"persists projects"| node_mongodb
node_projects -->|"uploads images"| node_cloudinary
node_matching -->|"reads profiles and projects"| node_mongodb
node_participation -->|"persists applications"| node_mongodb
node_contributions -->|"persists transactions"| node_mongodb
node_auth -->|"manages users"| node_mongodb
node_participation -.->|"application events"| node_notifications
node_contributions -.->|"contribution events"| node_notifications
node_notifications -->|"persists notifications"| node_mongodb
node_notifications -->|"emits events"| node_socket_server
node_notifications -->|"sends email"| node_email
node_socket_server -->|"pushes updates"| node_socket_client
node_web_app -->|"REST API calls"| node_app
node_volunteer_views -->|"matched projects"| node_matching
node_ngo_views -->|"manages projects"| node_projects
node_notification_ui -->|"notification API"| node_app
node_app -->|"retrieves news and SDG data"| node_external_apis

click node_web_bootstrap "https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/main.jsx"
click node_web_app "https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/App.jsx"
click node_auth_context "https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/context/AuthContext.jsx"
click node_ngo_views "https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/pages/ngo/myprojects.jsx"
click node_volunteer_views "https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/pages/volunteer/MatchedProjects.jsx"
click node_notification_ui "https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/store/slices/notificationsSlice.js"
click node_socket_client "https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/services/socket.js"
click node_server "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/server.js"
click node_app "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/app.js"
click node_auth "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/controllers/auth.controller.js"
click node_access "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/middleware/auth.middleware.js"
click node_projects "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/routes/ngo_management/Projectroutes.js"
click node_matching "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/services/volunteer_management/matchmaking.service.js"
click node_participation "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/controllers/volunteer_management/participation.controller.js"
click node_contributions "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/controllers/corporate_management/proposal.controller.js"
click node_notifications "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/services/notification.service.js"
click node_socket_server "https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/socket/socket.service.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_web_bootstrap,node_web_app,node_auth_context,node_ngo_views,node_volunteer_views,node_notification_ui,node_socket_client toneBlue
class node_server,node_app,node_auth,node_access,node_projects,node_matching,node_participation,node_contributions,node_notifications,node_socket_server toneAmber
class node_mongodb,node_cloudinary,node_external_apis,node_email toneMint
```

## Components

### React SPA

- [Vite bootstrap](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/main.jsx): React entry · `frontend/src/main.jsx`
- [Application shell](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/App.jsx): React routes · `frontend/src/App.jsx`
- [Session state](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/context/AuthContext.jsx): Auth context · `frontend/src/context/AuthContext.jsx`
- [NGO project views](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/pages/ngo/myprojects.jsx): React pages · `frontend/src/pages/ngo/myprojects.jsx`
- [Volunteer views](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/pages/volunteer/MatchedProjects.jsx): React pages · `frontend/src/pages/volunteer/MatchedProjects.jsx`
- [Notification UI state](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/store/slices/notificationsSlice.js): Redux slice · `frontend/src/store/slices/notificationsSlice.js`
- [Socket client](https://github.com/sahanmedhawa/crosslink/blob/main/frontend/src/services/socket.js): Socket.IO client · `frontend/src/services/socket.js`

### Express API

- [Server startup](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/server.js): Node entry · `backend/src/server.js`
- [HTTP application](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/app.js): Express composition · Composes REST middleware, routes, and Socket.IO. · `backend/src/app.js`
- [Authentication](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/controllers/auth.controller.js): Auth controller · Issues JWTs for volunteer, NGO, and corporate users. · `backend/src/controllers/auth.controller.js`
- [JWT role guard](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/middleware/auth.middleware.js): Express middleware · `backend/src/middleware/auth.middleware.js`
- [Project lifecycle](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/routes/ngo_management/Projectroutes.js): Project routes/controller · Public discovery and NGO project management. · `backend/src/routes/ngo_management/Projectroutes.js`
- [Skill matching](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/services/volunteer_management/matchmaking.service.js): Matchmaking service · `backend/src/services/volunteer_management/matchmaking.service.js`
- [Participation workflow](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/controllers/volunteer_management/participation.controller.js): Participation controller · Handles volunteer applications and NGO decisions. · `backend/src/controllers/volunteer_management/participation.controller.js`
- [Corporate contributions](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/controllers/corporate_management/proposal.controller.js): Domain controllers · Proposals, direct funding, and resource donations. · `backend/src/controllers/corporate_management/proposal.controller.js`
- [Notification delivery](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/services/notification.service.js): Notification service · Persists notifications and triggers delivery channels. · `backend/src/services/notification.service.js`
- [Real-time events](https://github.com/sahanmedhawa/crosslink/blob/main/backend/src/socket/socket.service.js): Socket.IO service · `backend/src/socket/socket.service.js`

### Data & integrations

- **MongoDB**: System of record · Stores users, projects, participation, contribution, and notification records.
- **Cloudinary**: Image storage · Stores project and profile uploads.
- **External content APIs**: NewsAPI and UN SDG API
- **Gmail SMTP**: Email delivery

## Connections

- Vite bootstrap → Application shell: mounts
- Application shell → Session state: provides session
- Application shell → NGO project views: routes to
- Application shell → Volunteer views: routes to
- Application shell → Notification UI state: uses
- Application shell → Socket client: connects
- Server startup → HTTP application: starts
- HTTP application → Authentication: auth endpoints
- HTTP application → JWT role guard: protects requests with
- JWT role guard → Project lifecycle: authorizes
- JWT role guard → Participation workflow: authorizes
- JWT role guard → Corporate contributions: authorizes
- Project lifecycle → MongoDB: persists projects
- Project lifecycle → Cloudinary: uploads images
- Skill matching → MongoDB: reads profiles and projects
- Participation workflow → MongoDB: persists applications
- Corporate contributions → MongoDB: persists transactions
- Authentication → MongoDB: manages users
- Participation workflow → Notification delivery: application events
- Corporate contributions → Notification delivery: contribution events
- Notification delivery → MongoDB: persists notifications
- Notification delivery → Real-time events: emits events
- Notification delivery → Gmail SMTP: sends email
- Real-time events → Socket client: pushes updates
- Application shell → HTTP application: REST API calls
- Volunteer views → Skill matching: matched projects
- NGO project views → Project lifecycle: manages projects
- Notification UI state → HTTP application: notification API
- HTTP application → External content APIs: retrieves news and SDG data
