# williamszatt/s.g.p.c architecture

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

- Interactive diagram: https://gitdiagram.com/williamszatt/s.g.p.c
- Repository: https://github.com/williamszatt/s.g.p.c

## Overview

ComercioOS is a web-based SaaS for small-shop operations, with tenant-scoped accounts and workflows for sales, inventory, clients, and management results. Users enter through the web interface, authenticate, and reach role-sensitive operational pages; the API exposes authentication, client, inventory, sales, and dashboard routes backed by Prisma. The graph preserves the documented reporting and settings capabilities. Several page-to-API details and unsampled subsystems are known only from imports or documentation, so uncertain links are omitted or marked dashed.

Main entry points: [`Front-end/src/App.tsx`](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/App.tsx) (Page router), [`Back-end/src/lib/prisma.ts`](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/lib/prisma.ts) (Prisma access), [`Back-end/src/server.ts`](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/server.ts) (HTTP API), [`Back-end/src/routes/auth.ts`](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/auth.ts) (Account routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Page router<br/>[App.tsx]"]
  node_context["Session context<br/>[AppContext.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_home["Public home<br/>[Home.tsx]"]
  node_auth_layout["Authenticated shell<br/>[AuthLayout.tsx]"]
end

subgraph group_identity["Identity and access"]
  node_auth_pages["Account pages<br/>[Register.tsx]"]
  node_auth_routes["Account routes<br/>[auth.ts]"]
  node_auth_middleware["Token authorization<br/>[auth.ts]"]
  node_password_reset["Password reset<br/>[password-reset.ts]"]
end

subgraph group_operations["Shop operations"]
  node_clients_ui["Client records<br/>[Clients.tsx]"]
  node_pos_ui["Point of sale<br/>[POSPage.tsx]"]
  node_stock_ui["Stock management<br/>[StockPage.tsx]"]
  node_client_routes["Client routes<br/>[clients.ts]"]
  node_inventory_routes["Inventory routes<br/>[inventory.ts]"]
  node_sales_routes["Sales routes<br/>[sales.ts]"]
end

subgraph group_management["Management"]
  node_dashboard_ui["Dashboard<br/>[Dashboard.tsx]"]
  node_reports_ui["Reports<br/>[Reports.tsx]"]
  node_settings_ui["Settings<br/>[Settings.tsx]"]
  node_notifications["Notifications<br/>[notifications.ts]"]
  node_dashboard_routes["Dashboard routes<br/>[dashboard.ts]"]
end

subgraph group_platform["API and persistence"]
  node_api_server["HTTP API<br/>[server.ts]"]
  node_prisma["Prisma access<br/>[prisma.ts]"]
  node_database[("Tenant data store<br/>[schema.prisma]")]
end

node_shopper(("Shop user"))

node_shopper -.->|"uses"| node_app
node_app -->|"provides state"| node_context
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_auth_pages
node_app -->|"routes to"| node_dashboard_ui
node_app -->|"routes to"| node_clients_ui
node_app -->|"routes to"| node_stock_ui
node_app -->|"routes to"| node_pos_ui
node_app -->|"routes to"| node_reports_ui
node_app -->|"routes to"| node_settings_ui
node_context -->|"calls"| node_api_client
node_auth_layout -->|"loads"| node_notifications
node_api_client -.->|"sends HTTP"| node_api_server
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_client_routes
node_api_server -->|"mounts"| node_inventory_routes
node_api_server -->|"mounts"| node_sales_routes
node_api_server -->|"mounts"| node_dashboard_routes
node_auth_routes -->|"uses"| node_auth_middleware
node_auth_routes -->|"uses"| node_password_reset
node_auth_middleware -->|"checks user"| node_prisma
node_auth_middleware -.->|"reads identity"| node_database
node_auth_routes -.->|"queries and writes"| node_prisma
node_client_routes -->|"queries and writes"| node_prisma
node_inventory_routes -.->|"uses data access"| node_prisma
node_sales_routes -.->|"uses data access"| node_prisma
node_dashboard_routes -.->|"uses data access"| node_prisma
node_prisma -.->|"persists records"| node_database
node_notifications -->|"requests stock and sales"| node_api_client
node_clients_ui -->|"renders within"| node_auth_layout

click node_app "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/App.tsx"
click node_context "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/contexts/AppContext.tsx"
click node_api_client "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/lib/api.ts"
click node_home "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Home.tsx"
click node_auth_pages "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Register.tsx"
click node_auth_layout "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/components/AuthLayout.tsx"
click node_clients_ui "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Clients.tsx"
click node_pos_ui "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/POSPage.tsx"
click node_stock_ui "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/StockPage.tsx"
click node_dashboard_ui "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Dashboard.tsx"
click node_reports_ui "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Reports.tsx"
click node_settings_ui "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Settings.tsx"
click node_notifications "https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/lib/notifications.ts"
click node_api_server "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/server.ts"
click node_auth_routes "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/auth.ts"
click node_auth_middleware "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/middleware/auth.ts"
click node_password_reset "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/services/password-reset.ts"
click node_client_routes "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/clients.ts"
click node_inventory_routes "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/inventory.ts"
click node_sales_routes "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/sales.ts"
click node_dashboard_routes "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/dashboard.ts"
click node_prisma "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/lib/prisma.ts"
click node_database "https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/prisma/schema.prisma"

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,node_context,node_api_client,node_home,node_auth_layout,node_shopper toneBlue
class node_auth_pages,node_auth_routes,node_auth_middleware,node_password_reset toneAmber
class node_clients_ui,node_pos_ui,node_stock_ui,node_client_routes,node_inventory_routes,node_sales_routes toneMint
class node_dashboard_ui,node_reports_ui,node_settings_ui,node_notifications,node_dashboard_routes toneRose
class node_api_server,node_prisma,node_database toneIndigo
```

## Components

### Web application

- [Page router](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/App.tsx): `Front-end/src/App.tsx`
- [Session context](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/contexts/AppContext.tsx): `Front-end/src/contexts/AppContext.tsx`
- [API client](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/lib/api.ts): `Front-end/src/lib/api.ts`
- [Public home](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Home.tsx): `Front-end/src/pages/Home.tsx`
- [Authenticated shell](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/components/AuthLayout.tsx): `Front-end/src/components/AuthLayout.tsx`

### Identity and access

- [Account pages](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Register.tsx): `Front-end/src/pages/Register.tsx`
- [Account routes](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/auth.ts): `Back-end/src/routes/auth.ts`
- [Token authorization](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/middleware/auth.ts): `Back-end/src/middleware/auth.ts`
- [Password reset](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/services/password-reset.ts): `Back-end/src/services/password-reset.ts`

### Shop operations

- [Client records](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Clients.tsx): `Front-end/src/pages/Clients.tsx`
- [Point of sale](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/POSPage.tsx): `Front-end/src/pages/POSPage.tsx`
- [Stock management](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/StockPage.tsx): `Front-end/src/pages/StockPage.tsx`
- [Client routes](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/clients.ts): `Back-end/src/routes/clients.ts`
- [Inventory routes](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/inventory.ts): `Back-end/src/routes/inventory.ts`
- [Sales routes](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/sales.ts): `Back-end/src/routes/sales.ts`

### Management

- [Dashboard](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Dashboard.tsx): `Front-end/src/pages/Dashboard.tsx`
- [Reports](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Reports.tsx): `Front-end/src/pages/Reports.tsx`
- [Settings](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/pages/Settings.tsx): `Front-end/src/pages/Settings.tsx`
- [Notifications](https://github.com/williamszatt/s.g.p.c/blob/main/Front-end/src/lib/notifications.ts): `Front-end/src/lib/notifications.ts`
- [Dashboard routes](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/routes/dashboard.ts): `Back-end/src/routes/dashboard.ts`

### API and persistence

- [HTTP API](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/server.ts): `Back-end/src/server.ts`
- [Prisma access](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/src/lib/prisma.ts): `Back-end/src/lib/prisma.ts`
- [Tenant data store](https://github.com/williamszatt/s.g.p.c/blob/main/Back-end/prisma/schema.prisma): `Back-end/prisma/schema.prisma`

### Other components

- **Shop user**

## Connections

- Shop user → Page router: uses (evidence: `README.md`)
- Page router → Session context: provides state (evidence: `Front-end/src/App.tsx`)
- Page router → Public home: routes to (evidence: `Front-end/src/App.tsx`)
- Page router → Account pages: routes to (evidence: `Front-end/src/App.tsx`)
- Page router → Dashboard: routes to (evidence: `Front-end/src/App.tsx`)
- Page router → Client records: routes to (evidence: `Front-end/src/App.tsx`)
- Page router → Stock management: routes to (evidence: `Front-end/src/App.tsx`)
- Page router → Point of sale: routes to (evidence: `Front-end/src/App.tsx`)
- Page router → Reports: routes to (evidence: `Front-end/src/App.tsx`)
- Page router → Settings: routes to (evidence: `Front-end/src/App.tsx`)
- Session context → API client: calls (evidence: `Front-end/src/contexts/AppContext.tsx`)
- Authenticated shell → Notifications: loads (evidence: `Front-end/src/components/AuthLayout.tsx`)
- API client → HTTP API: sends HTTP
- HTTP API → Account routes: mounts (evidence: `Back-end/src/server.ts`)
- HTTP API → Client routes: mounts (evidence: `Back-end/src/server.ts`)
- HTTP API → Inventory routes: mounts (evidence: `Back-end/src/server.ts`)
- HTTP API → Sales routes: mounts (evidence: `Back-end/src/server.ts`)
- HTTP API → Dashboard routes: mounts (evidence: `Back-end/src/server.ts`)
- Account routes → Token authorization: uses (evidence: `Back-end/src/routes/auth.ts`)
- Account routes → Password reset: uses (evidence: `Back-end/src/routes/auth.ts`)
- Token authorization → Prisma access: checks user (evidence: `Back-end/src/middleware/auth.ts`)
- Token authorization → Tenant data store: reads identity
- Account routes → Prisma access: queries and writes (evidence: `Back-end/src/routes/auth.ts`)
- Client routes → Prisma access: queries and writes (evidence: `Back-end/src/routes/clients.ts`)
- Inventory routes → Prisma access: uses data access (evidence: `Back-end/src/routes/inventory.ts`)
- Sales routes → Prisma access: uses data access (evidence: `Back-end/src/routes/sales.ts`)
- Dashboard routes → Prisma access: uses data access (evidence: `Back-end/src/routes/dashboard.ts`)
- Prisma access → Tenant data store: persists records
- Notifications → API client: requests stock and sales (evidence: `Front-end/src/lib/notifications.ts`)
- Client records → Authenticated shell: renders within (evidence: `Front-end/src/pages/Clients.tsx`)
