# dev-aylton/controle-app architecture

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

- Interactive diagram: https://gitdiagram.com/dev-aylton/controle-app
- Repository: https://github.com/dev-aylton/controle-app

## Overview

Controle-App is a multi-company inventory-management PWA. Its main workflow configures environments and products, records stock movements or inventory counts, then supports replenishment and sales-based stock reduction, with reports and audit for review. Authentication, company membership, role-based access, and Supabase-backed persistence underpin that workflow; offline movement queuing is a separate operational branch. The graph uses README capability descriptions and the supplied source excerpts/index; several feature implementations were not sampled, so their internal links are omitted where evidence is limited.

Main entry points: [`src/app/App.tsx`](https://github.com/dev-aylton/controle-app/blob/main/src/app/App.tsx) (Application routes), [`src/lib/supabase.ts`](https://github.com/dev-aylton/controle-app/blob/main/src/lib/supabase.ts) (Supabase client), [`src/services/movements.ts`](https://github.com/dev-aylton/controle-app/blob/main/src/services/movements.ts) (Movement operations), [`src/pages/MovementsPage.tsx`](https://github.com/dev-aylton/controle-app/blob/main/src/pages/MovementsPage.tsx) (Movement entry and history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and companies"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_company["Company context<br/>[CompanyContext.tsx]"]
  node_permissions["Role permissions<br/>[uiPermissions.ts]"]
end

subgraph group_inventory["Inventory operations"]
  node_environments["Environments"]
  node_products["Product catalog<br/>[productCatalog.ts]"]
  node_products_page["Product management<br/>[ProductsPage.tsx]"]
  node_movements_page["Movement entry and history<br/>[MovementsPage.tsx]"]
  node_movement_form["Movement form"]
  node_movement_service["Movement operations<br/>[movements.ts]"]
  node_inventory_page["Inventory counts<br/>[InventoryPage.tsx]"]
  node_offline_sync["Offline synchronization<br/>[sync.ts]"]
  node_offline_db[("Offline queue and cache<br/>[db.ts]")]
end

subgraph group_business["Purchasing and sales"]
  node_purchase_page["Purchase planning"]
  node_management["Purchasing rules and services"]
  node_sales_page["Sales import and pricing"]
  node_sales_service["Sales operations<br/>[salesService.ts]"]
  node_reports["Reports and audit"]
end

subgraph group_platform["Shared platform"]
  node_app["Application routes<br/>[App.tsx]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_postgres[("PostgreSQL and RLS")]
  node_support["Private support<br/>[supportService.ts]"]
  node_privacy["Privacy and account data"]
end

node_user(("Company user"))

node_user -->|"uses"| node_app
node_app -->|"provides"| node_auth
node_app -->|"provides"| node_company
node_app -->|"routes to"| node_products_page
node_app -->|"routes to"| node_movements_page
node_app -->|"routes to"| node_inventory_page
node_app -->|"routes to"| node_purchase_page
node_app -->|"routes to"| node_sales_page
node_app -->|"routes to"| node_reports
node_company -->|"reads session"| node_auth
node_company -->|"loads company data"| node_supabase
node_auth -->|"uses"| node_supabase
node_permissions -->|"checks role"| node_company
node_products_page -->|"uses catalog"| node_products
node_products_page -->|"reads stock"| node_movement_service
node_movements_page -->|"renders"| node_movement_form
node_movements_page -->|"records movements"| node_movement_service
node_inventory_page -->|"applies counts"| node_movement_service
node_movements_page -->|"queues offline"| node_offline_sync
node_offline_sync -->|"reads and writes"| node_offline_db
node_offline_sync -->|"syncs movements"| node_movement_service
node_purchase_page -->|"plans replenishment"| node_management
node_sales_page -->|"imports sales"| node_sales_service
node_sales_page -->|"reduces stock"| node_movement_service
node_movement_service -->|"calls RPCs"| node_supabase
node_sales_service -->|"calls RPCs"| node_supabase
node_supabase -->|"persists data"| node_postgres
node_environments -->|"loads environments"| node_supabase
node_support -->|"stores conversations"| node_supabase
node_privacy -->|"supports data rights"| node_user

click node_app "https://github.com/dev-aylton/controle-app/blob/main/src/app/App.tsx"
click node_auth "https://github.com/dev-aylton/controle-app/blob/main/src/features/auth/AuthContext.tsx"
click node_company "https://github.com/dev-aylton/controle-app/blob/main/src/features/company/CompanyContext.tsx"
click node_permissions "https://github.com/dev-aylton/controle-app/blob/main/src/lib/uiPermissions.ts"
click node_supabase "https://github.com/dev-aylton/controle-app/blob/main/src/lib/supabase.ts"
click node_environments "https://github.com/dev-aylton/controle-app/blob/main/src/features/environments/environmentService.ts"
click node_products "https://github.com/dev-aylton/controle-app/blob/main/src/features/products/productCatalog.ts"
click node_products_page "https://github.com/dev-aylton/controle-app/blob/main/src/pages/ProductsPage.tsx"
click node_movements_page "https://github.com/dev-aylton/controle-app/blob/main/src/pages/MovementsPage.tsx"
click node_movement_form "https://github.com/dev-aylton/controle-app/blob/main/src/features/movements/MovementLaunchForm.tsx"
click node_movement_service "https://github.com/dev-aylton/controle-app/blob/main/src/services/movements.ts"
click node_inventory_page "https://github.com/dev-aylton/controle-app/blob/main/src/pages/InventoryPage.tsx"
click node_offline_sync "https://github.com/dev-aylton/controle-app/blob/main/src/features/offline/sync.ts"
click node_offline_db "https://github.com/dev-aylton/controle-app/blob/main/src/features/offline/db.ts"
click node_purchase_page "https://github.com/dev-aylton/controle-app/blob/main/src/pages/PurchaseListPage.tsx"
click node_management "https://github.com/dev-aylton/controle-app/tree/main/src/features/management"
click node_sales_page "https://github.com/dev-aylton/controle-app/blob/main/src/pages/SalesImportPage.tsx"
click node_sales_service "https://github.com/dev-aylton/controle-app/blob/main/src/features/sales/salesService.ts"
click node_reports "https://github.com/dev-aylton/controle-app/tree/main/src/pages"
click node_support "https://github.com/dev-aylton/controle-app/blob/main/src/features/support/supportService.ts"
click node_privacy "https://github.com/dev-aylton/controle-app/tree/main/src/features/privacy"

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_auth,node_company,node_permissions,node_user toneBlue
class node_environments,node_products,node_products_page,node_movements_page,node_movement_form,node_movement_service,node_inventory_page,node_offline_sync,node_offline_db toneAmber
class node_purchase_page,node_management,node_sales_page,node_sales_service,node_reports toneMint
class node_app,node_supabase,node_postgres,node_support,node_privacy toneRose
```

## Components

### Identity and companies

- [Authentication](https://github.com/dev-aylton/controle-app/blob/main/src/features/auth/AuthContext.tsx): `src/features/auth/AuthContext.tsx`
- [Company context](https://github.com/dev-aylton/controle-app/blob/main/src/features/company/CompanyContext.tsx): `src/features/company/CompanyContext.tsx`
- [Role permissions](https://github.com/dev-aylton/controle-app/blob/main/src/lib/uiPermissions.ts): `src/lib/uiPermissions.ts`

### Inventory operations

- [Environments](https://github.com/dev-aylton/controle-app/blob/main/src/features/environments/environmentService.ts): `src/features/environments/environmentService.ts`
- [Product catalog](https://github.com/dev-aylton/controle-app/blob/main/src/features/products/productCatalog.ts): `src/features/products/productCatalog.ts`
- [Product management](https://github.com/dev-aylton/controle-app/blob/main/src/pages/ProductsPage.tsx): `src/pages/ProductsPage.tsx`
- [Movement entry and history](https://github.com/dev-aylton/controle-app/blob/main/src/pages/MovementsPage.tsx): `src/pages/MovementsPage.tsx`
- [Movement form](https://github.com/dev-aylton/controle-app/blob/main/src/features/movements/MovementLaunchForm.tsx): `src/features/movements/MovementLaunchForm.tsx`
- [Movement operations](https://github.com/dev-aylton/controle-app/blob/main/src/services/movements.ts): `src/services/movements.ts`
- [Inventory counts](https://github.com/dev-aylton/controle-app/blob/main/src/pages/InventoryPage.tsx): `src/pages/InventoryPage.tsx`
- [Offline synchronization](https://github.com/dev-aylton/controle-app/blob/main/src/features/offline/sync.ts): `src/features/offline/sync.ts`
- [Offline queue and cache](https://github.com/dev-aylton/controle-app/blob/main/src/features/offline/db.ts): `src/features/offline/db.ts`

### Purchasing and sales

- [Purchase planning](https://github.com/dev-aylton/controle-app/blob/main/src/pages/PurchaseListPage.tsx): `src/pages/PurchaseListPage.tsx`
- [Purchasing rules and services](https://github.com/dev-aylton/controle-app/tree/main/src/features/management): `src/features/management`
- [Sales import and pricing](https://github.com/dev-aylton/controle-app/blob/main/src/pages/SalesImportPage.tsx): `src/pages/SalesImportPage.tsx`
- [Sales operations](https://github.com/dev-aylton/controle-app/blob/main/src/features/sales/salesService.ts): `src/features/sales/salesService.ts`
- [Reports and audit](https://github.com/dev-aylton/controle-app/tree/main/src/pages): `src/pages`

### Shared platform

- [Application routes](https://github.com/dev-aylton/controle-app/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Supabase client](https://github.com/dev-aylton/controle-app/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- **PostgreSQL and RLS**
- [Private support](https://github.com/dev-aylton/controle-app/blob/main/src/features/support/supportService.ts): `src/features/support/supportService.ts`
- [Privacy and account data](https://github.com/dev-aylton/controle-app/tree/main/src/features/privacy): `src/features/privacy`

### Other components

- **Company user**

## Connections

- Company user → Application routes: uses (evidence: `README.md`)
- Application routes → Authentication: provides (evidence: `src/app/App.tsx`)
- Application routes → Company context: provides (evidence: `src/app/App.tsx`)
- Application routes → Product management: routes to (evidence: `src/app/App.tsx`)
- Application routes → Movement entry and history: routes to (evidence: `src/app/App.tsx`)
- Application routes → Inventory counts: routes to (evidence: `src/app/App.tsx`)
- Application routes → Purchase planning: routes to (evidence: `src/app/App.tsx`)
- Application routes → Sales import and pricing: routes to (evidence: `src/app/App.tsx`)
- Application routes → Reports and audit: routes to (evidence: `src/app/App.tsx`)
- Company context → Authentication: reads session (evidence: `src/features/company/CompanyContext.tsx`)
- Company context → Supabase client: loads company data (evidence: `src/features/company/CompanyContext.tsx`)
- Authentication → Supabase client: uses (evidence: `src/features/auth/AuthContext.tsx`)
- Role permissions → Company context: checks role (evidence: `README.md`)
- Product management → Product catalog: uses catalog (evidence: `src/pages/ProductsPage.tsx`)
- Product management → Movement operations: reads stock (evidence: `src/pages/ProductsPage.tsx`)
- Movement entry and history → Movement form: renders (evidence: `src/pages/MovementsPage.tsx`)
- Movement entry and history → Movement operations: records movements (evidence: `src/pages/MovementsPage.tsx`)
- Inventory counts → Movement operations: applies counts (evidence: `src/pages/InventoryPage.tsx`)
- Movement entry and history → Offline synchronization: queues offline (evidence: `src/pages/MovementsPage.tsx`)
- Offline synchronization → Offline queue and cache: reads and writes (evidence: `src/features/offline/sync.ts`)
- Offline synchronization → Movement operations: syncs movements (evidence: `src/features/offline/sync.ts`)
- Purchase planning → Purchasing rules and services: plans replenishment (evidence: `src/pages/PurchaseListPage.tsx`)
- Sales import and pricing → Sales operations: imports sales (evidence: `src/pages/SalesImportPage.tsx`)
- Sales import and pricing → Movement operations: reduces stock (evidence: `src/pages/SalesImportPage.tsx`)
- Movement operations → Supabase client: calls RPCs (evidence: `src/services/movements.ts`)
- Sales operations → Supabase client: calls RPCs (evidence: `src/features/sales/salesService.ts`)
- Supabase client → PostgreSQL and RLS: persists data (evidence: `README.md`)
- Environments → Supabase client: loads environments (evidence: `src/features/environments/environmentService.ts`)
- Private support → Supabase client: stores conversations (evidence: `src/features/support/supportService.ts`)
- Privacy and account data → Company user: supports data rights (evidence: `README.md`)
