# akshaymarch7/devtinder architecture

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

- Interactive diagram: https://gitdiagram.com/akshaymarch7/devtinder
- Repository: https://github.com/akshaymarch7/devtinder

## Overview

#### Purpose and Runtime
This is a Node.js backend for a user-connection platform with authentication, profiles, connection requests, chat, and payments. The application entry point is `src/app.js`; persistence is initialized through `src/config/database.js`. Route modules expose the API surface.

#### HTTP API Composition
`src/app.js` is the composition boundary for middleware, database setup, and route registration. Domain endpoints are separated by concern:
- Authentication: `src/routes/auth.js`
- Users and profiles: `src/routes/user.js`, `src/routes/profile.js`
- Connection-request lifecycle: `src/routes/request.js`
- Chat and payment workflows: `src/routes/chat.js`, `src/routes/payment.js`

This routing layer should remain responsible for request orchestration rather than persistence or third-party integration details.

#### Identity and Access Boundary
Authentication is centralized in `src/middlewares/auth.js`, with user identity represented by `src/models/user.js`. Auth routes in `src/routes/auth.js` establish identity; protected routes should consume the middleware-provided identity rather than accepting a user identifier as authority.

Validation and shared domain constants are located in `src/utils/validation.js` and `src/utils/constants.js`, forming common input and state constraints across route flows.

#### Core Social Domain
User discovery/profile data is handled through `src/models/user.js` and profile-facing routes in `src/routes/profile.js`. Relationship state is a separate persisted concept in `src/models/connectionRequest.js`, exposed through `src/routes/request.js`.

Primary flow: authenticated user → profile/user action → create, review, or update a connection request → resulting relationship state gates downstream interactions such as chat.

#### Realtime Chat
Chat persistence is modeled in `src/models/chat.js`; HTTP-facing chat operations are in `src/routes/chat.js`. Realtime/socket behavior is isolated in `src/utils/socket.js`, creating a transport boundary between the main HTTP application and event-driven delivery.

Expected control flow is: authenticated/authorized participants → chat message persisted via the chat domain → socket layer broadcasts or delivers events. Relationship authorization should be enforced before chat access.

#### Payments and External Services
Payments are represented by `src/models/payment.js`, coordinated by `src/routes/payment.js`, and integrated through `src/utils/razorpay.js`. Razorpay is therefore an external payment-service boundary; payment records should track application-side state independently of provider responses.

Email delivery is abstracted through `src/utils/sendEmail.js` and `src/utils/sesClient.js`, indicating Amazon SES integration. Scheduled/background actions are centralized in `src/utils/cronjob.js`, which is the likely boundary for recurring jobs such as notifications, expiry handling, or payment/request reconciliation.

#### Data and Infrastructure Boundaries
Mongo-style model organization is implied by the domain model files under `src/models/`, while `src/config/database.js` owns database connectivity. The application depends on at least three infrastructure concerns: database persistence, Razorpay payment processing, and Amazon SES email delivery. Socket infrastructure is additionally required for realtime chat behavior.

Key architecture rule: routes coordinate requests; models own persisted entities; middleware owns cross-cutting authorization; utilities encapsulate external providers, sockets, and scheduled execution.

