# riajuddinrumman/shebabook architecture

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

- Interactive diagram: https://gitdiagram.com/riajuddinrumman/shebabook
- Repository: https://github.com/riajuddinrumman/shebabook

## Overview

ShebaBook is a NestJS service-booking API. Customers register or log in, receive a JWT, then submit an appointment request; the booking service derives the end time, checks the listing and booking window, and checks provider/customer conflicts before writing. PostgreSQL constraints provide a final concurrency-safe safeguard. The graph also shows authentication guards and the liveness route. Provider discovery and service-listing management are described as product context, but no corresponding implemented routes are shown. Booking internals are supported by excerpts; other links rely on the README or SOURCE INDEX.

Main entry points: [`src/bookings/bookings.controller.ts`](https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/bookings.controller.ts) (Booking endpoint), [`src/bookings/booking.service.ts`](https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/booking.service.ts) (Booking rules), [`src/auth/auth.service.ts`](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/auth.service.ts) (Register and login), [`src/app.module.ts`](https://github.com/riajuddinrumman/shebabook/blob/main/src/app.module.ts) (App module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["API application"]
  node_appmodule["App module<br/>[app.module.ts]"]
  node_health["Liveness route<br/>[app.controller.ts]"]
  node_healthservice["Health response<br/>[app.service.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authcontroller["Auth endpoints<br/>[auth.controller.ts]"]
  node_authservice["Register and login<br/>[auth.service.ts]"]
  node_password["Password hashing<br/>[password.ts]"]
  node_token["JWT service<br/>[token.service.ts]"]
  node_jwtguard["JWT guard<br/>[jwt-auth.guard.ts]"]
  node_rolesguard["Role guard<br/>[roles.guard.ts]"]
  node_currentuser["Current identity"]
end

subgraph group_booking["Booking rules"]
  node_bookingcontroller["Booking endpoint"]
  node_bookingservice["Booking rules<br/>[booking.service.ts]"]
  node_bookingdto["Request validation"]
  node_overlap["Interval calculation<br/>[overlap.ts]"]
  node_slotconstraint["Constraint mapping<br/>[slot-constraint.ts]"]
end

subgraph group_persistence["Persistence"]
  node_prisma["Prisma data access<br/>[prisma.service.ts]"]
  node_postgres[("PostgreSQL")]
end

node_customer(("Customer"))
node_jwtprovider["JWT provider"]

node_appmodule -->|"wires"| node_authcontroller
node_appmodule -->|"wires"| node_bookingcontroller
node_appmodule -->|"registers"| node_health
node_health -->|"calls"| node_healthservice
node_customer -->|"registers or logs in"| node_authcontroller
node_authcontroller -->|"delegates"| node_authservice
node_authservice -->|"hashes and verifies"| node_password
node_authservice -->|"reads and creates users"| node_prisma
node_authservice -->|"signs token"| node_token
node_token -->|"signs and verifies"| node_jwtprovider
node_customer -->|"requests appointment"| node_bookingcontroller
node_bookingcontroller -->|"guards request"| node_jwtguard
node_bookingcontroller -->|"checks role"| node_rolesguard
node_bookingcontroller -->|"gets identity"| node_currentuser
node_bookingcontroller -->|"accepts request"| node_bookingdto
node_jwtguard -->|"verifies token"| node_token
node_rolesguard -->|"authorizes role"| node_customer
node_bookingcontroller -->|"creates booking"| node_bookingservice
node_bookingservice -->|"queries and writes"| node_prisma
node_bookingservice -->|"derives end time"| node_overlap
node_bookingservice -->|"maps constraint failure"| node_slotconstraint
node_prisma -->|"persists data"| node_postgres
node_postgres -->|"rejects overlapping writes"| node_bookingservice

click node_appmodule "https://github.com/riajuddinrumman/shebabook/blob/main/src/app.module.ts"
click node_health "https://github.com/riajuddinrumman/shebabook/blob/main/src/app.controller.ts"
click node_healthservice "https://github.com/riajuddinrumman/shebabook/blob/main/src/app.service.ts"
click node_authcontroller "https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/auth.controller.ts"
click node_authservice "https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/auth.service.ts"
click node_password "https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/password.ts"
click node_token "https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/token.service.ts"
click node_jwtguard "https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/jwt-auth.guard.ts"
click node_rolesguard "https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/roles.guard.ts"
click node_currentuser "https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/current-user.decorator.ts"
click node_bookingcontroller "https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/bookings.controller.ts"
click node_bookingservice "https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/booking.service.ts"
click node_bookingdto "https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/dto/create-booking.dto.ts"
click node_overlap "https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/overlap.ts"
click node_slotconstraint "https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/slot-constraint.ts"
click node_prisma "https://github.com/riajuddinrumman/shebabook/blob/main/src/prisma/prisma.service.ts"

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_appmodule,node_health,node_healthservice toneBlue
class node_authcontroller,node_authservice,node_password,node_token,node_jwtguard,node_rolesguard,node_currentuser toneAmber
class node_bookingcontroller,node_bookingservice,node_bookingdto,node_overlap,node_slotconstraint toneMint
class node_prisma,node_postgres toneRose
class node_customer,node_jwtprovider toneIndigo
```

## Components

### API application

- [App module](https://github.com/riajuddinrumman/shebabook/blob/main/src/app.module.ts): `src/app.module.ts`
- [Liveness route](https://github.com/riajuddinrumman/shebabook/blob/main/src/app.controller.ts): `src/app.controller.ts`
- [Health response](https://github.com/riajuddinrumman/shebabook/blob/main/src/app.service.ts): `src/app.service.ts`

### Identity and access

- [Auth endpoints](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Register and login](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [Password hashing](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/password.ts): `src/auth/password.ts`
- [JWT service](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/token.service.ts): `src/auth/token.service.ts`
- [JWT guard](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/jwt-auth.guard.ts): `src/auth/jwt-auth.guard.ts`
- [Role guard](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/roles.guard.ts): `src/auth/roles.guard.ts`
- [Current identity](https://github.com/riajuddinrumman/shebabook/blob/main/src/auth/current-user.decorator.ts): `src/auth/current-user.decorator.ts`

### Booking rules

- [Booking endpoint](https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/bookings.controller.ts): `src/bookings/bookings.controller.ts`
- [Booking rules](https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/booking.service.ts): `src/bookings/booking.service.ts`
- [Request validation](https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/dto/create-booking.dto.ts): `src/bookings/dto/create-booking.dto.ts`
- [Interval calculation](https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/overlap.ts): `src/bookings/overlap.ts`
- [Constraint mapping](https://github.com/riajuddinrumman/shebabook/blob/main/src/bookings/slot-constraint.ts): `src/bookings/slot-constraint.ts`

### Persistence

- [Prisma data access](https://github.com/riajuddinrumman/shebabook/blob/main/src/prisma/prisma.service.ts): `src/prisma/prisma.service.ts`
- **PostgreSQL**

### Other components

- **Customer**
- **JWT provider**

## Connections

- App module → Auth endpoints: wires
- App module → Booking endpoint: wires (evidence: `src/app.module.ts`)
- App module → Liveness route: registers (evidence: `src/app.module.ts`)
- Liveness route → Health response: calls (evidence: `src/app.controller.ts`)
- Customer → Auth endpoints: registers or logs in (evidence: `README.md`)
- Auth endpoints → Register and login: delegates (evidence: `src/auth/auth.controller.ts`)
- Register and login → Password hashing: hashes and verifies (evidence: `src/auth/auth.service.ts`)
- Register and login → Prisma data access: reads and creates users (evidence: `src/auth/auth.service.ts`)
- Register and login → JWT service: signs token (evidence: `src/auth/auth.service.ts`)
- JWT service → JWT provider: signs and verifies (evidence: `src/auth/token.service.ts`)
- Customer → Booking endpoint: requests appointment (evidence: `README.md`)
- Booking endpoint → JWT guard: guards request (evidence: `src/bookings/bookings.controller.ts`)
- Booking endpoint → Role guard: checks role (evidence: `src/bookings/bookings.controller.ts`)
- Booking endpoint → Current identity: gets identity (evidence: `src/bookings/bookings.controller.ts`)
- Booking endpoint → Request validation: accepts request (evidence: `src/bookings/bookings.controller.ts`)
- JWT guard → JWT service: verifies token (evidence: `src/auth/jwt-auth.guard.ts`)
- Role guard → Customer: authorizes role (evidence: `README.md`)
- Booking endpoint → Booking rules: creates booking (evidence: `src/bookings/bookings.controller.ts`)
- Booking rules → Prisma data access: queries and writes (evidence: `src/bookings/booking.service.ts`)
- Booking rules → Interval calculation: derives end time (evidence: `src/bookings/booking.service.ts`)
- Booking rules → Constraint mapping: maps constraint failure (evidence: `src/bookings/booking.service.ts`)
- Prisma data access → PostgreSQL: persists data (evidence: `src/prisma/prisma.service.ts`)
- PostgreSQL → Booking rules: rejects overlapping writes (evidence: `README.md`)
