# ratheshan03/matrimony-backend architecture

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

- Interactive diagram: https://gitdiagram.com/ratheshan03/matrimony-backend
- Repository: https://github.com/ratheshan03/matrimony-backend

## Overview

This is an Express backend for a matrimony service. The main workflow accepts profile registration, lets administrators review and approve submissions, then supports login and authenticated profile discovery and management. Controllers own these domain operations and use Mongo-backed models; profile operations also include photo storage and caching. The map preserves authentication, administration, profile features, and supporting infrastructure. Redis initialization is commented out, and some configuration/service implementations were not shown, so uncertain infrastructure links are omitted or marked unverified.

Main entry points: [`server.js`](https://github.com/ratheshan03/matrimony-backend/blob/main/server.js) (Express server), [`controllers/adminController.js`](https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/adminController.js) (Review and account admin), [`routes/profileRoutes.js`](https://github.com/ratheshan03/matrimony-backend/blob/main/routes/profileRoutes.js) (Profile routes), [`controllers/profileController.js`](https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/profileController.js) (Profile discovery and media)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["HTTP entry"]
  node_server["Express server<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_profile_routes["Profile routes<br/>[profileRoutes.js]"]
  node_admin_routes["Admin routes<br/>[adminRoutes.js]"]
end

subgraph group_identity["Identity"]
  node_auth_controller["Authentication<br/>[authController.js]"]
  node_auth_middleware["Token protection<br/>[authMiddleware.js]"]
  node_user_model[("User records<br/>[User.js]")]
end

subgraph group_profile["Profiles"]
  node_profile_controller["Profile discovery and media"]
  node_profile_model[("Profile records<br/>[Profile.js]")]
  node_upload_middleware["Photo upload parsing"]
end

subgraph group_admin["Administration"]
  node_admin_controller["Review and account admin<br/>[adminController.js]"]
  node_admin_middleware["Admin authorization<br/>[adminMiddleware.js]"]
  node_credentials["Credential generation"]
  node_email_service["Approval email<br/>[emailService.js]"]
end

subgraph group_infra["Infrastructure"]
  node_db_config["Database connection<br/>[db.js]"]
  node_gcs_config["Cloud storage config<br/>[gcs.js]"]
  node_redis_config["Redis client config<br/>[redisClient.js]"]
end

node_client(("API client"))
node_mongo[("MongoDB")]
node_cloud_storage[("Cloud object storage")]
node_redis[("Redis")]

node_client -->|"sends requests"| node_server
node_server -->|"connects database"| node_db_config
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_profile_routes
node_server -->|"mounts routes"| node_admin_routes
node_auth_routes -->|"dispatches requests"| node_auth_controller
node_profile_routes -->|"dispatches requests"| node_profile_controller
node_profile_routes -->|"protects routes"| node_auth_middleware
node_profile_routes -->|"parses uploads"| node_upload_middleware
node_admin_routes -->|"dispatches requests"| node_admin_controller
node_auth_controller -->|"reads and updates"| node_user_model
node_auth_controller -->|"creates profiles"| node_profile_model
node_auth_middleware -->|"loads user"| node_user_model
node_profile_controller -->|"queries and updates"| node_profile_model
node_profile_controller -->|"uploads and deletes"| node_gcs_config
node_profile_controller -->|"reads and writes cache"| node_redis_config
node_admin_controller -->|"reviews profiles"| node_profile_model
node_admin_controller -->|"updates accounts"| node_user_model
node_admin_controller -->|"generates credentials"| node_credentials
node_admin_controller -->|"sends approval email"| node_email_service
node_admin_middleware -->|"checks account"| node_user_model
node_db_config -.-> node_mongo
node_gcs_config -.-> node_cloud_storage
node_redis_config -.-> node_redis

click node_server "https://github.com/ratheshan03/matrimony-backend/blob/main/server.js"
click node_auth_routes "https://github.com/ratheshan03/matrimony-backend/blob/main/routes/authRoutes.js"
click node_profile_routes "https://github.com/ratheshan03/matrimony-backend/blob/main/routes/profileRoutes.js"
click node_admin_routes "https://github.com/ratheshan03/matrimony-backend/blob/main/routes/adminRoutes.js"
click node_auth_controller "https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/authController.js"
click node_auth_middleware "https://github.com/ratheshan03/matrimony-backend/blob/main/middlewares/authMiddleware.js"
click node_user_model "https://github.com/ratheshan03/matrimony-backend/blob/main/models/User.js"
click node_profile_controller "https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/profileController.js"
click node_profile_model "https://github.com/ratheshan03/matrimony-backend/blob/main/models/Profile.js"
click node_upload_middleware "https://github.com/ratheshan03/matrimony-backend/blob/main/middlewares/uploadMiddleware.js"
click node_admin_controller "https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/adminController.js"
click node_admin_middleware "https://github.com/ratheshan03/matrimony-backend/blob/main/middlewares/adminMiddleware.js"
click node_credentials "https://github.com/ratheshan03/matrimony-backend/blob/main/utils/generateCredentials.js"
click node_email_service "https://github.com/ratheshan03/matrimony-backend/blob/main/services/emailService.js"
click node_db_config "https://github.com/ratheshan03/matrimony-backend/blob/main/config/db.js"
click node_gcs_config "https://github.com/ratheshan03/matrimony-backend/blob/main/config/gcs.js"
click node_redis_config "https://github.com/ratheshan03/matrimony-backend/blob/main/config/redisClient.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_server,node_auth_routes,node_profile_routes,node_admin_routes,node_client toneBlue
class node_auth_controller,node_auth_middleware,node_user_model,node_mongo,node_cloud_storage,node_redis toneAmber
class node_profile_controller,node_profile_model,node_upload_middleware toneMint
class node_admin_controller,node_admin_middleware,node_credentials,node_email_service toneRose
class node_db_config,node_gcs_config,node_redis_config toneIndigo
```

## Components

### HTTP entry

- [Express server](https://github.com/ratheshan03/matrimony-backend/blob/main/server.js): `server.js`
- [Auth routes](https://github.com/ratheshan03/matrimony-backend/blob/main/routes/authRoutes.js): `routes/authRoutes.js`
- [Profile routes](https://github.com/ratheshan03/matrimony-backend/blob/main/routes/profileRoutes.js): `routes/profileRoutes.js`
- [Admin routes](https://github.com/ratheshan03/matrimony-backend/blob/main/routes/adminRoutes.js): `routes/adminRoutes.js`

### Identity

- [Authentication](https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/authController.js): `controllers/authController.js`
- [Token protection](https://github.com/ratheshan03/matrimony-backend/blob/main/middlewares/authMiddleware.js): `middlewares/authMiddleware.js`
- [User records](https://github.com/ratheshan03/matrimony-backend/blob/main/models/User.js): `models/User.js`

### Profiles

- [Profile discovery and media](https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/profileController.js): `controllers/profileController.js`
- [Profile records](https://github.com/ratheshan03/matrimony-backend/blob/main/models/Profile.js): `models/Profile.js`
- [Photo upload parsing](https://github.com/ratheshan03/matrimony-backend/blob/main/middlewares/uploadMiddleware.js): `middlewares/uploadMiddleware.js`

### Administration

- [Review and account admin](https://github.com/ratheshan03/matrimony-backend/blob/main/controllers/adminController.js): `controllers/adminController.js`
- [Admin authorization](https://github.com/ratheshan03/matrimony-backend/blob/main/middlewares/adminMiddleware.js): `middlewares/adminMiddleware.js`
- [Credential generation](https://github.com/ratheshan03/matrimony-backend/blob/main/utils/generateCredentials.js): `utils/generateCredentials.js`
- [Approval email](https://github.com/ratheshan03/matrimony-backend/blob/main/services/emailService.js): `services/emailService.js`

### Infrastructure

- [Database connection](https://github.com/ratheshan03/matrimony-backend/blob/main/config/db.js): `config/db.js`
- [Cloud storage config](https://github.com/ratheshan03/matrimony-backend/blob/main/config/gcs.js): `config/gcs.js`
- [Redis client config](https://github.com/ratheshan03/matrimony-backend/blob/main/config/redisClient.js): `config/redisClient.js`

### Other components

- **API client**
- **MongoDB**
- **Cloud object storage**
- **Redis**

## Connections

- API client → Express server: sends requests (evidence: `server.js`)
- Express server → Database connection: connects database (evidence: `server.js`)
- Express server → Auth routes: mounts routes (evidence: `server.js`)
- Express server → Profile routes: mounts routes (evidence: `server.js`)
- Express server → Admin routes: mounts routes (evidence: `server.js`)
- Auth routes → Authentication: dispatches requests (evidence: `routes/authRoutes.js`)
- Profile routes → Profile discovery and media: dispatches requests (evidence: `routes/profileRoutes.js`)
- Profile routes → Token protection: protects routes (evidence: `routes/profileRoutes.js`)
- Profile routes → Photo upload parsing: parses uploads (evidence: `routes/profileRoutes.js`)
- Admin routes → Review and account admin: dispatches requests (evidence: `routes/adminRoutes.js`)
- Authentication → User records: reads and updates (evidence: `controllers/authController.js`)
- Authentication → Profile records: creates profiles (evidence: `controllers/authController.js`)
- Token protection → User records: loads user (evidence: `middlewares/authMiddleware.js`)
- Profile discovery and media → Profile records: queries and updates (evidence: `controllers/profileController.js`)
- Profile discovery and media → Cloud storage config: uploads and deletes (evidence: `controllers/profileController.js`)
- Profile discovery and media → Redis client config: reads and writes cache (evidence: `controllers/profileController.js`)
- Review and account admin → Profile records: reviews profiles (evidence: `controllers/adminController.js`)
- Review and account admin → User records: updates accounts (evidence: `controllers/adminController.js`)
- Review and account admin → Credential generation: generates credentials (evidence: `controllers/adminController.js`)
- Review and account admin → Approval email: sends approval email (evidence: `controllers/adminController.js`)
- Admin authorization → User records: checks account (evidence: `middlewares/adminMiddleware.js`)
- Database connection → MongoDB
- Cloud storage config → Cloud object storage
- Redis client config → Redis
