# rogeraosilva32-debug/system architecture

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

- Interactive diagram: https://gitdiagram.com/rogeraosilva32-debug/system
- Repository: https://github.com/rogeraosilva32-debug/system

## Overview

ServiçoApp is a B2B field-team management platform licensed per company. The principal workflow is company setup and service registration, followed by assigning a service visit to a collaborator, who views the task, shares location while it is in progress, and completes it. Company and platform administration, messaging, reporting, and CRM/API integrations are distinct capabilities. The graph follows documented workflows and visible routing; unsampled implementation details are represented only where the README supports them.

Main entry points: [`src/App.jsx`](https://github.com/rogeraosilva32-debug/system/blob/main/src/App.jsx) (Role-based app routes), [`src/pages/CompanyAdmin.jsx`](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/CompanyAdmin.jsx) (Company admin), [`src/pages/CollaboratorTasks.jsx`](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/CollaboratorTasks.jsx) (Collaborator tasks), [`src/pages/PlatformAdmin.jsx`](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/PlatformAdmin.jsx) (Platform console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and access"]
  node_company_admin["Company admin<br/>[CompanyAdmin.jsx]"]
  node_app_router["Role-based app routes<br/>[App.jsx]"]
  node_auth["Authentication and roles<br/>[AuthContext.jsx]"]
end

subgraph group_company["Company operations"]
  node_company_settings["Company settings"]
  node_collaborators_services["Collaborators and services"]
  node_assignments["Visit assignments<br/>[AssignmentsTab.jsx]"]
  node_live_map["Company live map<br/>[LiveMapTab.jsx]"]
  node_company_chat["Company messaging<br/>[MessagesTab.jsx]"]
  node_reports["Company reports<br/>[ReportsTab.jsx]"]
end

subgraph group_field["Field work"]
  node_collaborator_tasks["Collaborator tasks"]
  node_route_map["Route mapping<br/>[RouteMap.jsx]"]
  node_address_geocoding["Address geocoding<br/>[geocoding.js]"]
  node_courier_gps["Location sharing<br/>[CourierGps.jsx]"]
  node_gps_client["GPS transport<br/>[gps.js]"]
end

subgraph group_platform["Platform administration"]
  node_platform_console["Platform console<br/>[PlatformAdmin.jsx]"]
  node_audit_log["System event log<br/>[eventLog.js]"]
end

subgraph group_integrations["Integrations and data"]
  node_supabase_client["Supabase client<br/>[supabase.js]"]
  node_crm_import["CRM import function<br/>[index.ts]"]
  node_api_data["Outbound data API<br/>[index.ts]"]
  node_push_function["Push delivery function<br/>[index.ts]"]
  node_supabase[("Supabase backend")]
end

node_collaborator(("Collaborator"))
node_platform_admin(("Platform admin"))
node_crm["External CRM"]
node_external_api_consumer(("External API consumer"))
node_mapping_services["Mapping services"]

node_company_admin -->|"uses company portal"| node_app_router
node_collaborator -->|"uses task portal"| node_app_router
node_platform_admin -->|"uses admin portal"| node_app_router
node_app_router -->|"loads auth state"| node_auth
node_app_router -->|"routes tasks"| node_collaborator_tasks
node_app_router -->|"routes platform admin"| node_platform_console
node_collaborator_tasks -->|"reads and updates tasks"| node_supabase_client
node_company_admin -->|"manages team and services"| node_collaborators_services
node_company_admin -->|"creates assignments"| node_assignments
node_assignments -->|"geocodes addresses"| node_address_geocoding
node_address_geocoding -->|"queries geocoders"| node_mapping_services
node_collaborator_tasks -->|"shows visit route"| node_route_map
node_collaborator_tasks -->|"starts visit tracking"| node_courier_gps
node_courier_gps -->|"uses GPS transport"| node_gps_client
node_gps_client -->|"writes location updates"| node_supabase_client
node_live_map -->|"receives live location"| node_supabase
node_company_admin -->|"manages messages"| node_company_chat
node_company_admin -->|"views reports"| node_reports
node_platform_admin -->|"manages companies"| node_platform_console
node_platform_console -->|"views system log"| node_audit_log
node_audit_log -->|"records events"| node_supabase_client
node_crm -->|"provides CRM records"| node_crm_import
node_crm_import -->|"creates imported records"| node_supabase
node_supabase -->|"serves authorized data"| node_api_data
node_api_data -->|"returns company data"| node_external_api_consumer
node_push_function -.->|"uses backend services"| node_supabase

click node_company_admin "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/CompanyAdmin.jsx"
click node_app_router "https://github.com/rogeraosilva32-debug/system/blob/main/src/App.jsx"
click node_auth "https://github.com/rogeraosilva32-debug/system/blob/main/src/context/AuthContext.jsx"
click node_supabase_client "https://github.com/rogeraosilva32-debug/system/blob/main/src/services/supabase.js"
click node_company_settings "https://github.com/rogeraosilva32-debug/system/blob/main/src/hooks/useCompanySettings.js"
click node_collaborators_services "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/CollaboratorsAndServices.jsx"
click node_assignments "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/AssignmentsTab.jsx"
click node_collaborator_tasks "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/CollaboratorTasks.jsx"
click node_route_map "https://github.com/rogeraosilva32-debug/system/blob/main/src/components/RouteMap.jsx"
click node_address_geocoding "https://github.com/rogeraosilva32-debug/system/blob/main/src/utils/geocoding.js"
click node_courier_gps "https://github.com/rogeraosilva32-debug/system/blob/main/src/context/CourierGps.jsx"
click node_gps_client "https://github.com/rogeraosilva32-debug/system/blob/main/src/utils/gps.js"
click node_live_map "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/LiveMapTab.jsx"
click node_company_chat "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/MessagesTab.jsx"
click node_reports "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/ReportsTab.jsx"
click node_platform_console "https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/PlatformAdmin.jsx"
click node_audit_log "https://github.com/rogeraosilva32-debug/system/blob/main/src/services/eventLog.js"
click node_crm_import "https://github.com/rogeraosilva32-debug/system/blob/main/supabase/functions/crm-import/index.ts"
click node_api_data "https://github.com/rogeraosilva32-debug/system/blob/main/supabase/functions/api-data/index.ts"
click node_push_function "https://github.com/rogeraosilva32-debug/system/blob/main/supabase/functions/send-push/index.ts"

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_company_admin,node_app_router,node_auth toneBlue
class node_company_settings,node_collaborators_services,node_assignments,node_live_map,node_company_chat,node_reports toneAmber
class node_collaborator_tasks,node_route_map,node_address_geocoding,node_courier_gps,node_gps_client,node_external_api_consumer toneMint
class node_platform_console,node_audit_log toneRose
class node_supabase_client,node_crm_import,node_api_data,node_push_function,node_supabase,node_collaborator,node_platform_admin,node_crm,node_mapping_services toneIndigo
```

## Components

### App and access

- [Company admin](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/CompanyAdmin.jsx): `src/pages/CompanyAdmin.jsx`
- [Role-based app routes](https://github.com/rogeraosilva32-debug/system/blob/main/src/App.jsx): `src/App.jsx`
- [Authentication and roles](https://github.com/rogeraosilva32-debug/system/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`

### Company operations

- [Company settings](https://github.com/rogeraosilva32-debug/system/blob/main/src/hooks/useCompanySettings.js): `src/hooks/useCompanySettings.js`
- [Collaborators and services](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/CollaboratorsAndServices.jsx): `src/pages/company/CollaboratorsAndServices.jsx`
- [Visit assignments](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/AssignmentsTab.jsx): `src/pages/company/AssignmentsTab.jsx`
- [Company live map](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/LiveMapTab.jsx): `src/pages/company/LiveMapTab.jsx`
- [Company messaging](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/MessagesTab.jsx): `src/pages/company/MessagesTab.jsx`
- [Company reports](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/company/ReportsTab.jsx): `src/pages/company/ReportsTab.jsx`

### Field work

- [Collaborator tasks](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/CollaboratorTasks.jsx): `src/pages/CollaboratorTasks.jsx`
- [Route mapping](https://github.com/rogeraosilva32-debug/system/blob/main/src/components/RouteMap.jsx): `src/components/RouteMap.jsx`
- [Address geocoding](https://github.com/rogeraosilva32-debug/system/blob/main/src/utils/geocoding.js): `src/utils/geocoding.js`
- [Location sharing](https://github.com/rogeraosilva32-debug/system/blob/main/src/context/CourierGps.jsx): `src/context/CourierGps.jsx`
- [GPS transport](https://github.com/rogeraosilva32-debug/system/blob/main/src/utils/gps.js): `src/utils/gps.js`

### Platform administration

- [Platform console](https://github.com/rogeraosilva32-debug/system/blob/main/src/pages/PlatformAdmin.jsx): `src/pages/PlatformAdmin.jsx`
- [System event log](https://github.com/rogeraosilva32-debug/system/blob/main/src/services/eventLog.js): `src/services/eventLog.js`

### Integrations and data

- [Supabase client](https://github.com/rogeraosilva32-debug/system/blob/main/src/services/supabase.js): `src/services/supabase.js`
- [CRM import function](https://github.com/rogeraosilva32-debug/system/blob/main/supabase/functions/crm-import/index.ts): `supabase/functions/crm-import/index.ts`
- [Outbound data API](https://github.com/rogeraosilva32-debug/system/blob/main/supabase/functions/api-data/index.ts): `supabase/functions/api-data/index.ts`
- [Push delivery function](https://github.com/rogeraosilva32-debug/system/blob/main/supabase/functions/send-push/index.ts): `supabase/functions/send-push/index.ts`
- **Supabase backend**

### Other components

- **Collaborator**
- **Platform admin**
- **External CRM**
- **External API consumer**
- **Mapping services**

## Connections

- Company admin → Role-based app routes: uses company portal (evidence: `src/App.jsx`)
- Collaborator → Role-based app routes: uses task portal
- Platform admin → Role-based app routes: uses admin portal
- Role-based app routes → Authentication and roles: loads auth state (evidence: `src/App.jsx`)
- Role-based app routes → Collaborator tasks: routes tasks (evidence: `src/App.jsx`)
- Role-based app routes → Platform console: routes platform admin (evidence: `src/App.jsx`)
- Collaborator tasks → Supabase client: reads and updates tasks (evidence: `src/pages/CollaboratorTasks.jsx`)
- Company admin → Collaborators and services: manages team and services
- Company admin → Visit assignments: creates assignments
- Visit assignments → Address geocoding: geocodes addresses
- Address geocoding → Mapping services: queries geocoders (evidence: `src/utils/geocoding.js`)
- Collaborator tasks → Route mapping: shows visit route (evidence: `src/pages/CollaboratorTasks.jsx`)
- Collaborator tasks → Location sharing: starts visit tracking
- Location sharing → GPS transport: uses GPS transport (evidence: `src/context/CourierGps.jsx`)
- GPS transport → Supabase client: writes location updates (evidence: `src/utils/gps.js`)
- Company live map → Supabase backend: receives live location
- Company admin → Company messaging: manages messages
- Company admin → Company reports: views reports
- Platform admin → Platform console: manages companies
- Platform console → System event log: views system log (evidence: `src/pages/PlatformAdmin.jsx`)
- System event log → Supabase client: records events (evidence: `src/services/eventLog.js`)
- External CRM → CRM import function: provides CRM records
- CRM import function → Supabase backend: creates imported records
- Supabase backend → Outbound data API: serves authorized data
- Outbound data API → External API consumer: returns company data
- Push delivery function → Supabase backend: uses backend services
