# primetek-africa/hotel-booking-api architecture

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

- Interactive diagram: https://gitdiagram.com/primetek-africa/hotel-booking-api
- Repository: https://github.com/primetek-africa/hotel-booking-api

## Overview

This is an Express API for an ushering/booking application. Its evidenced request flow is client → mounted routes → API-key/JWT checks where required → controllers → authentication or user services → Sequelize models. The model catalog also defines room, booking, payment, conversation, and messaging domains, although their request handlers and business workflows are not shown. The README is empty; links for unsampled domain behavior are therefore omitted rather than inferred.

Main entry points: [`src/libraries/DBConnection.js`](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/libraries/DBConnection.js) (Sequelize connection), [`src/db/models/index.js`](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/index.js) (Model associations), [`src/api.js`](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/api.js) (Express API), [`src/services/authenticationServices.js`](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/services/authenticationServices.js) (Authentication service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_server["Express API<br/>[api.js]"]
  node_routes["Route mounting<br/>[index.js]"]
  node_config["Runtime configuration<br/>[config.js]"]
  node_errors["Error handling<br/>[errorHandler.js]"]
end

subgraph group_auth["Authentication"]
  node_authroutes["Authentication routes"]
  node_apikey["API-key check<br/>[apiAuthHandler.js]"]
  node_jwtcheck["JWT verification"]
  node_authcontroller["Login controller<br/>[login.js]"]
  node_authservice["Authentication service"]
  node_tokens["JWT signing<br/>[tokenSign.js]"]
end

subgraph group_users["User management"]
  node_useroutes["User routes<br/>[userRouter.js]"]
  node_usercontrollers["User controllers<br/>[index.js]"]
  node_userservice["User service<br/>[userServices.js]"]
end

subgraph group_data["Persistence and domains"]
  node_userrecords[("User records<br/>[user.js]")]
  node_phone[("Phone records<br/>[phone.js]")]
  node_roles[("User roles<br/>[userRole.js]")]
  node_statuses[("User statuses<br/>[userStatus.js]")]
  node_domainmodels[("Booking, room, payment, messaging models<br/>[booking.js]")]
  node_associations["Model associations<br/>[index.js]"]
  node_database[("Sequelize connection<br/>[DBConnection.js]")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_routes
node_server -->|"sets associations"| node_associations
node_server -->|"tests connection"| node_database
node_server -->|"installs handlers"| node_errors
node_routes -->|"mounts routes"| node_authroutes
node_routes -->|"mounts routes"| node_useroutes
node_authroutes -->|"checks key"| node_apikey
node_authroutes -->|"dispatches login"| node_authcontroller
node_useroutes -->|"checks key"| node_apikey
node_useroutes -->|"checks session"| node_jwtcheck
node_useroutes -->|"dispatches requests"| node_usercontrollers
node_authcontroller -->|"authenticates"| node_authservice
node_authservice -->|"reads and updates"| node_userrecords
node_authservice -->|"loads role"| node_roles
node_authservice -->|"loads status"| node_statuses
node_authservice -->|"signs token"| node_tokens
node_jwtcheck -->|"renews token"| node_tokens
node_usercontrollers -->|"delegates operations"| node_userservice
node_userservice -->|"manages users"| node_userrecords
node_userservice -->|"manages phones"| node_phone
node_userservice -->|"loads role data"| node_roles
node_userservice -->|"loads status data"| node_statuses
node_userrecords -->|"uses connection"| node_database
node_phone -->|"uses connection"| node_database
node_roles -->|"uses connection"| node_database
node_statuses -->|"uses connection"| node_database
node_domainmodels -->|"uses connection"| node_database
node_associations -->|"associates models"| node_userrecords
node_associations -->|"associates models"| node_roles
node_associations -->|"associates models"| node_statuses
node_associations -->|"associates models"| node_phone
node_associations -->|"associates domains"| node_domainmodels
node_database -->|"reads settings"| node_config
node_apikey -->|"reads API key"| node_config
node_jwtcheck -->|"reads JWT key"| node_config

click node_server "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/api.js"
click node_routes "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/routes/index.js"
click node_authroutes "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/routes/authenticationRouter.js"
click node_useroutes "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/routes/userRouter.js"
click node_apikey "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/middlewares/apiAuthHandler.js"
click node_jwtcheck "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/middlewares/tokenHandlers/authAppTokenHandler.js"
click node_authcontroller "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/controllers/authentication/login.js"
click node_authservice "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/services/authenticationServices.js"
click node_tokens "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/utils/auth/tokenSign.js"
click node_usercontrollers "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/controllers/user/index.js"
click node_userservice "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/services/userServices.js"
click node_userrecords "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/user.js"
click node_phone "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/phone.js"
click node_roles "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/userRole.js"
click node_statuses "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/userStatus.js"
click node_domainmodels "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/booking.js"
click node_associations "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/index.js"
click node_database "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/libraries/DBConnection.js"
click node_config "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/config/config.js"
click node_errors "https://github.com/primetek-africa/hotel-booking-api/blob/main/src/middlewares/errorHandler.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_routes,node_config,node_errors,node_client toneBlue
class node_authroutes,node_apikey,node_jwtcheck,node_authcontroller,node_authservice,node_tokens toneAmber
class node_useroutes,node_usercontrollers,node_userservice toneMint
class node_userrecords,node_phone,node_roles,node_statuses,node_domainmodels,node_associations,node_database toneRose
```

## Components

### API entry

- [Express API](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/api.js): `src/api.js`
- [Route mounting](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/routes/index.js): `src/routes/index.js`
- [Runtime configuration](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/config/config.js): `src/config/config.js`
- [Error handling](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/middlewares/errorHandler.js): `src/middlewares/errorHandler.js`

### Authentication

- [Authentication routes](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/routes/authenticationRouter.js): `src/routes/authenticationRouter.js`
- [API-key check](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/middlewares/apiAuthHandler.js): `src/middlewares/apiAuthHandler.js`
- [JWT verification](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/middlewares/tokenHandlers/authAppTokenHandler.js): `src/middlewares/tokenHandlers/authAppTokenHandler.js`
- [Login controller](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/controllers/authentication/login.js): `src/controllers/authentication/login.js`
- [Authentication service](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/services/authenticationServices.js): `src/services/authenticationServices.js`
- [JWT signing](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/utils/auth/tokenSign.js): `src/utils/auth/tokenSign.js`

### User management

- [User routes](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/routes/userRouter.js): `src/routes/userRouter.js`
- [User controllers](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/controllers/user/index.js): `src/controllers/user/index.js`
- [User service](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/services/userServices.js): `src/services/userServices.js`

### Persistence and domains

- [User records](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/user.js): `src/db/models/user.js`
- [Phone records](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/phone.js): `src/db/models/phone.js`
- [User roles](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/userRole.js): `src/db/models/userRole.js`
- [User statuses](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/userStatus.js): `src/db/models/userStatus.js`
- [Booking, room, payment, messaging models](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/booking.js): `src/db/models/booking.js`
- [Model associations](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/db/models/index.js): `src/db/models/index.js`
- [Sequelize connection](https://github.com/primetek-africa/hotel-booking-api/blob/main/src/libraries/DBConnection.js): `src/libraries/DBConnection.js`

### Other components

- **API client**

## Connections

- API client → Express API: sends requests
- Express API → Route mounting: mounts routes (evidence: `src/api.js`)
- Express API → Model associations: sets associations (evidence: `src/api.js`)
- Express API → Sequelize connection: tests connection (evidence: `src/api.js`)
- Express API → Error handling: installs handlers (evidence: `src/api.js`)
- Route mounting → Authentication routes: mounts routes (evidence: `src/routes/index.js`)
- Route mounting → User routes: mounts routes (evidence: `src/routes/index.js`)
- Authentication routes → API-key check: checks key (evidence: `src/routes/authenticationRouter.js`)
- Authentication routes → Login controller: dispatches login (evidence: `src/routes/authenticationRouter.js`)
- User routes → API-key check: checks key (evidence: `src/routes/userRouter.js`)
- User routes → JWT verification: checks session (evidence: `src/routes/userRouter.js`)
- User routes → User controllers: dispatches requests (evidence: `src/routes/userRouter.js`)
- Login controller → Authentication service: authenticates (evidence: `src/controllers/authentication/login.js`)
- Authentication service → User records: reads and updates (evidence: `src/services/authenticationServices.js`)
- Authentication service → User roles: loads role (evidence: `src/services/authenticationServices.js`)
- Authentication service → User statuses: loads status (evidence: `src/services/authenticationServices.js`)
- Authentication service → JWT signing: signs token (evidence: `src/services/authenticationServices.js`)
- JWT verification → JWT signing: renews token (evidence: `src/middlewares/tokenHandlers/authAppTokenHandler.js`)
- User controllers → User service: delegates operations (evidence: `src/controllers/user/index.js`)
- User service → User records: manages users (evidence: `src/services/userServices.js`)
- User service → Phone records: manages phones (evidence: `src/services/userServices.js`)
- User service → User roles: loads role data (evidence: `src/services/userServices.js`)
- User service → User statuses: loads status data (evidence: `src/services/userServices.js`)
- User records → Sequelize connection: uses connection (evidence: `src/db/models/user.js`)
- Phone records → Sequelize connection: uses connection (evidence: `src/db/models/phone.js`)
- User roles → Sequelize connection: uses connection (evidence: `src/db/models/userRole.js`)
- User statuses → Sequelize connection: uses connection (evidence: `src/db/models/userStatus.js`)
- Booking, room, payment, messaging models → Sequelize connection: uses connection (evidence: `src/db/models/booking.js`)
- Model associations → User records: associates models (evidence: `src/db/models/index.js`)
- Model associations → User roles: associates models (evidence: `src/db/models/index.js`)
- Model associations → User statuses: associates models (evidence: `src/db/models/index.js`)
- Model associations → Phone records: associates models (evidence: `src/db/models/index.js`)
- Model associations → Booking, room, payment, messaging models: associates domains (evidence: `src/db/models/index.js`)
- Sequelize connection → Runtime configuration: reads settings (evidence: `src/libraries/DBConnection.js`)
- API-key check → Runtime configuration: reads API key (evidence: `src/middlewares/apiAuthHandler.js`)
- JWT verification → Runtime configuration: reads JWT key (evidence: `src/middlewares/tokenHandlers/authAppTokenHandler.js`)
