# rizky-iqbal36/crud-api architecture

> Architecture diagram of the GitHub repository rizky-iqbal36/crud-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/rizky-iqbal36/crud-api
- Repository: https://github.com/rizky-iqbal36/crud-api

## Overview

This NestJS CRUD API supports registration and login, authenticated user self-service, admin user management, health checks, and user seeding. The main request flow is HTTP client → controller → user service → repository → MongoDB; authentication services and request middleware support protected routes. The graph also shows application-wide response and exception handling. Source excerpts establish the controller, service, repository, and module wiring; seeding and MongoDB deployment details are based on README documentation, so some relationships are not shown at implementation level.

Main entry points: [`src/services/user.service.ts`](https://github.com/rizky-iqbal36/crud-api/blob/main/src/services/user.service.ts) (User workflows), [`src/controllers/api/admin.controller.ts`](https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/api/admin.controller.ts) (Admin routes), [`src/app.module.ts`](https://github.com/rizky-iqbal36/crud-api/blob/main/src/app.module.ts) (App module), [`src/controllers/base.controller.ts`](https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/base.controller.ts) (Request validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_user_routes["User routes<br/>[user.controller.ts]"]
  node_admin_routes["Admin routes"]
  node_health["Health check"]
  node_validation["Request validation<br/>[base.controller.ts]"]
  node_schema["User schemas<br/>[user.schema.ts]"]
end

subgraph group_identity["Identity and Access"]
  node_auth_routes["Auth routes<br/>[auth.controller.ts]"]
  node_auth_middleware["Auth middleware<br/>[auth.middleware.ts]"]
  node_admin_guard["Admin guard<br/>[admin.guard.ts]"]
  node_auth_service["Token and passwords<br/>[auth.service.ts]"]
end

subgraph group_users["User Domain"]
  node_user_service["User workflows<br/>[user.service.ts]"]
  node_user_repository["User repository<br/>[user.repository.ts]"]
  node_user_model["User model<br/>[user.model.ts]"]
  node_seeding["User seeding"]
  node_seeder_entry["Seeder entry<br/>[seeder.ts]"]
end

subgraph group_runtime["Runtime and Data"]
  node_mongo[("MongoDB")]
  node_app_module["App module<br/>[app.module.ts]"]
  node_bootstrap["HTTP bootstrap<br/>[main.ts]"]
  node_config["Application config<br/>[appConfig.ts]"]
  node_response["Response interceptor"]
  node_exceptions["Exception handling"]
end

node_client(("API client"))

node_client -->|"registers or logs in"| node_auth_routes
node_client -->|"requests user data"| node_user_routes
node_client -->|"manages users"| node_admin_routes
node_client -->|"checks health"| node_health
node_auth_routes -->|"validates input"| node_validation
node_user_routes -->|"validates input"| node_validation
node_admin_routes -->|"validates input"| node_validation
node_validation -->|"uses schemas"| node_schema
node_auth_routes -->|"calls workflows"| node_user_service
node_user_routes -->|"calls workflows"| node_user_service
node_admin_routes -->|"calls workflows"| node_user_service
node_user_service -->|"queries users"| node_user_repository
node_user_service -->|"hashes and signs"| node_auth_service
node_user_repository -->|"uses model"| node_user_model
node_user_model -.->|"persists user data"| node_mongo
node_app_module -->|"registers middleware"| node_auth_middleware
node_admin_routes -->|"guards routes"| node_admin_guard
node_bootstrap -->|"starts application"| node_app_module
node_app_module -->|"registers interceptor"| node_response
node_app_module -->|"registers filter"| node_exceptions
node_bootstrap -->|"reads port"| node_config
node_seeder_entry -.->|"runs seeding"| node_seeding
node_seeding -.->|"seeds users"| node_mongo

click node_auth_routes "https://github.com/rizky-iqbal36/crud-api/blob/main/src/authentication/controller/auth.controller.ts"
click node_user_routes "https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/api/user.controller.ts"
click node_admin_routes "https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/api/admin.controller.ts"
click node_health "https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/health-check.controller.ts"
click node_validation "https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/base.controller.ts"
click node_schema "https://github.com/rizky-iqbal36/crud-api/blob/main/src/schema/requestvalidators/user.schema.ts"
click node_auth_middleware "https://github.com/rizky-iqbal36/crud-api/blob/main/src/authentication/middleware/auth.middleware.ts"
click node_admin_guard "https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/guard/admin.guard.ts"
click node_auth_service "https://github.com/rizky-iqbal36/crud-api/blob/main/src/authentication/service/auth.service.ts"
click node_user_service "https://github.com/rizky-iqbal36/crud-api/blob/main/src/services/user.service.ts"
click node_user_repository "https://github.com/rizky-iqbal36/crud-api/blob/main/src/repositories/user.repository.ts"
click node_user_model "https://github.com/rizky-iqbal36/crud-api/blob/main/src/database/models/user.model.ts"
click node_seeding "https://github.com/rizky-iqbal36/crud-api/tree/main/src/database/seeds"
click node_seeder_entry "https://github.com/rizky-iqbal36/crud-api/blob/main/resources/seeder.ts"
click node_app_module "https://github.com/rizky-iqbal36/crud-api/blob/main/src/app.module.ts"
click node_bootstrap "https://github.com/rizky-iqbal36/crud-api/blob/main/src/main.ts"
click node_config "https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/config/appConfig.ts"
click node_response "https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/utils/interceptor/response.interceptor.ts"
click node_exceptions "https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/exception/http-exception.filter.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_user_routes,node_admin_routes,node_health,node_validation,node_schema,node_client toneBlue
class node_auth_routes,node_auth_middleware,node_admin_guard,node_auth_service toneAmber
class node_user_service,node_user_repository,node_user_model,node_seeding,node_seeder_entry toneMint
class node_mongo,node_app_module,node_bootstrap,node_config,node_response,node_exceptions toneRose
```

## Components

### HTTP API

- [User routes](https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/api/user.controller.ts): `src/controllers/api/user.controller.ts`
- [Admin routes](https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/api/admin.controller.ts): `src/controllers/api/admin.controller.ts`
- [Health check](https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/health-check.controller.ts): `src/controllers/health-check.controller.ts`
- [Request validation](https://github.com/rizky-iqbal36/crud-api/blob/main/src/controllers/base.controller.ts): `src/controllers/base.controller.ts`
- [User schemas](https://github.com/rizky-iqbal36/crud-api/blob/main/src/schema/requestvalidators/user.schema.ts): `src/schema/requestvalidators/user.schema.ts`

### Identity and Access

- [Auth routes](https://github.com/rizky-iqbal36/crud-api/blob/main/src/authentication/controller/auth.controller.ts): `src/authentication/controller/auth.controller.ts`
- [Auth middleware](https://github.com/rizky-iqbal36/crud-api/blob/main/src/authentication/middleware/auth.middleware.ts): `src/authentication/middleware/auth.middleware.ts`
- [Admin guard](https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/guard/admin.guard.ts): `src/app/guard/admin.guard.ts`
- [Token and passwords](https://github.com/rizky-iqbal36/crud-api/blob/main/src/authentication/service/auth.service.ts): `src/authentication/service/auth.service.ts`

### User Domain

- [User workflows](https://github.com/rizky-iqbal36/crud-api/blob/main/src/services/user.service.ts): `src/services/user.service.ts`
- [User repository](https://github.com/rizky-iqbal36/crud-api/blob/main/src/repositories/user.repository.ts): `src/repositories/user.repository.ts`
- [User model](https://github.com/rizky-iqbal36/crud-api/blob/main/src/database/models/user.model.ts): `src/database/models/user.model.ts`
- [User seeding](https://github.com/rizky-iqbal36/crud-api/tree/main/src/database/seeds): `src/database/seeds`
- [Seeder entry](https://github.com/rizky-iqbal36/crud-api/blob/main/resources/seeder.ts): `resources/seeder.ts`

### Runtime and Data

- **MongoDB**
- [App module](https://github.com/rizky-iqbal36/crud-api/blob/main/src/app.module.ts): `src/app.module.ts`
- [HTTP bootstrap](https://github.com/rizky-iqbal36/crud-api/blob/main/src/main.ts): `src/main.ts`
- [Application config](https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/config/appConfig.ts): `src/app/config/appConfig.ts`
- [Response interceptor](https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/utils/interceptor/response.interceptor.ts): `src/app/utils/interceptor/response.interceptor.ts`
- [Exception handling](https://github.com/rizky-iqbal36/crud-api/blob/main/src/app/exception/http-exception.filter.ts): `src/app/exception/http-exception.filter.ts`

### Other components

- **API client**

## Connections

- API client → Auth routes: registers or logs in (evidence: `README.md`)
- API client → User routes: requests user data (evidence: `README.md`)
- API client → Admin routes: manages users (evidence: `README.md`)
- API client → Health check: checks health (evidence: `README.md`)
- Auth routes → Request validation: validates input (evidence: `src/authentication/controller/auth.controller.ts`)
- User routes → Request validation: validates input (evidence: `src/controllers/api/user.controller.ts`)
- Admin routes → Request validation: validates input (evidence: `src/controllers/api/admin.controller.ts`)
- Request validation → User schemas: uses schemas (evidence: `src/controllers/base.controller.ts`)
- Auth routes → User workflows: calls workflows (evidence: `src/authentication/controller/auth.controller.ts`)
- User routes → User workflows: calls workflows (evidence: `src/controllers/api/user.controller.ts`)
- Admin routes → User workflows: calls workflows (evidence: `src/controllers/api/admin.controller.ts`)
- User workflows → User repository: queries users (evidence: `src/services/user.service.ts`)
- User workflows → Token and passwords: hashes and signs (evidence: `src/services/user.service.ts`)
- User repository → User model: uses model (evidence: `src/repositories/user.repository.ts`)
- User model → MongoDB: persists user data (evidence: `README.md`)
- App module → Auth middleware: registers middleware (evidence: `src/app.module.ts`)
- Admin routes → Admin guard: guards routes (evidence: `src/controllers/api/admin.controller.ts`)
- HTTP bootstrap → App module: starts application (evidence: `src/main.ts`)
- App module → Response interceptor: registers interceptor (evidence: `src/app.module.ts`)
- App module → Exception handling: registers filter (evidence: `src/app.module.ts`)
- HTTP bootstrap → Application config: reads port (evidence: `src/main.ts`)
- Seeder entry → User seeding: runs seeding (evidence: `README.md`)
- User seeding → MongoDB: seeds users (evidence: `README.md`)