Main entry points: [`src/app.js`](https://github.com/akshaymarch7/devtinder/blob/main/src/app.js) (App composition), [`src/routes/request.js`](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/request.js) (Connection requests), [`src/routes/chat.js`](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/chat.js) (Chat HTTP), [`src/middlewares/auth.js`](https://github.com/akshaymarch7/devtinder/blob/main/src/middlewares/auth.js) (Auth middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app_entry["App composition<br/>Express entry<br/>[app.js]"]
  node_database_setup["Database setup<br/>persistence bootstrap<br/>[database.js]"]
  node_auth_middleware["Auth middleware<br/>access control<br/>[auth.js]"]
end

subgraph group_api["HTTP API"]
  node_auth_routes["Authentication<br/>route module<br/>[auth.js]"]
  node_user_routes["User discovery<br/>route module<br/>[user.js]"]
  node_profile_routes["Profiles<br/>route module<br/>[profile.js]"]
  node_request_routes["Connection requests<br/>route module<br/>[request.js]"]
  node_chat_routes["Chat HTTP<br/>route module<br/>[chat.js]"]
  node_payment_routes["Payments<br/>route module<br/>[payment.js]"]
end

subgraph group_domain["Domain &amp; Data"]
  node_user_model["User<br/>persisted model<br/>[user.js]"]
  node_request_model["Connection request<br/>persisted model"]
  node_chat_model["Chat message<br/>persisted model<br/>[chat.js]"]
  node_payment_model["Payment record<br/>persisted model<br/>[payment.js]"]
  node_validation["Validation<br/>shared policy<br/>[validation.js]"]
  node_constants["Domain constants<br/>shared state rules<br/>[constants.js]"]
  node_database[("Mongo persistence<br/>database")]
end

subgraph group_integrations["Async &amp; Integrations"]
  node_socket_layer["Socket transport<br/>realtime boundary<br/>[socket.js]"]
  node_razorpay{{"Razorpay adapter<br/>payment provider adapter<br/>[razorpay.js]"}}
  node_email_delivery["Email delivery<br/>SES mail adapter<br/>[sendEmail.js]"]
  node_ses_client{{"Amazon SES client<br/>provider client<br/>[sesClient.js]"}}
  node_scheduled_jobs["Scheduled jobs<br/>background scheduler<br/>[cronjob.js]"]
end

node_app_entry -->|"initializes"| node_database_setup
node_database_setup -->|"connects"| node_database
node_app_entry -->|"installs"| node_auth_middleware
node_app_entry -->|"registers"| node_auth_routes
node_app_entry -->|"registers"| node_user_routes
node_app_entry -->|"registers"| node_profile_routes
node_app_entry -->|"registers"| node_request_routes
node_app_entry -->|"registers"| node_chat_routes
node_app_entry -->|"registers"| node_payment_routes
node_auth_routes -->|"establishes identity"| node_user_model
node_auth_middleware -->|"verifies identity"| node_user_model
node_profile_routes -->|"protects"| node_auth_middleware
node_profile_routes -->|"reads and updates"| node_user_model
node_user_routes -->|"queries"| node_user_model
node_request_routes -->|"protects"| node_auth_middleware
node_request_routes -->|"manages lifecycle"| node_request_model
node_request_routes -->|"resolves participants"| node_user_model
node_chat_routes -->|"protects"| node_auth_middleware
node_chat_routes -->|"authorizes relationship"| node_request_model
node_chat_routes -->|"persists messages"| node_chat_model
node_chat_routes -->|"delivers events"| node_socket_layer
node_payment_routes -->|"records state"| node_payment_model
node_payment_routes -->|"processes payment"| node_razorpay
node_email_delivery -->|"sends through"| node_ses_client
node_scheduled_jobs -.->|"triggers notifications"| node_email_delivery
node_scheduled_jobs -.->|"reconciles"| node_payment_model
node_scheduled_jobs -.->|"handles expiry"| node_request_model
node_request_routes -->|"validates input"| node_validation
node_request_routes -->|"applies states"| node_constants

click node_app_entry "https://github.com/akshaymarch7/devtinder/blob/main/src/app.js"
click node_database_setup "https://github.com/akshaymarch7/devtinder/blob/main/src/config/database.js"
click node_auth_middleware "https://github.com/akshaymarch7/devtinder/blob/main/src/middlewares/auth.js"
click node_auth_routes "https://github.com/akshaymarch7/devtinder/blob/main/src/routes/auth.js"
click node_user_routes "https://github.com/akshaymarch7/devtinder/blob/main/src/routes/user.js"
click node_profile_routes "https://github.com/akshaymarch7/devtinder/blob/main/src/routes/profile.js"
click node_request_routes "https://github.com/akshaymarch7/devtinder/blob/main/src/routes/request.js"
click node_chat_routes "https://github.com/akshaymarch7/devtinder/blob/main/src/routes/chat.js"
click node_payment_routes "https://github.com/akshaymarch7/devtinder/blob/main/src/routes/payment.js"
click node_user_model "https://github.com/akshaymarch7/devtinder/blob/main/src/models/user.js"
click node_request_model "https://github.com/akshaymarch7/devtinder/blob/main/src/models/connectionRequest.js"
click node_chat_model "https://github.com/akshaymarch7/devtinder/blob/main/src/models/chat.js"
click node_payment_model "https://github.com/akshaymarch7/devtinder/blob/main/src/models/payment.js"
click node_validation "https://github.com/akshaymarch7/devtinder/blob/main/src/utils/validation.js"
click node_constants "https://github.com/akshaymarch7/devtinder/blob/main/src/utils/constants.js"
click node_socket_layer "https://github.com/akshaymarch7/devtinder/blob/main/src/utils/socket.js"
click node_razorpay "https://github.com/akshaymarch7/devtinder/blob/main/src/utils/razorpay.js"
click node_email_delivery "https://github.com/akshaymarch7/devtinder/blob/main/src/utils/sendEmail.js"
click node_ses_client "https://github.com/akshaymarch7/devtinder/blob/main/src/utils/sesClient.js"
click node_scheduled_jobs "https://github.com/akshaymarch7/devtinder/blob/main/src/utils/cronjob.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_app_entry,node_database_setup,node_auth_middleware toneBlue
class node_auth_routes,node_user_routes,node_profile_routes,node_request_routes,node_chat_routes,node_payment_routes toneAmber
class node_user_model,node_request_model,node_chat_model,node_payment_model,node_validation,node_constants,node_database toneMint
class node_socket_layer,node_razorpay,node_email_delivery,node_ses_client,node_scheduled_jobs toneRose
```

## Components

### Application

- [App composition](https://github.com/akshaymarch7/devtinder/blob/main/src/app.js): Express entry · Registers middleware, database setup, and routes. · `src/app.js`
- [Database setup](https://github.com/akshaymarch7/devtinder/blob/main/src/config/database.js): persistence bootstrap · `src/config/database.js`
- [Auth middleware](https://github.com/akshaymarch7/devtinder/blob/main/src/middlewares/auth.js): access control · Supplies verified user identity to protected flows. · `src/middlewares/auth.js`

### HTTP API

- [Authentication](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/auth.js): route module · `src/routes/auth.js`
- [User discovery](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/user.js): route module · `src/routes/user.js`
- [Profiles](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/profile.js): route module · `src/routes/profile.js`
- [Connection requests](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/request.js): route module · `src/routes/request.js`
- [Chat HTTP](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/chat.js): route module · `src/routes/chat.js`
- [Payments](https://github.com/akshaymarch7/devtinder/blob/main/src/routes/payment.js): route module · `src/routes/payment.js`

### Domain & Data

- [User](https://github.com/akshaymarch7/devtinder/blob/main/src/models/user.js): persisted model · `src/models/user.js`
- [Connection request](https://github.com/akshaymarch7/devtinder/blob/main/src/models/connectionRequest.js): persisted model · Owns relationship lifecycle state. · `src/models/connectionRequest.js`
- [Chat message](https://github.com/akshaymarch7/devtinder/blob/main/src/models/chat.js): persisted model · `src/models/chat.js`
- [Payment record](https://github.com/akshaymarch7/devtinder/blob/main/src/models/payment.js): persisted model · Tracks application-side payment state. · `src/models/payment.js`
- [Validation](https://github.com/akshaymarch7/devtinder/blob/main/src/utils/validation.js): shared policy · `src/utils/validation.js`
- [Domain constants](https://github.com/akshaymarch7/devtinder/blob/main/src/utils/constants.js): shared state rules · `src/utils/constants.js`
- **Mongo persistence**: database

### Async & Integrations

- [Socket transport](https://github.com/akshaymarch7/devtinder/blob/main/src/utils/socket.js): realtime boundary · `src/utils/socket.js`
- [Razorpay adapter](https://github.com/akshaymarch7/devtinder/blob/main/src/utils/razorpay.js): payment provider adapter · `src/utils/razorpay.js`
- [Email delivery](https://github.com/akshaymarch7/devtinder/blob/main/src/utils/sendEmail.js): SES mail adapter · `src/utils/sendEmail.js`
- [Amazon SES client](https://github.com/akshaymarch7/devtinder/blob/main/src/utils/sesClient.js): provider client · `src/utils/sesClient.js`
- [Scheduled jobs](https://github.com/akshaymarch7/devtinder/blob/main/src/utils/cronjob.js): background scheduler · Runs recurring notification, expiry, and reconciliation work. · `src/utils/cronjob.js`

## Connections

- App composition → Database setup: initializes
- Database setup → Mongo persistence: connects
- App composition → Auth middleware: installs
- App composition → Authentication: registers
- App composition → User discovery: registers
- App composition → Profiles: registers
- App composition → Connection requests: registers
- App composition → Chat HTTP: registers
- App composition → Payments: registers
- Authentication → User: establishes identity
- Auth middleware → User: verifies identity
- Profiles → Auth middleware: protects
- Profiles → User: reads and updates
- User discovery → User: queries
- Connection requests → Auth middleware: protects
- Connection requests → Connection request: manages lifecycle
- Connection requests → User: resolves participants
- Chat HTTP → Auth middleware: protects
- Chat HTTP → Connection request: authorizes relationship
- Chat HTTP → Chat message: persists messages
- Chat HTTP → Socket transport: delivers events
- Payments → Payment record: records state
- Payments → Razorpay adapter: processes payment
- Email delivery → Amazon SES client: sends through
- Scheduled jobs → Email delivery: triggers notifications
- Scheduled jobs → Payment record: reconciles
- Scheduled jobs → Connection request: handles expiry
- Connection requests → Validation: validates input
- Connection requests → Domain constants: applies states
