# sanjay-05/book_management_system architecture

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

- Interactive diagram: https://gitdiagram.com/sanjay-05/book_management_system
- Repository: https://github.com/sanjay-05/book_management_system

## Overview

This is a Gin-based Book Store API. Its principal workflow is an HTTP request routed through public or role-protected routes to a handler, then through business services to repository operations backed by PostgreSQL; handlers return API responses. The domain spans identity and password recovery, catalog and contact administration, user profiles, carts, and order checkout/status. The source excerpts show representative calls across these layers, but not every route or subsystem implementation; README-documented capabilities are retained without inventing their internal wiring.

Main entry points: [`router/routes.go`](https://github.com/sanjay-05/book_management_system/blob/main/router/routes.go) (HTTP routes), [`driver/dbConnection.go`](https://github.com/sanjay-05/book_management_system/blob/main/driver/dbConnection.go) (Database connection), [`main.go`](https://github.com/sanjay-05/book_management_system/blob/main/main.go) (Server startup), [`handler/user_handler.go`](https://github.com/sanjay-05/book_management_system/blob/main/handler/user_handler.go) (Identity handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_main["Server startup<br/>[main.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_router["HTTP routes<br/>[routes.go]"]
end

subgraph group_identity["Identity and access"]
  node_authmw["Role middleware<br/>[auth.go]"]
  node_helpers["Auth helpers<br/>[helper.go]"]
  node_identity_handler["Identity handlers<br/>[user_handler.go]"]
  node_identity_service["Identity services<br/>[user_service.go]"]
end

subgraph group_catalog["Catalog administration"]
  node_admin_handler["Admin handlers<br/>[admin_handler.go]"]
  node_admin_service["Admin services<br/>[admin_service.go]"]
end

subgraph group_commerce["User commerce"]
  node_commerce_handler["Cart and order handlers"]
  node_commerce_service["Cart and order services"]
end

subgraph group_persistence["Persistence"]
  node_user_repository["User repository<br/>[user_repository.go]"]
  node_commerce_repository["Cart and order repository"]
  node_admin_repository["Admin repository"]
  node_models["Domain models<br/>[models.go]"]
  node_db_driver["Database connection<br/>[dbConnection.go]"]
  node_schema["Database migrations"]
end

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

node_client -->|"sends requests"| node_router
node_main -->|"loads settings"| node_config
node_main -->|"connects database"| node_db_driver
node_main -->|"starts server"| node_router
node_router -->|"protects routes"| node_authmw
node_router -->|"routes requests"| node_identity_handler
node_router -->|"routes requests"| node_commerce_handler
node_router -->|"routes requests"| node_admin_handler
node_authmw -->|"validates tokens"| node_helpers
node_identity_handler -->|"hashes passwords"| node_helpers
node_identity_handler -->|"delegates identity"| node_identity_service
node_identity_service -->|"checks and updates users"| node_user_repository
node_commerce_handler -->|"delegates commerce"| node_commerce_service
node_commerce_service -->|"performs commerce operations"| node_commerce_repository
node_admin_handler -->|"delegates administration"| node_admin_service
node_admin_service -->|"manages catalog and users"| node_admin_repository
node_admin_service -->|"checks user records"| node_user_repository
node_user_repository -->|"uses database handle"| node_db_driver
node_commerce_repository -->|"uses database handle"| node_db_driver
node_admin_repository -->|"uses database handle"| node_db_driver
node_db_driver -->|"connects to"| node_postgres
node_schema -.->|"defines schema"| node_postgres
node_commerce_repository -->|"queries domain records"| node_models
node_admin_repository -->|"queries domain records"| node_models

click node_main "https://github.com/sanjay-05/book_management_system/blob/main/main.go"
click node_config "https://github.com/sanjay-05/book_management_system/blob/main/config/config.go"
click node_router "https://github.com/sanjay-05/book_management_system/blob/main/router/routes.go"
click node_authmw "https://github.com/sanjay-05/book_management_system/blob/main/middleware/auth.go"
click node_helpers "https://github.com/sanjay-05/book_management_system/blob/main/helper/helper.go"
click node_identity_handler "https://github.com/sanjay-05/book_management_system/blob/main/handler/user_handler.go"
click node_identity_service "https://github.com/sanjay-05/book_management_system/blob/main/service/user_service.go"
click node_commerce_handler "https://github.com/sanjay-05/book_management_system/blob/main/handler/userAdmin_handler.go"
click node_commerce_service "https://github.com/sanjay-05/book_management_system/blob/main/service/userAdmin_service.go"
click node_admin_handler "https://github.com/sanjay-05/book_management_system/blob/main/handler/admin_handler.go"
click node_admin_service "https://github.com/sanjay-05/book_management_system/blob/main/service/admin_service.go"
click node_user_repository "https://github.com/sanjay-05/book_management_system/blob/main/repository/user_repository.go"
click node_commerce_repository "https://github.com/sanjay-05/book_management_system/blob/main/repository/userAdmin_repository.go"
click node_admin_repository "https://github.com/sanjay-05/book_management_system/blob/main/repository/admin_repository.go"
click node_models "https://github.com/sanjay-05/book_management_system/blob/main/models/models.go"
click node_db_driver "https://github.com/sanjay-05/book_management_system/blob/main/driver/dbConnection.go"
click node_schema "https://github.com/sanjay-05/book_management_system/tree/main/migrations"

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_main,node_config,node_router,node_client toneBlue
class node_authmw,node_helpers,node_identity_handler,node_identity_service,node_postgres toneAmber
class node_admin_handler,node_admin_service toneMint
class node_commerce_handler,node_commerce_service toneRose
class node_user_repository,node_commerce_repository,node_admin_repository,node_models,node_db_driver,node_schema toneIndigo
```

## Components

### Server runtime

- [Server startup](https://github.com/sanjay-05/book_management_system/blob/main/main.go): `main.go`
- [Configuration](https://github.com/sanjay-05/book_management_system/blob/main/config/config.go): `config/config.go`
- [HTTP routes](https://github.com/sanjay-05/book_management_system/blob/main/router/routes.go): `router/routes.go`

### Identity and access

- [Role middleware](https://github.com/sanjay-05/book_management_system/blob/main/middleware/auth.go): `middleware/auth.go`
- [Auth helpers](https://github.com/sanjay-05/book_management_system/blob/main/helper/helper.go): `helper/helper.go`
- [Identity handlers](https://github.com/sanjay-05/book_management_system/blob/main/handler/user_handler.go): `handler/user_handler.go`
- [Identity services](https://github.com/sanjay-05/book_management_system/blob/main/service/user_service.go): `service/user_service.go`

### Catalog administration

- [Admin handlers](https://github.com/sanjay-05/book_management_system/blob/main/handler/admin_handler.go): `handler/admin_handler.go`
- [Admin services](https://github.com/sanjay-05/book_management_system/blob/main/service/admin_service.go): `service/admin_service.go`

### User commerce

- [Cart and order handlers](https://github.com/sanjay-05/book_management_system/blob/main/handler/userAdmin_handler.go): `handler/userAdmin_handler.go`
- [Cart and order services](https://github.com/sanjay-05/book_management_system/blob/main/service/userAdmin_service.go): `service/userAdmin_service.go`

### Persistence

- [User repository](https://github.com/sanjay-05/book_management_system/blob/main/repository/user_repository.go): `repository/user_repository.go`
- [Cart and order repository](https://github.com/sanjay-05/book_management_system/blob/main/repository/userAdmin_repository.go): `repository/userAdmin_repository.go`
- [Admin repository](https://github.com/sanjay-05/book_management_system/blob/main/repository/admin_repository.go): `repository/admin_repository.go`
- [Domain models](https://github.com/sanjay-05/book_management_system/blob/main/models/models.go): `models/models.go`
- [Database connection](https://github.com/sanjay-05/book_management_system/blob/main/driver/dbConnection.go): `driver/dbConnection.go`
- [Database migrations](https://github.com/sanjay-05/book_management_system/tree/main/migrations): `migrations`

### Other components

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

## Connections

- API client → HTTP routes: sends requests (evidence: `README.md`)
- Server startup → Configuration: loads settings (evidence: `main.go`)
- Server startup → Database connection: connects database (evidence: `main.go`)
- Server startup → HTTP routes: starts server (evidence: `main.go`)
- HTTP routes → Role middleware: protects routes (evidence: `router/routes.go`)
- HTTP routes → Identity handlers: routes requests (evidence: `router/routes.go`)
- HTTP routes → Cart and order handlers: routes requests (evidence: `router/routes.go`)
- HTTP routes → Admin handlers: routes requests (evidence: `router/routes.go`)
- Role middleware → Auth helpers: validates tokens (evidence: `middleware/auth.go`)
- Identity handlers → Auth helpers: hashes passwords (evidence: `handler/user_handler.go`)
- Identity handlers → Identity services: delegates identity (evidence: `handler/user_handler.go`)
- Identity services → User repository: checks and updates users (evidence: `service/user_service.go`)
- Cart and order handlers → Cart and order services: delegates commerce (evidence: `handler/userAdmin_handler.go`)
- Cart and order services → Cart and order repository: performs commerce operations (evidence: `service/userAdmin_service.go`)
- Admin handlers → Admin services: delegates administration (evidence: `handler/admin_handler.go`)
- Admin services → Admin repository: manages catalog and users (evidence: `service/admin_service.go`)
- Admin services → User repository: checks user records (evidence: `service/admin_service.go`)
- User repository → Database connection: uses database handle (evidence: `repository/user_repository.go`)
- Cart and order repository → Database connection: uses database handle (evidence: `repository/userAdmin_repository.go`)
- Admin repository → Database connection: uses database handle (evidence: `repository/admin_repository.go`)
- Database connection → PostgreSQL: connects to (evidence: `README.md`)
- Database migrations → PostgreSQL: defines schema
- Cart and order repository → Domain models: queries domain records (evidence: `repository/userAdmin_repository.go`)
- Admin repository → Domain models: queries domain records (evidence: `repository/admin_repository.go`)
