# framejc7f/warehouse architecture

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

- Interactive diagram: https://gitdiagram.com/framejc7f/warehouse
- Repository: https://github.com/framejc7f/warehouse

## Overview

This is a Go warehouse-management web application for tracking tires and rims by warehouse cell. Its main workflow is an authenticated API request to receive, ship, move, or inspect stock: the router dispatches to a controller, the storage service applies the operation, and the storage repository reads or updates PostgreSQL. The README also describes item/stock accounting, filtered views, and movement visibility. The sampled code substantiates the stock-operation path; other domain branches are included from the route wiring and repository tree, with unsampled internal calls omitted.

Main entry points: [`internal/controller/routes.go`](https://github.com/framejc7f/warehouse/blob/master/internal/controller/routes.go) (API router), [`internal/service/storage.go`](https://github.com/framejc7f/warehouse/blob/master/internal/service/storage.go) (Stock service), [`internal/repository/storage.go`](https://github.com/framejc7f/warehouse/blob/master/internal/repository/storage.go) (Stock repository), [`internal/repository`](https://github.com/framejc7f/warehouse/tree/master/internal/repository) (Tire and rim repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_router["API router<br/>[routes.go]"]
  node_stock_controller["Stock controller"]
  node_auth_controller["Auth controller<br/>[auth_controller.go]"]
  node_user_controller["User controller<br/>[user_controller.go]"]
end

subgraph group_operations["Stock Operations"]
  node_stock_service["Stock service<br/>[storage.go]"]
  node_stock_repo["Stock repository<br/>[storage.go]"]
  node_stock_model["Stock records<br/>[storage.go]"]
end

subgraph group_catalog["Warehouse Catalog"]
  node_item_services["Tire and rim services"]
  node_item_repos["Tire and rim repositories"]
  node_cell_service["Cell service<br/>[cell.go]"]
  node_cell_repo["Cell repository<br/>[cell.go]"]
end

subgraph group_identity["Identity and Access"]
  node_user_service["User service<br/>[user.go]"]
  node_auth_service["Auth service<br/>[auth.go]"]
  node_user_repo["User repository<br/>[user.go]"]
end

subgraph group_persistence["Persistence"]
  node_postgres[("PostgreSQL")]
  node_schema["Database schema<br/>[ddl.go]"]
end

node_operator(("Warehouse user"))

node_operator -->|"sends request"| node_router
node_router -->|"dispatches"| node_stock_controller
node_router -->|"dispatches"| node_auth_controller
node_router -->|"dispatches"| node_user_controller
node_stock_controller -->|"calls operations"| node_stock_service
node_stock_service -->|"reads and updates"| node_stock_repo
node_stock_service -->|"looks up items"| node_item_repos
node_stock_service -->|"looks up cells"| node_cell_repo
node_stock_repo -->|"queries stock"| node_postgres
node_stock_repo -->|"creates tire repository"| node_item_repos
node_stock_repo -->|"reads and writes"| node_stock_model
node_item_services -.->|"accesses catalog"| node_item_repos
node_cell_service -.->|"accesses cells"| node_cell_repo
node_user_controller -->|"calls user operations"| node_user_service
node_auth_controller -.->|"handles authentication"| node_auth_service
node_auth_service -->|"looks up account"| node_user_repo
node_user_service -.->|"accesses accounts"| node_user_repo
node_user_repo -.->|"queries accounts"| node_postgres
node_item_repos -.->|"queries catalog"| node_postgres
node_cell_repo -.->|"queries cells"| node_postgres
node_schema -.->|"defines schema"| node_postgres

click node_router "https://github.com/framejc7f/warehouse/blob/master/internal/controller/routes.go"
click node_stock_controller "https://github.com/framejc7f/warehouse/blob/master/internal/controller/storage_controller.go"
click node_auth_controller "https://github.com/framejc7f/warehouse/blob/master/internal/controller/auth_controller.go"
click node_user_controller "https://github.com/framejc7f/warehouse/blob/master/internal/controller/user_controller.go"
click node_stock_service "https://github.com/framejc7f/warehouse/blob/master/internal/service/storage.go"
click node_stock_repo "https://github.com/framejc7f/warehouse/blob/master/internal/repository/storage.go"
click node_stock_model "https://github.com/framejc7f/warehouse/blob/master/internal/models/storage.go"
click node_item_services "https://github.com/framejc7f/warehouse/tree/master/internal/service"
click node_item_repos "https://github.com/framejc7f/warehouse/tree/master/internal/repository"
click node_cell_service "https://github.com/framejc7f/warehouse/blob/master/internal/service/cell.go"
click node_cell_repo "https://github.com/framejc7f/warehouse/blob/master/internal/repository/cell.go"
click node_user_service "https://github.com/framejc7f/warehouse/blob/master/internal/service/user.go"
click node_auth_service "https://github.com/framejc7f/warehouse/blob/master/internal/service/auth.go"
click node_user_repo "https://github.com/framejc7f/warehouse/blob/master/internal/repository/user.go"
click node_schema "https://github.com/framejc7f/warehouse/blob/master/internal/db/ddl.go"

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_router,node_stock_controller,node_auth_controller,node_user_controller,node_operator toneBlue
class node_stock_service,node_stock_repo,node_stock_model toneAmber
class node_item_services,node_item_repos,node_cell_service,node_cell_repo toneMint
class node_user_service,node_auth_service,node_user_repo toneRose
class node_postgres,node_schema toneIndigo
```

## Components

### HTTP API

- [API router](https://github.com/framejc7f/warehouse/blob/master/internal/controller/routes.go): `internal/controller/routes.go`
- [Stock controller](https://github.com/framejc7f/warehouse/blob/master/internal/controller/storage_controller.go): `internal/controller/storage_controller.go`
- [Auth controller](https://github.com/framejc7f/warehouse/blob/master/internal/controller/auth_controller.go): `internal/controller/auth_controller.go`
- [User controller](https://github.com/framejc7f/warehouse/blob/master/internal/controller/user_controller.go): `internal/controller/user_controller.go`

### Stock Operations

- [Stock service](https://github.com/framejc7f/warehouse/blob/master/internal/service/storage.go): `internal/service/storage.go`
- [Stock repository](https://github.com/framejc7f/warehouse/blob/master/internal/repository/storage.go): `internal/repository/storage.go`
- [Stock records](https://github.com/framejc7f/warehouse/blob/master/internal/models/storage.go): `internal/models/storage.go`

### Warehouse Catalog

- [Tire and rim services](https://github.com/framejc7f/warehouse/tree/master/internal/service): `internal/service`
- [Tire and rim repositories](https://github.com/framejc7f/warehouse/tree/master/internal/repository): `internal/repository`
- [Cell service](https://github.com/framejc7f/warehouse/blob/master/internal/service/cell.go): `internal/service/cell.go`
- [Cell repository](https://github.com/framejc7f/warehouse/blob/master/internal/repository/cell.go): `internal/repository/cell.go`

### Identity and Access

- [User service](https://github.com/framejc7f/warehouse/blob/master/internal/service/user.go): `internal/service/user.go`
- [Auth service](https://github.com/framejc7f/warehouse/blob/master/internal/service/auth.go): `internal/service/auth.go`
- [User repository](https://github.com/framejc7f/warehouse/blob/master/internal/repository/user.go): `internal/repository/user.go`

### Persistence

- **PostgreSQL**
- [Database schema](https://github.com/framejc7f/warehouse/blob/master/internal/db/ddl.go): `internal/db/ddl.go`

### Other components

- **Warehouse user**

## Connections

- Warehouse user → API router: sends request
- API router → Stock controller: dispatches (evidence: `internal/controller/routes.go`)
- API router → Auth controller: dispatches (evidence: `internal/controller/routes.go`)
- API router → User controller: dispatches (evidence: `internal/controller/routes.go`)
- Stock controller → Stock service: calls operations (evidence: `internal/controller/storage_controller.go`)
- Stock service → Stock repository: reads and updates (evidence: `internal/service/storage.go`)
- Stock service → Tire and rim repositories: looks up items (evidence: `internal/service/storage.go`)
- Stock service → Cell repository: looks up cells (evidence: `internal/service/storage.go`)
- Stock repository → PostgreSQL: queries stock (evidence: `internal/repository/storage.go`)
- Stock repository → Tire and rim repositories: creates tire repository (evidence: `internal/repository/storage.go`)
- Stock repository → Stock records: reads and writes (evidence: `internal/repository/storage.go`)
- Tire and rim services → Tire and rim repositories: accesses catalog
- Cell service → Cell repository: accesses cells
- User controller → User service: calls user operations (evidence: `internal/controller/user_controller.go`)
- Auth controller → Auth service: handles authentication
- Auth service → User repository: looks up account (evidence: `internal/service/auth.go`)
- User service → User repository: accesses accounts
- User repository → PostgreSQL: queries accounts
- Tire and rim repositories → PostgreSQL: queries catalog
- Cell repository → PostgreSQL: queries cells
- Database schema → PostgreSQL: defines schema
