# sysfaisal/nyobarust architecture

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

- Interactive diagram: https://gitdiagram.com/sysfaisal/nyobarust
- Repository: https://github.com/sysfaisal/nyobarust

## Overview

Nyobarust is a Rust/Axum API for perfume and related inventory, sales, and revenue operations, with user authentication. The principal workflow is an HTTP request routed to a domain handler, processed by a service, and answered through API response DTOs. The tree identifies distinct domain modules, but route and service implementations were not provided, so detailed dispatch, persistence, validation, and authentication wiring is not asserted.

Main entry points: [`src/handlers/mod.rs`](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/mod.rs) (Domain handlers), [`src/main.rs`](https://github.com/sysfaisal/nyobarust/blob/main/src/main.rs) (Server startup), [`src/c_auth/mod.rs`](https://github.com/sysfaisal/nyobarust/blob/main/src/c_auth/mod.rs) (Authentication), [`src/route/route.rs`](https://github.com/sysfaisal/nyobarust/blob/main/src/route/route.rs) (HTTP routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_entry["Server startup<br/>[main.rs]"]
  node_routing["HTTP routing<br/>[route.rs]"]
  node_handlers["Domain handlers<br/>[mod.rs]"]
  node_dto["Request/response DTOs<br/>[mod.rs]"]
  node_state["Application state<br/>[state.rs]"]
  node_database[("PostgreSQL pool<br/>[database.rs]")]
end

subgraph group_identity["Identity"]
  node_users["User operations<br/>[user.rs]"]
  node_user_service["User service<br/>[user_svc.rs]"]
  node_auth["Authentication<br/>[mod.rs]"]
  node_login["Login<br/>[login.rs]"]
  node_refresh["Token refresh<br/>[refresh_token.rs]"]
end

subgraph group_catalog["Catalog inventory"]
  node_brands["Brand operations<br/>[brand.rs]"]
  node_brand_service["Brand service<br/>[brands_svc.rs]"]
  node_perfumes["Perfume operations<br/>[parfume.rs]"]
  node_perfume_service["Perfume service<br/>[parfume_svc.rs]"]
  node_batches["Batch operations<br/>[batch.rs]"]
  node_batch_service["Batch service<br/>[batch_svc.rs]"]
  node_decants["Decant operations<br/>[decant.rs]"]
  node_decant_service["Decant service<br/>[decant_svc.rs]"]
  node_bottles["Bottle operations<br/>[bottle.rs]"]
  node_bottle_service["Bottle service<br/>[bottle_svc.rs]"]
end

subgraph group_sales["Sales reporting"]
  node_orders["Order operations<br/>[order.rs]"]
  node_order_service["Order service<br/>[order_svc.rs]"]
  node_revenue["Revenue operations<br/>[revenue.rs]"]
  node_revenue_service["Revenue service<br/>[revenue_svc.rs]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_entry
node_entry -->|"creates routes"| node_routing
node_entry -->|"connects pool"| node_database
node_entry -->|"builds state"| node_state
node_routing -->|"routes requests"| node_handlers
node_handlers -->|"uses payloads"| node_dto
node_handlers --> node_users
node_handlers --> node_brands
node_handlers --> node_perfumes
node_handlers --> node_batches
node_handlers --> node_decants
node_handlers --> node_bottles
node_handlers --> node_orders
node_handlers --> node_revenue
node_users -->|"delegates"| node_user_service
node_brands -->|"delegates"| node_brand_service
node_perfumes -->|"delegates"| node_perfume_service
node_batches -->|"delegates"| node_batch_service
node_decants -->|"delegates"| node_decant_service
node_bottles -->|"delegates"| node_bottle_service
node_orders -->|"delegates"| node_order_service
node_revenue -->|"delegates"| node_revenue_service
node_auth --> node_login
node_auth --> node_refresh

click node_entry "https://github.com/sysfaisal/nyobarust/blob/main/src/main.rs"
click node_routing "https://github.com/sysfaisal/nyobarust/blob/main/src/route/route.rs"
click node_handlers "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/mod.rs"
click node_dto "https://github.com/sysfaisal/nyobarust/blob/main/src/dto/mod.rs"
click node_state "https://github.com/sysfaisal/nyobarust/blob/main/src/state/state.rs"
click node_database "https://github.com/sysfaisal/nyobarust/blob/main/src/config/database.rs"
click node_users "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/user.rs"
click node_user_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/user_svc.rs"
click node_auth "https://github.com/sysfaisal/nyobarust/blob/main/src/c_auth/mod.rs"
click node_login "https://github.com/sysfaisal/nyobarust/blob/main/src/c_auth/login.rs"
click node_refresh "https://github.com/sysfaisal/nyobarust/blob/main/src/c_auth/refresh_token.rs"
click node_brands "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/brand.rs"
click node_brand_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/brands_svc.rs"
click node_perfumes "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/parfume.rs"
click node_perfume_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/parfume_svc.rs"
click node_batches "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/batch.rs"
click node_batch_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/batch_svc.rs"
click node_decants "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/decant.rs"
click node_decant_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/decant_svc.rs"
click node_bottles "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/bottle.rs"
click node_bottle_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/bottle_svc.rs"
click node_orders "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/order.rs"
click node_order_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/order_svc.rs"
click node_revenue "https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/revenue.rs"
click node_revenue_service "https://github.com/sysfaisal/nyobarust/blob/main/src/service/revenue_svc.rs"

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_entry,node_routing,node_handlers,node_dto,node_state,node_database,node_client toneBlue
class node_users,node_user_service,node_auth,node_login,node_refresh toneAmber
class node_brands,node_brand_service,node_perfumes,node_perfume_service,node_batches,node_batch_service,node_decants,node_decant_service,node_bottles,node_bottle_service toneMint
class node_orders,node_order_service,node_revenue,node_revenue_service toneRose
```

## Components

### API runtime

- [Server startup](https://github.com/sysfaisal/nyobarust/blob/main/src/main.rs): `src/main.rs`
- [HTTP routing](https://github.com/sysfaisal/nyobarust/blob/main/src/route/route.rs): `src/route/route.rs`
- [Domain handlers](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/mod.rs): `src/handlers/mod.rs`
- [Request/response DTOs](https://github.com/sysfaisal/nyobarust/blob/main/src/dto/mod.rs): `src/dto/mod.rs`
- [Application state](https://github.com/sysfaisal/nyobarust/blob/main/src/state/state.rs): `src/state/state.rs`
- [PostgreSQL pool](https://github.com/sysfaisal/nyobarust/blob/main/src/config/database.rs): `src/config/database.rs`

### Identity

- [User operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/user.rs): `src/handlers/user.rs`
- [User service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/user_svc.rs): `src/service/user_svc.rs`
- [Authentication](https://github.com/sysfaisal/nyobarust/blob/main/src/c_auth/mod.rs): `src/c_auth/mod.rs`
- [Login](https://github.com/sysfaisal/nyobarust/blob/main/src/c_auth/login.rs): `src/c_auth/login.rs`
- [Token refresh](https://github.com/sysfaisal/nyobarust/blob/main/src/c_auth/refresh_token.rs): `src/c_auth/refresh_token.rs`

### Catalog inventory

- [Brand operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/brand.rs): `src/handlers/brand.rs`
- [Brand service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/brands_svc.rs): `src/service/brands_svc.rs`
- [Perfume operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/parfume.rs): `src/handlers/parfume.rs`
- [Perfume service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/parfume_svc.rs): `src/service/parfume_svc.rs`
- [Batch operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/batch.rs): `src/handlers/batch.rs`
- [Batch service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/batch_svc.rs): `src/service/batch_svc.rs`
- [Decant operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/decant.rs): `src/handlers/decant.rs`
- [Decant service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/decant_svc.rs): `src/service/decant_svc.rs`
- [Bottle operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/bottle.rs): `src/handlers/bottle.rs`
- [Bottle service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/bottle_svc.rs): `src/service/bottle_svc.rs`

### Sales reporting

- [Order operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/order.rs): `src/handlers/order.rs`
- [Order service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/order_svc.rs): `src/service/order_svc.rs`
- [Revenue operations](https://github.com/sysfaisal/nyobarust/blob/main/src/handlers/revenue.rs): `src/handlers/revenue.rs`
- [Revenue service](https://github.com/sysfaisal/nyobarust/blob/main/src/service/revenue_svc.rs): `src/service/revenue_svc.rs`

### Other components

- **API client**

## Connections

- API client → Server startup: sends requests
- Server startup → HTTP routing: creates routes
- Server startup → PostgreSQL pool: connects pool
- Server startup → Application state: builds state
- HTTP routing → Domain handlers: routes requests
- Domain handlers → Request/response DTOs: uses payloads
- Domain handlers → User operations
- Domain handlers → Brand operations
- Domain handlers → Perfume operations
- Domain handlers → Batch operations
- Domain handlers → Decant operations
- Domain handlers → Bottle operations
- Domain handlers → Order operations
- Domain handlers → Revenue operations
- User operations → User service: delegates
- Brand operations → Brand service: delegates
- Perfume operations → Perfume service: delegates
- Batch operations → Batch service: delegates
- Decant operations → Decant service: delegates
- Bottle operations → Bottle service: delegates
- Order operations → Order service: delegates
- Revenue operations → Revenue service: delegates
- Authentication → Login
- Authentication → Token refresh
