# antonessam28/saraha-app architecture

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

- Interactive diagram: https://gitdiagram.com/antonessam28/saraha-app
- Repository: https://github.com/antonessam28/saraha-app

## Overview

This is an Express/Mongoose backend for a Saraha-style application. Requests enter through the server and feature routes; the documented-in-source authentication workflow validates input, invokes auth services, persists users and OTPs, and may send verification email or verify Google credentials. User and message routes are also mounted, but their internal behavior is not established by the available excerpts. The graph preserves those product areas while limiting their internal links; relationships are based on shown calls or SOURCE INDEX references.

Main entry points: [`src/app/auth/service/auth.service.js`](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/service/auth.service.js) (Auth workflows), [`src/main.js`](https://github.com/antonessam28/saraha-app/blob/main/src/main.js) (Express server), [`src/app/auth/controller/auth.controller.js`](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/controller/auth.controller.js) (Auth controller), [`src/app/auth/auth.route.js`](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/auth.route.js) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_server["Express server<br/>[main.js]"]
end

subgraph group_auth["Authentication"]
  node_auth_route["Auth routes<br/>[auth.route.js]"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_auth_dto["Auth schemas<br/>[auth.dto.js]"]
  node_auth_service["Auth workflows<br/>[auth.service.js]"]
  node_auth_repo["Auth repository<br/>[auth.repository.js]"]
  node_otp_repo["OTP repository<br/>[otp.repsoitory.js]"]
  node_otp_model["OTP model<br/>[otp.model.js]"]
  node_password_utils["Password hashing<br/>[hash.js]"]
  node_token_utils["Token generation<br/>[token.js]"]
end

subgraph group_users["User domain"]
  node_user_route["User routes<br/>[user.route.js]"]
  node_user_controller["User controller<br/>[user.controller.js]"]
  node_user_service["User service<br/>[user.service.js]"]
  node_user_repo["User repository<br/>[user.repository.js]"]
  node_user_model[("User model<br/>[user.model.js]")]
end

subgraph group_messages["Messaging"]
  node_message_route["Message routes<br/>[message.route.js]"]
  node_message_controller["Message controller"]
  node_message_service["Message service<br/>[message.service.js]"]
  node_message_repo["Message repository"]
  node_message_model[("Message model<br/>[message.model.js]")]
end

subgraph group_shared["Shared services"]
  node_validation["Body validation<br/>[validation.js]"]
  node_mongoose[("Mongo connection<br/>[mongoose.js]")]
  node_email["Email sender<br/>[nodemailer.js]"]
  node_google_verify["Google token check<br/>[google-auth.js]"]
  node_error_handler["Error handling<br/>[error.js]"]
end

node_client(("API client"))
node_mail_provider["Gmail SMTP"]
node_google_provider["Google identity"]

node_client -->|"sends requests"| node_server
node_server -->|"mounts at /auth"| node_auth_route
node_server -->|"mounts at /user"| node_user_route
node_server -->|"mounts at /message"| node_message_route
node_server -->|"loads connection"| node_mongoose
node_server -->|"handles errors"| node_error_handler
node_auth_route -->|"dispatches requests"| node_auth_controller
node_auth_controller -->|"validates bodies"| node_validation
node_auth_controller -->|"uses schemas"| node_auth_dto
node_auth_controller -->|"invokes workflows"| node_auth_service
node_auth_service -->|"checks and creates users"| node_auth_repo
node_auth_service -->|"manages OTP records"| node_otp_repo
node_auth_service -->|"updates users"| node_user_repo
node_auth_repo -->|"queries users"| node_user_model
node_user_repo -->|"updates records"| node_user_model
node_otp_repo -->|"uses OTP model"| node_otp_model
node_auth_service -->|"hashes passwords"| node_password_utils
node_auth_service -->|"generates tokens"| node_token_utils
node_auth_service -->|"sends OTP email"| node_email
node_email -.->|"sends mail"| node_mail_provider
node_auth_service -->|"verifies Google token"| node_google_verify
node_google_verify -.->|"checks identity token"| node_google_provider

click node_server "https://github.com/antonessam28/saraha-app/blob/main/src/main.js"
click node_auth_route "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/auth.route.js"
click node_auth_controller "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/controller/auth.controller.js"
click node_auth_dto "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/dto/auth.dto.js"
click node_auth_service "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/service/auth.service.js"
click node_auth_repo "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/repository/auth.repository.js"
click node_otp_repo "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/repository/otp.repsoitory.js"
click node_otp_model "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/model/otp.model.js"
click node_password_utils "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/utils/hash.js"
click node_token_utils "https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/utils/token.js"
click node_user_route "https://github.com/antonessam28/saraha-app/blob/main/src/app/user/user.route.js"
click node_user_controller "https://github.com/antonessam28/saraha-app/blob/main/src/app/user/controller/user.controller.js"
click node_user_service "https://github.com/antonessam28/saraha-app/blob/main/src/app/user/service/user.service.js"
click node_user_repo "https://github.com/antonessam28/saraha-app/blob/main/src/app/user/repository/user.repository.js"
click node_user_model "https://github.com/antonessam28/saraha-app/blob/main/src/app/user/model/user.model.js"
click node_message_route "https://github.com/antonessam28/saraha-app/blob/main/src/app/message/message.route.js"
click node_message_controller "https://github.com/antonessam28/saraha-app/blob/main/src/app/message/controller/message.controller.js"
click node_message_service "https://github.com/antonessam28/saraha-app/blob/main/src/app/message/service/message.service.js"
click node_message_repo "https://github.com/antonessam28/saraha-app/blob/main/src/app/message/repository/message.repository.js"
click node_message_model "https://github.com/antonessam28/saraha-app/blob/main/src/app/message/model/message.model.js"
click node_validation "https://github.com/antonessam28/saraha-app/blob/main/src/common/validation/validation.js"
click node_mongoose "https://github.com/antonessam28/saraha-app/blob/main/src/common/db/mongoose.js"
click node_email "https://github.com/antonessam28/saraha-app/blob/main/src/common/email/nodemailer.js"
click node_google_verify "https://github.com/antonessam28/saraha-app/blob/main/src/common/utils/google-auth.js"
click node_error_handler "https://github.com/antonessam28/saraha-app/blob/main/src/common/error/error.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_client toneBlue
class node_auth_route,node_auth_controller,node_auth_dto,node_auth_service,node_auth_repo,node_otp_repo,node_otp_model,node_password_utils,node_token_utils toneAmber
class node_user_route,node_user_controller,node_user_service,node_user_repo,node_user_model toneMint
class node_message_route,node_message_controller,node_message_service,node_message_repo,node_message_model toneRose
class node_validation,node_mongoose,node_email,node_google_verify,node_error_handler,node_mail_provider,node_google_provider toneIndigo
```

## Components

### HTTP runtime

- [Express server](https://github.com/antonessam28/saraha-app/blob/main/src/main.js): `src/main.js`

### Authentication

- [Auth routes](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/auth.route.js): `src/app/auth/auth.route.js`
- [Auth controller](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/controller/auth.controller.js): `src/app/auth/controller/auth.controller.js`
- [Auth schemas](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/dto/auth.dto.js): `src/app/auth/dto/auth.dto.js`
- [Auth workflows](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/service/auth.service.js): `src/app/auth/service/auth.service.js`
- [Auth repository](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/repository/auth.repository.js): `src/app/auth/repository/auth.repository.js`
- [OTP repository](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/repository/otp.repsoitory.js): `src/app/auth/repository/otp.repsoitory.js`
- [OTP model](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/model/otp.model.js): `src/app/auth/model/otp.model.js`
- [Password hashing](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/utils/hash.js): `src/app/auth/utils/hash.js`
- [Token generation](https://github.com/antonessam28/saraha-app/blob/main/src/app/auth/utils/token.js): `src/app/auth/utils/token.js`

### User domain

- [User routes](https://github.com/antonessam28/saraha-app/blob/main/src/app/user/user.route.js): `src/app/user/user.route.js`
- [User controller](https://github.com/antonessam28/saraha-app/blob/main/src/app/user/controller/user.controller.js): `src/app/user/controller/user.controller.js`
- [User service](https://github.com/antonessam28/saraha-app/blob/main/src/app/user/service/user.service.js): `src/app/user/service/user.service.js`
- [User repository](https://github.com/antonessam28/saraha-app/blob/main/src/app/user/repository/user.repository.js): `src/app/user/repository/user.repository.js`
- [User model](https://github.com/antonessam28/saraha-app/blob/main/src/app/user/model/user.model.js): `src/app/user/model/user.model.js`

### Messaging

- [Message routes](https://github.com/antonessam28/saraha-app/blob/main/src/app/message/message.route.js): `src/app/message/message.route.js`
- [Message controller](https://github.com/antonessam28/saraha-app/blob/main/src/app/message/controller/message.controller.js): `src/app/message/controller/message.controller.js`
- [Message service](https://github.com/antonessam28/saraha-app/blob/main/src/app/message/service/message.service.js): `src/app/message/service/message.service.js`
- [Message repository](https://github.com/antonessam28/saraha-app/blob/main/src/app/message/repository/message.repository.js): `src/app/message/repository/message.repository.js`
- [Message model](https://github.com/antonessam28/saraha-app/blob/main/src/app/message/model/message.model.js): `src/app/message/model/message.model.js`

### Shared services

- [Body validation](https://github.com/antonessam28/saraha-app/blob/main/src/common/validation/validation.js): `src/common/validation/validation.js`
- [Mongo connection](https://github.com/antonessam28/saraha-app/blob/main/src/common/db/mongoose.js): `src/common/db/mongoose.js`
- [Email sender](https://github.com/antonessam28/saraha-app/blob/main/src/common/email/nodemailer.js): `src/common/email/nodemailer.js`
- [Google token check](https://github.com/antonessam28/saraha-app/blob/main/src/common/utils/google-auth.js): `src/common/utils/google-auth.js`
- [Error handling](https://github.com/antonessam28/saraha-app/blob/main/src/common/error/error.js): `src/common/error/error.js`

### Other components

- **API client**
- **Gmail SMTP**
- **Google identity**

## Connections

- API client → Express server: sends requests (evidence: `src/main.js`)
- Express server → Auth routes: mounts at /auth (evidence: `src/main.js`)
- Express server → User routes: mounts at /user (evidence: `src/main.js`)
- Express server → Message routes: mounts at /message (evidence: `src/main.js`)
- Express server → Mongo connection: loads connection (evidence: `src/main.js`)
- Express server → Error handling: handles errors (evidence: `src/main.js`)
- Auth routes → Auth controller: dispatches requests (evidence: `src/app/auth/auth.route.js`)
- Auth controller → Body validation: validates bodies (evidence: `src/app/auth/controller/auth.controller.js`)
- Auth controller → Auth schemas: uses schemas (evidence: `src/app/auth/controller/auth.controller.js`)
- Auth controller → Auth workflows: invokes workflows (evidence: `src/app/auth/controller/auth.controller.js`)
- Auth workflows → Auth repository: checks and creates users (evidence: `src/app/auth/service/auth.service.js`)
- Auth workflows → OTP repository: manages OTP records (evidence: `src/app/auth/service/auth.service.js`)
- Auth workflows → User repository: updates users (evidence: `src/app/auth/service/auth.service.js`)
- Auth repository → User model: queries users (evidence: `src/app/auth/repository/auth.repository.js`)
- User repository → User model: updates records (evidence: `src/app/user/repository/user.repository.js`)
- OTP repository → OTP model: uses OTP model (evidence: `src/app/auth/repository/otp.repsoitory.js`)
- Auth workflows → Password hashing: hashes passwords (evidence: `src/app/auth/service/auth.service.js`)
- Auth workflows → Token generation: generates tokens (evidence: `src/app/auth/service/auth.service.js`)
- Auth workflows → Email sender: sends OTP email (evidence: `src/app/auth/service/auth.service.js`)
- Email sender → Gmail SMTP: sends mail
- Auth workflows → Google token check: verifies Google token (evidence: `src/app/auth/service/auth.service.js`)
- Google token check → Google identity: checks identity token
