# enochtec/go_fiber architecture

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

- Interactive diagram: https://gitdiagram.com/enochtec/go_fiber
- Repository: https://github.com/enochtec/go_fiber

## Overview

This is a multi-tenant point-of-sale application with a SvelteKit client and Go/Fiber API. A cashier signs in, manages a shift, and records sales; the product also supports catalog and stock management, purchasing, customer and supplier records, reporting, users, and shop settings. Offline-capable client services cache domain data locally and queue changes for synchronization. The backend route table and startup wiring are excerpted; many domain handlers and services are not, so their internal call chains are not inferred.

Main entry points: [`backend/internal/routes/routes.go`](https://github.com/enochtec/go_fiber/blob/main/backend/internal/routes/routes.go) (API Routes), [`src/lib/services/offline.ts`](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/offline.ts) (Offline Domains), [`src/lib/services/api.ts`](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/api.ts) (API Client), [`backend/cmd/main.go`](https://github.com/enochtec/go_fiber/blob/main/backend/cmd/main.go) (POS API Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["POS Client"]
  node_app_shell["Protected App<br/>[+layout.svelte]"]
  node_login_page["Sign In<br/>[+page.svelte]"]
  node_sales_page["Sales Screen<br/>[+page.svelte]"]
  node_auth_store["Auth State<br/>[auth.svelte.ts]"]
  node_api_client["API Client<br/>[api.ts]"]
end

subgraph group_offline["Offline Data"]
  node_offline_services["Offline Domains<br/>[offline.ts]"]
  node_local_db[("Local Database<br/>[db.ts]")]
  node_connection["Connection State<br/>[connection.ts]"]
  node_sync_queue["Sync Queue<br/>[sync.svelte.ts]"]
  node_product_service["Product Service<br/>[products.ts]"]
  node_customer_service["Customer Service<br/>[customers.ts]"]
  node_sales_service["Sales Service<br/>[sales.ts]"]
end

subgraph group_api["API Runtime"]
  node_server["POS API Server<br/>[main.go]"]
  node_route_table["API Routes<br/>[routes.go]"]
  node_database[("PostgreSQL<br/>[db.go]")]
  node_auth_handler["Auth Handler<br/>[auth_handler.go]"]
  node_auth_service["Auth Service<br/>[auth_service.go]"]
end

subgraph group_operations["Sales Operations"]
  node_sales_ops["Sales &amp; Shifts<br/>[sale_handler.go]"]
  node_inventory_ops["Inventory &amp; Purchases"]
  node_mpesa["M-Pesa Payments<br/>[mpesa_service.go]"]
end

subgraph group_management["Business Management"]
  node_catalog["Products &amp; Categories<br/>[product_handler.go]"]
  node_customer_records["Customer Records"]
  node_supplier_records["Supplier Records"]
  node_reports["Reports<br/>[report_handler.go]"]
  node_users_shop["Users &amp; Shop<br/>[user_handler.go]"]
  node_email["Receipt Email<br/>[email_service.go]"]
end

node_cashier(("Cashier / Manager"))

node_cashier -->|"signs in"| node_login_page
node_cashier -->|"records sales"| node_sales_page
node_login_page -.->|"authenticates via"| node_api_client
node_auth_store -->|"supplies token"| node_api_client
node_api_client -->|"sends API requests"| node_server
node_server -->|"connects"| node_database
node_server -->|"registers routes"| node_route_table
node_route_table -->|"routes auth"| node_auth_handler
node_auth_handler -->|"calls login"| node_auth_service
node_auth_service -.->|"reads user data"| node_database
node_route_table -->|"routes sales"| node_sales_ops
node_route_table -->|"routes inventory"| node_inventory_ops
node_route_table -->|"routes products"| node_catalog
node_route_table -->|"routes customers"| node_customer_records
node_route_table -->|"routes suppliers"| node_supplier_records
node_route_table -->|"routes reports"| node_reports
node_route_table -->|"routes users"| node_users_shop
node_route_table -->|"routes receipt email"| node_email
node_route_table -->|"routes M-Pesa"| node_mpesa
node_offline_services -->|"requests remote data"| node_api_client
node_offline_services -->|"reads and writes"| node_local_db
node_offline_services -->|"checks status"| node_connection
node_offline_services -->|"queues changes"| node_sync_queue
node_offline_services -->|"uses types"| node_product_service
node_offline_services -->|"uses types"| node_customer_service
node_offline_services -->|"uses types"| node_sales_service

click node_app_shell "https://github.com/enochtec/go_fiber/blob/main/src/routes/(app)/%2Blayout.svelte"
click node_login_page "https://github.com/enochtec/go_fiber/blob/main/src/routes/login/%2Bpage.svelte"
click node_sales_page "https://github.com/enochtec/go_fiber/blob/main/src/routes/(app)/sales/%2Bpage.svelte"
click node_auth_store "https://github.com/enochtec/go_fiber/blob/main/src/lib/stores/auth.svelte.ts"
click node_api_client "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/api.ts"
click node_offline_services "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/offline.ts"
click node_local_db "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/db.ts"
click node_connection "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/connection.ts"
click node_sync_queue "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/sync.svelte.ts"
click node_product_service "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/products.ts"
click node_customer_service "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/customers.ts"
click node_sales_service "https://github.com/enochtec/go_fiber/blob/main/src/lib/services/sales.ts"
click node_server "https://github.com/enochtec/go_fiber/blob/main/backend/cmd/main.go"
click node_route_table "https://github.com/enochtec/go_fiber/blob/main/backend/internal/routes/routes.go"
click node_database "https://github.com/enochtec/go_fiber/blob/main/backend/internal/database/db.go"
click node_auth_handler "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/auth_handler.go"
click node_auth_service "https://github.com/enochtec/go_fiber/blob/main/backend/internal/services/auth_service.go"
click node_sales_ops "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/sale_handler.go"
click node_inventory_ops "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/inventory_handler.go"
click node_catalog "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/product_handler.go"
click node_customer_records "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/customer_handler.go"
click node_supplier_records "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/supplier_handler.go"
click node_reports "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/report_handler.go"
click node_users_shop "https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/user_handler.go"
click node_email "https://github.com/enochtec/go_fiber/blob/main/backend/internal/services/email_service.go"
click node_mpesa "https://github.com/enochtec/go_fiber/blob/main/backend/internal/services/mpesa_service.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_app_shell,node_login_page,node_sales_page,node_auth_store,node_api_client toneBlue
class node_offline_services,node_local_db,node_connection,node_sync_queue,node_product_service,node_customer_service,node_sales_service toneAmber
class node_server,node_route_table,node_database,node_auth_handler,node_auth_service toneMint
class node_sales_ops,node_inventory_ops,node_mpesa toneRose
class node_catalog,node_customer_records,node_supplier_records,node_reports,node_users_shop,node_email,node_cashier toneIndigo
```

## Components

### POS Client

- [Protected App](https://github.com/enochtec/go_fiber/blob/main/src/routes/(app)/%2Blayout.svelte): `src/routes/(app)/+layout.svelte`
- [Sign In](https://github.com/enochtec/go_fiber/blob/main/src/routes/login/%2Bpage.svelte): `src/routes/login/+page.svelte`
- [Sales Screen](https://github.com/enochtec/go_fiber/blob/main/src/routes/(app)/sales/%2Bpage.svelte): `src/routes/(app)/sales/+page.svelte`
- [Auth State](https://github.com/enochtec/go_fiber/blob/main/src/lib/stores/auth.svelte.ts): `src/lib/stores/auth.svelte.ts`
- [API Client](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/api.ts): `src/lib/services/api.ts`

### Offline Data

- [Offline Domains](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/offline.ts): `src/lib/services/offline.ts`
- [Local Database](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/db.ts): `src/lib/services/db.ts`
- [Connection State](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/connection.ts): `src/lib/services/connection.ts`
- [Sync Queue](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/sync.svelte.ts): `src/lib/services/sync.svelte.ts`
- [Product Service](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/products.ts): `src/lib/services/products.ts`
- [Customer Service](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/customers.ts): `src/lib/services/customers.ts`
- [Sales Service](https://github.com/enochtec/go_fiber/blob/main/src/lib/services/sales.ts): `src/lib/services/sales.ts`

### API Runtime

- [POS API Server](https://github.com/enochtec/go_fiber/blob/main/backend/cmd/main.go): `backend/cmd/main.go`
- [API Routes](https://github.com/enochtec/go_fiber/blob/main/backend/internal/routes/routes.go): `backend/internal/routes/routes.go`
- [PostgreSQL](https://github.com/enochtec/go_fiber/blob/main/backend/internal/database/db.go): `backend/internal/database/db.go`
- [Auth Handler](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/auth_handler.go): `backend/internal/handlers/auth_handler.go`
- [Auth Service](https://github.com/enochtec/go_fiber/blob/main/backend/internal/services/auth_service.go): `backend/internal/services/auth_service.go`

### Sales Operations

- [Sales & Shifts](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/sale_handler.go): `backend/internal/handlers/sale_handler.go`
- [Inventory & Purchases](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/inventory_handler.go): `backend/internal/handlers/inventory_handler.go`
- [M-Pesa Payments](https://github.com/enochtec/go_fiber/blob/main/backend/internal/services/mpesa_service.go): `backend/internal/services/mpesa_service.go`

### Business Management

- [Products & Categories](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/product_handler.go): `backend/internal/handlers/product_handler.go`
- [Customer Records](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/customer_handler.go): `backend/internal/handlers/customer_handler.go`
- [Supplier Records](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/supplier_handler.go): `backend/internal/handlers/supplier_handler.go`
- [Reports](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/report_handler.go): `backend/internal/handlers/report_handler.go`
- [Users & Shop](https://github.com/enochtec/go_fiber/blob/main/backend/internal/handlers/user_handler.go): `backend/internal/handlers/user_handler.go`
- [Receipt Email](https://github.com/enochtec/go_fiber/blob/main/backend/internal/services/email_service.go): `backend/internal/services/email_service.go`

### Other components

- **Cashier / Manager**

## Connections

- Cashier / Manager → Sign In: signs in (evidence: `README.md`)
- Cashier / Manager → Sales Screen: records sales (evidence: `README.md`)
- Sign In → API Client: authenticates via
- Auth State → API Client: supplies token (evidence: `src/lib/services/api.ts`)
- API Client → POS API Server: sends API requests (evidence: `src/lib/services/api.ts`)
- POS API Server → PostgreSQL: connects (evidence: `backend/cmd/main.go`)
- POS API Server → API Routes: registers routes (evidence: `backend/cmd/main.go`)
- API Routes → Auth Handler: routes auth (evidence: `backend/internal/routes/routes.go`)
- Auth Handler → Auth Service: calls login (evidence: `backend/internal/handlers/auth_handler.go`)
- Auth Service → PostgreSQL: reads user data
- API Routes → Sales & Shifts: routes sales (evidence: `backend/internal/routes/routes.go`)
- API Routes → Inventory & Purchases: routes inventory (evidence: `backend/internal/routes/routes.go`)
- API Routes → Products & Categories: routes products (evidence: `backend/internal/routes/routes.go`)
- API Routes → Customer Records: routes customers (evidence: `backend/internal/routes/routes.go`)
- API Routes → Supplier Records: routes suppliers (evidence: `backend/internal/routes/routes.go`)
- API Routes → Reports: routes reports (evidence: `backend/internal/routes/routes.go`)
- API Routes → Users & Shop: routes users (evidence: `backend/internal/routes/routes.go`)
- API Routes → Receipt Email: routes receipt email (evidence: `backend/internal/routes/routes.go`)
- API Routes → M-Pesa Payments: routes M-Pesa (evidence: `backend/internal/routes/routes.go`)
- Offline Domains → API Client: requests remote data (evidence: `src/lib/services/offline.ts`)
- Offline Domains → Local Database: reads and writes (evidence: `src/lib/services/offline.ts`)
- Offline Domains → Connection State: checks status (evidence: `src/lib/services/offline.ts`)
- Offline Domains → Sync Queue: queues changes (evidence: `src/lib/services/offline.ts`)
- Offline Domains → Product Service: uses types (evidence: `src/lib/services/offline.ts`)
- Offline Domains → Customer Service: uses types (evidence: `src/lib/services/offline.ts`)
- Offline Domains → Sales Service: uses types (evidence: `src/lib/services/offline.ts`)
