# danielshaitovs/user-service architecture

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

- Interactive diagram: https://gitdiagram.com/danielshaitovs/user-service
- Repository: https://github.com/danielshaitovs/user-service

## Overview

This is a NestJS user and access-management API, despite the starter-template README. Its principal workflow is an HTTP request entering a controller, passing to a domain pipeline for user, role, or store operations, and using services for domain work; sign-in additionally resolves assigned roles and stores before issuing a JWT. The graph preserves those domain branches and the role-permission and user-assignment capabilities. Several service implementations and module registrations were not sampled, so their internal links are omitted rather than inferred.

Main entry points: [`src/app.module.ts`](https://github.com/danielshaitovs/user-service/blob/main/src/app.module.ts) (Application wiring), [`src/user/role.pipeline.ts`](https://github.com/danielshaitovs/user-service/blob/main/src/user/role.pipeline.ts) (User-role operations), [`src/auth/auth.service.ts`](https://github.com/danielshaitovs/user-service/blob/main/src/auth/auth.service.ts) (Sign-in service), [`src/store/store.pipeline.ts`](https://github.com/danielshaitovs/user-service/blob/main/src/store/store.pipeline.ts) (Store operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_bootstrap["HTTP bootstrap<br/>[main.ts]"]
  node_application["Application wiring<br/>[app.module.ts]"]
  node_postgres[("PostgreSQL")]
  node_audit["User audit<br/>[audit.service.ts]"]
  node_cache_service["Shared cache<br/>[cache.service.ts]"]
end

subgraph group_identity["Authentication"]
  node_auth_controller["Auth endpoints<br/>[auth.controller.ts]"]
  node_auth_service["Sign-in service<br/>[auth.service.ts]"]
  node_auth_cache["Token cache<br/>[cache.service.ts]"]
end

subgraph group_access["Roles and permissions"]
  node_role_controller["Role endpoints<br/>[role.controller.ts]"]
  node_role_pipeline["Role operations<br/>[role.pipeline.ts]"]
  node_role_services["Role domain services"]
  node_permission_controller["Permission endpoints"]
  node_permission_pipeline["Permission operations"]
end

subgraph group_accounts["Users and stores"]
  node_user_controller["User endpoints<br/>[user.controller.ts]"]
  node_user_pipeline["User operations<br/>[user.pipeline.ts]"]
  node_user_services["User domain services"]
  node_user_role_controller["User-role endpoints"]
  node_user_role_pipeline["User-role operations<br/>[role.pipeline.ts]"]
  node_user_role_services["User-role services<br/>[role.service.ts]"]
  node_user_store_services["User-store services<br/>[store.service.ts]"]
  node_store_controller["Store endpoints"]
  node_store_pipeline["Store operations<br/>[store.pipeline.ts]"]
  node_store_services["Store domain services"]
end

node_client(("API client"))

node_client -->|"sends HTTP"| node_bootstrap
node_bootstrap -->|"creates app"| node_application
node_application -->|"configures database"| node_postgres
node_application -->|"registers module"| node_auth_controller
node_application -->|"registers module"| node_user_controller
node_application -->|"registers module"| node_role_controller
node_application -->|"registers module"| node_store_controller
node_auth_controller -->|"delegates sign-in"| node_auth_service
node_auth_service -->|"loads permissions"| node_user_role_pipeline
node_auth_service -->|"loads assigned stores"| node_user_store_services
node_auth_service -->|"stores token"| node_auth_cache
node_user_controller -->|"delegates requests"| node_user_pipeline
node_user_pipeline -->|"delegates domain work"| node_user_services
node_user_pipeline -->|"records changes"| node_audit
node_user_role_controller -->|"delegates requests"| node_user_role_pipeline
node_user_role_pipeline -->|"manages assignments"| node_user_role_services
node_user_role_pipeline -->|"records assignments"| node_audit
node_user_role_pipeline -->|"caches permissions"| node_cache_service
node_role_controller -->|"delegates requests"| node_role_pipeline
node_role_pipeline -->|"delegates domain work"| node_role_services
node_permission_controller -->|"delegates requests"| node_permission_pipeline
node_store_controller -->|"delegates requests"| node_store_pipeline
node_store_pipeline -->|"delegates domain work"| node_store_services
node_store_pipeline -->|"records changes"| node_audit
node_store_pipeline -->|"caches store data"| node_cache_service
node_auth_cache -->|"uses shared cache"| node_cache_service

click node_bootstrap "https://github.com/danielshaitovs/user-service/blob/main/src/main.ts"
click node_application "https://github.com/danielshaitovs/user-service/blob/main/src/app.module.ts"
click node_auth_controller "https://github.com/danielshaitovs/user-service/blob/main/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/danielshaitovs/user-service/blob/main/src/auth/auth.service.ts"
click node_auth_cache "https://github.com/danielshaitovs/user-service/blob/main/src/auth/cache.service.ts"
click node_user_controller "https://github.com/danielshaitovs/user-service/blob/main/src/user/controllers/user.controller.ts"
click node_user_pipeline "https://github.com/danielshaitovs/user-service/blob/main/src/user/user.pipeline.ts"
click node_user_services "https://github.com/danielshaitovs/user-service/tree/main/src/user/services/user"
click node_user_role_controller "https://github.com/danielshaitovs/user-service/blob/main/src/user/controllers/roles.controller.ts"
click node_user_role_pipeline "https://github.com/danielshaitovs/user-service/blob/main/src/user/role.pipeline.ts"
click node_user_role_services "https://github.com/danielshaitovs/user-service/blob/main/src/user/services/role/role.service.ts"
click node_user_store_services "https://github.com/danielshaitovs/user-service/blob/main/src/user/services/store/store.service.ts"
click node_audit "https://github.com/danielshaitovs/user-service/blob/main/src/user/services/audit.service.ts"
click node_role_controller "https://github.com/danielshaitovs/user-service/blob/main/src/role/controllers/role.controller.ts"
click node_role_pipeline "https://github.com/danielshaitovs/user-service/blob/main/src/role/role.pipeline.ts"
click node_role_services "https://github.com/danielshaitovs/user-service/tree/main/src/role/services"
click node_permission_controller "https://github.com/danielshaitovs/user-service/blob/main/src/role/permission/controllers/permission.controller.ts"
click node_permission_pipeline "https://github.com/danielshaitovs/user-service/blob/main/src/role/permission/permission.pipeline.ts"
click node_store_controller "https://github.com/danielshaitovs/user-service/blob/main/src/store/controllers/store.controller.ts"
click node_store_pipeline "https://github.com/danielshaitovs/user-service/blob/main/src/store/store.pipeline.ts"
click node_store_services "https://github.com/danielshaitovs/user-service/tree/main/src/store/services"
click node_cache_service "https://github.com/danielshaitovs/user-service/blob/main/src/base/service/cache.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_bootstrap,node_application,node_postgres,node_audit,node_cache_service,node_client toneBlue
class node_auth_controller,node_auth_service,node_auth_cache toneAmber
class node_role_controller,node_role_pipeline,node_role_services,node_permission_controller,node_permission_pipeline toneMint
class node_user_controller,node_user_pipeline,node_user_services,node_user_role_controller,node_user_role_pipeline,node_user_role_services,node_user_store_services,node_store_controller,node_store_pipeline,node_store_services toneRose
```

## Components

### API runtime

- [HTTP bootstrap](https://github.com/danielshaitovs/user-service/blob/main/src/main.ts): `src/main.ts`
- [Application wiring](https://github.com/danielshaitovs/user-service/blob/main/src/app.module.ts): `src/app.module.ts`
- **PostgreSQL**
- [User audit](https://github.com/danielshaitovs/user-service/blob/main/src/user/services/audit.service.ts): `src/user/services/audit.service.ts`
- [Shared cache](https://github.com/danielshaitovs/user-service/blob/main/src/base/service/cache.service.ts): `src/base/service/cache.service.ts`

### Authentication

- [Auth endpoints](https://github.com/danielshaitovs/user-service/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Sign-in service](https://github.com/danielshaitovs/user-service/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [Token cache](https://github.com/danielshaitovs/user-service/blob/main/src/auth/cache.service.ts): `src/auth/cache.service.ts`

### Roles and permissions

- [Role endpoints](https://github.com/danielshaitovs/user-service/blob/main/src/role/controllers/role.controller.ts): `src/role/controllers/role.controller.ts`
- [Role operations](https://github.com/danielshaitovs/user-service/blob/main/src/role/role.pipeline.ts): `src/role/role.pipeline.ts`
- [Role domain services](https://github.com/danielshaitovs/user-service/tree/main/src/role/services): `src/role/services`
- [Permission endpoints](https://github.com/danielshaitovs/user-service/blob/main/src/role/permission/controllers/permission.controller.ts): `src/role/permission/controllers/permission.controller.ts`
- [Permission operations](https://github.com/danielshaitovs/user-service/blob/main/src/role/permission/permission.pipeline.ts): `src/role/permission/permission.pipeline.ts`

### Users and stores

- [User endpoints](https://github.com/danielshaitovs/user-service/blob/main/src/user/controllers/user.controller.ts): `src/user/controllers/user.controller.ts`
- [User operations](https://github.com/danielshaitovs/user-service/blob/main/src/user/user.pipeline.ts): `src/user/user.pipeline.ts`
- [User domain services](https://github.com/danielshaitovs/user-service/tree/main/src/user/services/user): `src/user/services/user`
- [User-role endpoints](https://github.com/danielshaitovs/user-service/blob/main/src/user/controllers/roles.controller.ts): `src/user/controllers/roles.controller.ts`
- [User-role operations](https://github.com/danielshaitovs/user-service/blob/main/src/user/role.pipeline.ts): `src/user/role.pipeline.ts`
- [User-role services](https://github.com/danielshaitovs/user-service/blob/main/src/user/services/role/role.service.ts): `src/user/services/role/role.service.ts`
- [User-store services](https://github.com/danielshaitovs/user-service/blob/main/src/user/services/store/store.service.ts): `src/user/services/store/store.service.ts`
- [Store endpoints](https://github.com/danielshaitovs/user-service/blob/main/src/store/controllers/store.controller.ts): `src/store/controllers/store.controller.ts`
- [Store operations](https://github.com/danielshaitovs/user-service/blob/main/src/store/store.pipeline.ts): `src/store/store.pipeline.ts`
- [Store domain services](https://github.com/danielshaitovs/user-service/tree/main/src/store/services): `src/store/services`

### Other components

- **API client**

## Connections

- API client → HTTP bootstrap: sends HTTP (evidence: `src/main.ts`)
- HTTP bootstrap → Application wiring: creates app (evidence: `src/main.ts`)
- Application wiring → PostgreSQL: configures database (evidence: `src/app.module.ts`)
- Application wiring → Auth endpoints: registers module (evidence: `src/app.module.ts`)
- Application wiring → User endpoints: registers module (evidence: `src/app.module.ts`)
- Application wiring → Role endpoints: registers module (evidence: `src/app.module.ts`)
- Application wiring → Store endpoints: registers module (evidence: `src/app.module.ts`)
- Auth endpoints → Sign-in service: delegates sign-in (evidence: `src/auth/auth.controller.ts`)
- Sign-in service → User-role operations: loads permissions (evidence: `src/auth/auth.service.ts`)
- Sign-in service → User-store services: loads assigned stores (evidence: `src/auth/auth.service.ts`)
- Sign-in service → Token cache: stores token (evidence: `src/auth/auth.service.ts`)
- User endpoints → User operations: delegates requests (evidence: `src/user/controllers/user.controller.ts`)
- User operations → User domain services: delegates domain work (evidence: `src/user/user.pipeline.ts`)
- User operations → User audit: records changes (evidence: `src/user/user.pipeline.ts`)
- User-role endpoints → User-role operations: delegates requests (evidence: `src/user/controllers/roles.controller.ts`)
- User-role operations → User-role services: manages assignments (evidence: `src/user/role.pipeline.ts`)
- User-role operations → User audit: records assignments (evidence: `src/user/role.pipeline.ts`)
- User-role operations → Shared cache: caches permissions (evidence: `src/user/role.pipeline.ts`)
- Role endpoints → Role operations: delegates requests (evidence: `src/role/controllers/role.controller.ts`)
- Role operations → Role domain services: delegates domain work (evidence: `src/role/role.pipeline.ts`)
- Permission endpoints → Permission operations: delegates requests (evidence: `src/role/permission/controllers/permission.controller.ts`)
- Store endpoints → Store operations: delegates requests (evidence: `src/store/controllers/store.controller.ts`)
- Store operations → Store domain services: delegates domain work (evidence: `src/store/store.pipeline.ts`)
- Store operations → User audit: records changes (evidence: `src/store/store.pipeline.ts`)
- Store operations → Shared cache: caches store data (evidence: `src/store/store.pipeline.ts`)
- Token cache → Shared cache: uses shared cache (evidence: `src/auth/cache.service.ts`)
