# omarhss-dev/prj-gatekeeper architecture

> Architecture diagram of the GitHub repository omarhss-dev/prj-gatekeeper, 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/omarhss-dev/prj-gatekeeper
- Repository: https://github.com/omarhss-dev/prj-gatekeeper

## Overview

Gatekeeper is a NestJS API with authentication, user profiles, and health checks backed by PostgreSQL. The visible user workflow is register or log in through HTTP, validate the request, apply authentication rules, and persist or retrieve user data; profile requests additionally verify a JWT. The repository contains event and reservation migrations and domain error codes, but no corresponding runtime modules appear in the tree, so those capabilities are not mapped as implemented workflows. Edges reflect the excerpts and SOURCE INDEX; unsampled behavior is omitted.

Main entry points: [`apps/api/src/app.module.js`](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/app.module.js) (Application wiring), [`apps/api/src/modules/auth/http/auth.controller.js`](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/auth.controller.js) (Auth endpoints), [`apps/api/src/modules/auth/core/auth.service.js`](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/core/auth.service.js) (Auth rules), [`apps/api/src/modules/auth/http/me.controller.js`](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/me.controller.js) (Profile endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_bootstrap["Server bootstrap<br/>[main.js]"]
  node_app["Application wiring<br/>[app.module.js]"]
  node_validation["Request validation"]
end

subgraph group_auth["Authentication"]
  node_auth_http["Auth endpoints<br/>[auth.controller.js]"]
  node_profile_http["Profile endpoint<br/>[me.controller.js]"]
  node_jwt_guard["JWT guard<br/>[jwt-auth.guard.js]"]
  node_auth_service["Auth rules<br/>[auth.service.js]"]
  node_token_service["Token service<br/>[token.service.js]"]
  node_users_repo["User repository"]
end

subgraph group_platform["Platform services"]
  node_database_module["Database module<br/>[database.module.js]"]
  node_pool["PostgreSQL pool<br/>[pool.js]"]
  node_errors["HTTP error mapping"]
end

subgraph group_health["Health checks"]
  node_health_http["Health endpoints"]
  node_health_service["Readiness check<br/>[health.service.js]"]
  node_ping["Database ping<br/>[ping.js]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_bootstrap
node_bootstrap -->|"starts app"| node_app
node_app -->|"registers module"| node_auth_http
node_app -->|"registers module"| node_health_http
node_app -->|"configures database"| node_database_module
node_app -->|"installs filter"| node_errors
node_auth_http -->|"validates input"| node_validation
node_auth_http -->|"calls auth rules"| node_auth_service
node_auth_http -.->|"returns auth result"| node_client
node_profile_http -->|"guards profile"| node_jwt_guard
node_profile_http -->|"loads profile"| node_auth_service
node_jwt_guard -->|"verifies token"| node_token_service
node_auth_service -->|"reads and writes users"| node_users_repo
node_auth_service -->|"signs token"| node_token_service
node_database_module -->|"creates pool"| node_pool
node_users_repo -->|"queries users"| node_postgres
node_health_http -->|"checks readiness"| node_health_service
node_health_service -->|"checks database"| node_ping
node_ping -.->|"tests connection"| node_postgres
node_errors -->|"returns problem response"| node_client

click node_bootstrap "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/main.js"
click node_app "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/app.module.js"
click node_validation "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/common/validation/zod-validation.pipe.js"
click node_auth_http "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/auth.controller.js"
click node_profile_http "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/me.controller.js"
click node_jwt_guard "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/jwt-auth.guard.js"
click node_auth_service "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/core/auth.service.js"
click node_token_service "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/core/token.service.js"
click node_users_repo "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/core/users.repository.js"
click node_database_module "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/database/database.module.js"
click node_pool "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/database/pool.js"
click node_errors "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/common/errors/all-exceptions.filter.js"
click node_health_http "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/health/health.controller.js"
click node_health_service "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/health/health.service.js"
click node_ping "https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/database/ping.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_bootstrap,node_app,node_validation,node_client toneBlue
class node_auth_http,node_profile_http,node_jwt_guard,node_auth_service,node_token_service,node_users_repo,node_postgres toneAmber
class node_database_module,node_pool,node_errors toneMint
class node_health_http,node_health_service,node_ping toneRose
```

## Components

### API entry

- [Server bootstrap](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/main.js): `apps/api/src/main.js`
- [Application wiring](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/app.module.js): `apps/api/src/app.module.js`
- [Request validation](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/common/validation/zod-validation.pipe.js): `apps/api/src/common/validation/zod-validation.pipe.js`

### Authentication

- [Auth endpoints](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/auth.controller.js): `apps/api/src/modules/auth/http/auth.controller.js`
- [Profile endpoint](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/me.controller.js): `apps/api/src/modules/auth/http/me.controller.js`
- [JWT guard](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/http/jwt-auth.guard.js): `apps/api/src/modules/auth/http/jwt-auth.guard.js`
- [Auth rules](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/core/auth.service.js): `apps/api/src/modules/auth/core/auth.service.js`
- [Token service](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/core/token.service.js): `apps/api/src/modules/auth/core/token.service.js`
- [User repository](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/auth/core/users.repository.js): `apps/api/src/modules/auth/core/users.repository.js`

### Platform services

- [Database module](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/database/database.module.js): `apps/api/src/database/database.module.js`
- [PostgreSQL pool](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/database/pool.js): `apps/api/src/database/pool.js`
- [HTTP error mapping](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/common/errors/all-exceptions.filter.js): `apps/api/src/common/errors/all-exceptions.filter.js`

### Health checks

- [Health endpoints](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/health/health.controller.js): `apps/api/src/modules/health/health.controller.js`
- [Readiness check](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/modules/health/health.service.js): `apps/api/src/modules/health/health.service.js`
- [Database ping](https://github.com/omarhss-dev/prj-gatekeeper/blob/main/apps/api/src/database/ping.js): `apps/api/src/database/ping.js`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → Server bootstrap: sends requests
- Server bootstrap → Application wiring: starts app (evidence: `apps/api/src/main.js`)
- Application wiring → Auth endpoints: registers module (evidence: `apps/api/src/app.module.js`)
- Application wiring → Health endpoints: registers module (evidence: `apps/api/src/app.module.js`)
- Application wiring → Database module: configures database (evidence: `apps/api/src/app.module.js`)
- Application wiring → HTTP error mapping: installs filter (evidence: `apps/api/src/app.module.js`)
- Auth endpoints → Request validation: validates input (evidence: `apps/api/src/modules/auth/http/auth.controller.js`)
- Auth endpoints → Auth rules: calls auth rules (evidence: `apps/api/src/modules/auth/http/auth.controller.js`)
- Auth endpoints → API client: returns auth result
- Profile endpoint → JWT guard: guards profile (evidence: `apps/api/src/modules/auth/http/me.controller.js`)
- Profile endpoint → Auth rules: loads profile (evidence: `apps/api/src/modules/auth/http/me.controller.js`)
- JWT guard → Token service: verifies token (evidence: `apps/api/src/modules/auth/http/jwt-auth.guard.js`)
- Auth rules → User repository: reads and writes users (evidence: `apps/api/src/modules/auth/core/auth.service.js`)
- Auth rules → Token service: signs token (evidence: `apps/api/src/modules/auth/core/auth.service.js`)
- Database module → PostgreSQL pool: creates pool (evidence: `apps/api/src/database/database.module.js`)
- User repository → PostgreSQL: queries users (evidence: `apps/api/src/modules/auth/core/users.repository.js`)
- Health endpoints → Readiness check: checks readiness (evidence: `apps/api/src/modules/health/health.controller.js`)
- Readiness check → Database ping: checks database (evidence: `apps/api/src/modules/health/health.service.js`)
- Database ping → PostgreSQL: tests connection
- HTTP error mapping → API client: returns problem response (evidence: `apps/api/src/common/errors/all-exceptions.filter.js`)
