# juanespinoza96/saas architecture

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

- Interactive diagram: https://gitdiagram.com/juanespinoza96/saas
- Repository: https://github.com/juanespinoza96/saas

## Overview

SaasPOS is a multi-tenant point-of-sale and commerce-management SaaS with separate tenant and platform-admin web apps. In the main workflow, a staff member uses the POS to submit a sale; the API applies tenant context, pricing and stock rules, then persists sale data. The Web-to-API sale handoff and several unsampled service/controller links are not visible in the excerpts, so those relationships are marked unverified. The graph also preserves documented-by-tree capability areas such as reporting, SRI invoicing, AI, subscriptions, trials and administration.

Main entry points: [`src/SaasPOS.Infrastructure/Data/AppDbContext.cs`](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Data/AppDbContext.cs) (Tenant data access), [`src/SaasPOS.Api/Controllers/Tenants/VentasController.cs`](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Api/Controllers/Tenants/VentasController.cs) (Sales API), [`src/SaasPOS.Api/Controllers/Tenants`](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Api/Controllers/Tenants) (Commerce endpoints), [`src/SaasPOS.Web/src/App.tsx`](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Web/src/App.tsx) (Tenant web app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tenant_ui["Tenant application"]
  node_tenant_app["Tenant web app<br/>[App.tsx]"]
  node_pos_pages["POS screens<br/>[PosNormalPage.tsx]"]
  node_tenant_features["Commerce features<br/>[pages]"]
end

subgraph group_admin_ui["Platform administration"]
  node_admin_app["Admin web app<br/>[App.tsx]"]
  node_admin_features["Platform controls<br/>[pages]"]
end

subgraph group_api["API and domain workflows"]
  node_auth_api["Authentication API<br/>[AuthController.cs]"]
  node_sales_api["Sales API"]
  node_commerce_api["Commerce endpoints<br/>[Tenants]"]
  node_admin_api["Admin endpoints<br/>[Admin]"]
  node_tenant_security["Tenant and security<br/>[Middleware]"]
end

subgraph group_services["Business services"]
  node_auth_service["Identity service<br/>[AuthService.cs]"]
  node_stock_service["Stock service<br/>[StockService.cs]"]
  node_billing_trials["Billing and trials<br/>[BillingService.cs]"]
  node_reporting["Reporting and export<br/>[ReportEngine.cs]"]
  node_ai_sri["AI and SRI<br/>[Services]"]
  node_audit_notifications["Audit and notices<br/>[AuditService.cs]"]
end

subgraph group_persistence["Persistence and domain"]
  node_db_context[("Tenant data access<br/>[AppDbContext.cs]")]
  node_domain_entities["Commerce records<br/>[Entities]"]
  node_plan_entities["Plans and subscriptions<br/>[Plan.cs]"]
end

node_staff(("Commerce staff"))

node_staff -.->|"uses"| node_tenant_app
node_tenant_app -.->|"presents"| node_pos_pages
node_tenant_app -.->|"presents"| node_tenant_features
node_pos_pages -.->|"submits sale"| node_sales_api
node_tenant_features -.->|"uses endpoints"| node_commerce_api
node_sales_api -->|"uses"| node_stock_service
node_sales_api -->|"reads and writes"| node_db_context
node_sales_api -->|"creates sales"| node_domain_entities
node_tenant_security -.->|"sets tenant scope"| node_db_context
node_db_context -->|"maps records"| node_domain_entities
node_staff -.->|"authenticates"| node_auth_api
node_auth_api -->|"delegates"| node_auth_service
node_auth_service -->|"reads and writes"| node_db_context
node_admin_app -.->|"presents"| node_admin_features
node_admin_features -.->|"uses endpoints"| node_admin_api
node_admin_api -->|"accesses data"| node_db_context
node_admin_api -.->|"uses billing"| node_billing_trials
node_commerce_api -.->|"requests reports"| node_reporting
node_commerce_api -.->|"uses integrations"| node_ai_sri
node_commerce_api -.->|"records activity"| node_audit_notifications
node_billing_trials -.->|"manages subscriptions"| node_plan_entities
node_billing_trials -.->|"persists billing"| node_db_context
node_reporting -->|"queries records"| node_db_context

click node_tenant_app "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Web/src/App.tsx"
click node_pos_pages "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Web/src/pages/PosNormalPage.tsx"
click node_tenant_features "https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Web/src/pages"
click node_admin_app "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Admin/src/App.tsx"
click node_admin_features "https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Admin/src/pages"
click node_auth_api "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Api/Controllers/AuthController.cs"
click node_sales_api "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Api/Controllers/Tenants/VentasController.cs"
click node_commerce_api "https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Api/Controllers/Tenants"
click node_admin_api "https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Api/Controllers/Admin"
click node_tenant_security "https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Api/Middleware"
click node_auth_service "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/AuthService.cs"
click node_stock_service "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/StockService.cs"
click node_billing_trials "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/BillingService.cs"
click node_reporting "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/ReportEngine.cs"
click node_ai_sri "https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Infrastructure/Services"
click node_audit_notifications "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/AuditService.cs"
click node_db_context "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Data/AppDbContext.cs"
click node_domain_entities "https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Domain/Entities"
click node_plan_entities "https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Domain/Entities/Plan.cs"

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_tenant_app,node_pos_pages,node_tenant_features toneBlue
class node_admin_app,node_admin_features toneAmber
class node_auth_api,node_sales_api,node_commerce_api,node_admin_api,node_tenant_security toneMint
class node_auth_service,node_stock_service,node_billing_trials,node_reporting,node_ai_sri,node_audit_notifications toneRose
class node_db_context,node_domain_entities,node_plan_entities,node_staff toneIndigo
```

## Components

### Tenant application

- [Tenant web app](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Web/src/App.tsx): `src/SaasPOS.Web/src/App.tsx`
- [POS screens](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Web/src/pages/PosNormalPage.tsx): `src/SaasPOS.Web/src/pages/PosNormalPage.tsx`
- [Commerce features](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Web/src/pages): `src/SaasPOS.Web/src/pages`

### Platform administration

- [Admin web app](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Admin/src/App.tsx): `src/SaasPOS.Admin/src/App.tsx`
- [Platform controls](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Admin/src/pages): `src/SaasPOS.Admin/src/pages`

### API and domain workflows

- [Authentication API](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Api/Controllers/AuthController.cs): `src/SaasPOS.Api/Controllers/AuthController.cs`
- [Sales API](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Api/Controllers/Tenants/VentasController.cs): `src/SaasPOS.Api/Controllers/Tenants/VentasController.cs`
- [Commerce endpoints](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Api/Controllers/Tenants): `src/SaasPOS.Api/Controllers/Tenants`
- [Admin endpoints](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Api/Controllers/Admin): `src/SaasPOS.Api/Controllers/Admin`
- [Tenant and security](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Api/Middleware): `src/SaasPOS.Api/Middleware`

### Business services

- [Identity service](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/AuthService.cs): `src/SaasPOS.Infrastructure/Services/AuthService.cs`
- [Stock service](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/StockService.cs): `src/SaasPOS.Infrastructure/Services/StockService.cs`
- [Billing and trials](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/BillingService.cs): `src/SaasPOS.Infrastructure/Services/BillingService.cs`
- [Reporting and export](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/ReportEngine.cs): `src/SaasPOS.Infrastructure/Services/ReportEngine.cs`
- [AI and SRI](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Infrastructure/Services): `src/SaasPOS.Infrastructure/Services`
- [Audit and notices](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Services/AuditService.cs): `src/SaasPOS.Infrastructure/Services/AuditService.cs`

### Persistence and domain

- [Tenant data access](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Infrastructure/Data/AppDbContext.cs): `src/SaasPOS.Infrastructure/Data/AppDbContext.cs`
- [Commerce records](https://github.com/juanespinoza96/saas/tree/main/src/SaasPOS.Domain/Entities): `src/SaasPOS.Domain/Entities`
- [Plans and subscriptions](https://github.com/juanespinoza96/saas/blob/main/src/SaasPOS.Domain/Entities/Plan.cs): `src/SaasPOS.Domain/Entities/Plan.cs`

### Other components

- **Commerce staff**

## Connections

- Commerce staff → Tenant web app: uses
- Tenant web app → POS screens: presents
- Tenant web app → Commerce features: presents
- POS screens → Sales API: submits sale
- Commerce features → Commerce endpoints: uses endpoints
- Sales API → Stock service: uses (evidence: `src/SaasPOS.Api/Controllers/Tenants/VentasController.cs`)
- Sales API → Tenant data access: reads and writes (evidence: `src/SaasPOS.Api/Controllers/Tenants/VentasController.cs`)
- Sales API → Commerce records: creates sales (evidence: `src/SaasPOS.Api/Controllers/Tenants/VentasController.cs`)
- Tenant and security → Tenant data access: sets tenant scope
- Tenant data access → Commerce records: maps records (evidence: `src/SaasPOS.Infrastructure/Data/AppDbContext.cs`)
- Commerce staff → Authentication API: authenticates
- Authentication API → Identity service: delegates (evidence: `src/SaasPOS.Api/Controllers/AuthController.cs`)
- Identity service → Tenant data access: reads and writes (evidence: `src/SaasPOS.Infrastructure/Services/AuthService.cs`)
- Admin web app → Platform controls: presents
- Platform controls → Admin endpoints: uses endpoints
- Admin endpoints → Tenant data access: accesses data (evidence: `src/SaasPOS.Api/Controllers/Admin/ComerciosController.cs`)
- Admin endpoints → Billing and trials: uses billing
- Commerce endpoints → Reporting and export: requests reports
- Commerce endpoints → AI and SRI: uses integrations (evidence: `src/SaasPOS.Api/Controllers/Tenants/UsuariosController.cs`)
- Commerce endpoints → Audit and notices: records activity
- Billing and trials → Plans and subscriptions: manages subscriptions
- Billing and trials → Tenant data access: persists billing
- Reporting and export → Tenant data access: queries records (evidence: `src/SaasPOS.Infrastructure/Services/ReportEngine.cs`)
