# lucascarper/toteminterface architecture

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

- Interactive diagram: https://gitdiagram.com/lucascarper/toteminterface
- Repository: https://github.com/lucascarper/toteminterface

## Overview

MultiLife is a tablet reception kiosk backed by an administrative panel and a FastAPI service that mediates access to SGG and local persistence. The patient flow is: choose a visit type, enter a CPF, identify and confirm the patient, then register arrival and show success or guidance. The panel configures monitored/reception agendas and the kiosk, triggers SGG synchronization, and reviews operation logs. Source evidence is partial: some use cases and UI modules were not excerpted, so uncertain internal calls are omitted; documented product capabilities remain represented.

Main entry points: [`backend/app/api/container.py`](https://github.com/lucascarper/toteminterface/blob/main/backend/app/api/container.py) (Dependency container), [`frontend/src/features/totem/TotemApp.tsx`](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/totem/TotemApp.tsx) (Check-in flow), [`backend/app/main.py`](https://github.com/lucascarper/toteminterface/blob/main/backend/app/main.py) (FastAPI service), [`frontend/src/features/admin/AdminApp.tsx`](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/admin/AdminApp.tsx) (Admin panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_kiosk["Patient kiosk"]
  node_routes["App routes<br/>[App.tsx]"]
  node_kioskflow["Check-in flow<br/>[TotemApp.tsx]"]
  node_kioskstate["Flow state<br/>[machine.ts]"]
  node_cpf["CPF validation<br/>[cpf.ts]"]
  node_totemclient["Kiosk API client<br/>[totem.ts]"]
end

subgraph group_admin["Administration"]
  node_adminui["Admin panel<br/>[AdminApp.tsx]"]
  node_adminconfig["Agenda configuration<br/>[ConfigPage.tsx]"]
  node_adminlogs["Operation logs<br/>[LogsPage.tsx]"]
  node_adminclient["Admin API client<br/>[admin.ts]"]
end

subgraph group_service["API and application"]
  node_api["FastAPI service<br/>[main.py]"]
  node_totemapi["Totem endpoints<br/>[totem.py]"]
  node_adminapi["Admin endpoints<br/>[admin.py]"]
  node_container["Dependency container<br/>[container.py]"]
  node_checkin["Check-in use case"]
  node_identify["Patient identification"]
  node_agendaops["Agenda operations"]
  node_domain["Reception domain<br/>[entities.py]"]
  node_scheduler["Background scheduler<br/>[scheduler.py]"]
end

subgraph group_integration["SGG and persistence"]
  node_sgg["SGG gateway<br/>[http_gateway.py]"]
  node_sggservice["SGG system"]
  node_persistence[("SQL persistence<br/>[repositories.py]")]
  node_database[("Local database")]
end

node_patient(("Patient"))

node_patient -->|"uses kiosk"| node_routes
node_routes -->|"routes to"| node_kioskflow
node_kioskflow -->|"dispatches events"| node_kioskstate
node_kioskflow -->|"validates CPF"| node_cpf
node_kioskflow -->|"requests patient and check-in"| node_totemclient
node_totemclient -.->|"calls API"| node_totemapi
node_patient -->|"uses panel"| node_adminui
node_adminui -.->|"shows configuration"| node_adminconfig
node_adminui -.->|"shows logs"| node_adminlogs
node_adminconfig -.->|"requests configuration"| node_adminclient
node_adminlogs -.->|"requests logs"| node_adminclient
node_adminclient -.->|"calls API"| node_adminapi
node_api -->|"mounts routes"| node_totemapi
node_api -->|"mounts routes"| node_adminapi
node_api -->|"builds dependencies"| node_container
node_container -->|"constructs"| node_checkin
node_container -->|"constructs"| node_identify
node_container -->|"constructs use cases"| node_agendaops
node_container -->|"configures"| node_scheduler
node_scheduler -->|"runs synchronization and cleanup"| node_agendaops
node_checkin -->|"looks up and registers arrival"| node_sgg
node_checkin -->|"uses domain types"| node_domain
node_agendaops -->|"synchronizes agendas"| node_sgg
node_sgg -->|"sends API requests"| node_sggservice
node_container -->|"configures unit of work"| node_persistence
node_persistence -.->|"reads and writes"| node_database

click node_routes "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/App.tsx"
click node_kioskflow "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/totem/TotemApp.tsx"
click node_kioskstate "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/totem/machine.ts"
click node_cpf "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/lib/cpf.ts"
click node_totemclient "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/api/totem.ts"
click node_adminui "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/admin/AdminApp.tsx"
click node_adminconfig "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/admin/ConfigPage.tsx"
click node_adminlogs "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/admin/LogsPage.tsx"
click node_adminclient "https://github.com/lucascarper/toteminterface/blob/main/frontend/src/api/admin.ts"
click node_api "https://github.com/lucascarper/toteminterface/blob/main/backend/app/main.py"
click node_totemapi "https://github.com/lucascarper/toteminterface/blob/main/backend/app/api/routers/totem.py"
click node_adminapi "https://github.com/lucascarper/toteminterface/blob/main/backend/app/api/routers/admin.py"
click node_container "https://github.com/lucascarper/toteminterface/blob/main/backend/app/api/container.py"
click node_checkin "https://github.com/lucascarper/toteminterface/blob/main/backend/app/application/use_cases/realizar_checkin.py"
click node_identify "https://github.com/lucascarper/toteminterface/blob/main/backend/app/application/use_cases/identificar_paciente.py"
click node_agendaops "https://github.com/lucascarper/toteminterface/tree/main/backend/app/application/use_cases"
click node_domain "https://github.com/lucascarper/toteminterface/blob/main/backend/app/domain/entities.py"
click node_scheduler "https://github.com/lucascarper/toteminterface/blob/main/backend/app/infrastructure/scheduler.py"
click node_sgg "https://github.com/lucascarper/toteminterface/blob/main/backend/app/infrastructure/sgg/http_gateway.py"
click node_persistence "https://github.com/lucascarper/toteminterface/blob/main/backend/app/infrastructure/persistence/repositories.py"

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_routes,node_kioskflow,node_kioskstate,node_cpf,node_totemclient toneBlue
class node_adminui,node_adminconfig,node_adminlogs,node_adminclient toneAmber
class node_api,node_totemapi,node_adminapi,node_container,node_checkin,node_identify,node_agendaops,node_domain,node_scheduler toneMint
class node_sgg,node_sggservice,node_persistence,node_database toneRose
class node_patient toneIndigo
```

## Components

### Patient kiosk

- [App routes](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Check-in flow](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/totem/TotemApp.tsx): `frontend/src/features/totem/TotemApp.tsx`
- [Flow state](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/totem/machine.ts): `frontend/src/features/totem/machine.ts`
- [CPF validation](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/lib/cpf.ts): `frontend/src/lib/cpf.ts`
- [Kiosk API client](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/api/totem.ts): `frontend/src/api/totem.ts`

### Administration

- [Admin panel](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/admin/AdminApp.tsx): `frontend/src/features/admin/AdminApp.tsx`
- [Agenda configuration](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/admin/ConfigPage.tsx): `frontend/src/features/admin/ConfigPage.tsx`
- [Operation logs](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/features/admin/LogsPage.tsx): `frontend/src/features/admin/LogsPage.tsx`
- [Admin API client](https://github.com/lucascarper/toteminterface/blob/main/frontend/src/api/admin.ts): `frontend/src/api/admin.ts`

### API and application

- [FastAPI service](https://github.com/lucascarper/toteminterface/blob/main/backend/app/main.py): `backend/app/main.py`
- [Totem endpoints](https://github.com/lucascarper/toteminterface/blob/main/backend/app/api/routers/totem.py): `backend/app/api/routers/totem.py`
- [Admin endpoints](https://github.com/lucascarper/toteminterface/blob/main/backend/app/api/routers/admin.py): `backend/app/api/routers/admin.py`
- [Dependency container](https://github.com/lucascarper/toteminterface/blob/main/backend/app/api/container.py): `backend/app/api/container.py`
- [Check-in use case](https://github.com/lucascarper/toteminterface/blob/main/backend/app/application/use_cases/realizar_checkin.py): `backend/app/application/use_cases/realizar_checkin.py`
- [Patient identification](https://github.com/lucascarper/toteminterface/blob/main/backend/app/application/use_cases/identificar_paciente.py): `backend/app/application/use_cases/identificar_paciente.py`
- [Agenda operations](https://github.com/lucascarper/toteminterface/tree/main/backend/app/application/use_cases): `backend/app/application/use_cases`
- [Reception domain](https://github.com/lucascarper/toteminterface/blob/main/backend/app/domain/entities.py): `backend/app/domain/entities.py`
- [Background scheduler](https://github.com/lucascarper/toteminterface/blob/main/backend/app/infrastructure/scheduler.py): `backend/app/infrastructure/scheduler.py`

### SGG and persistence

- [SGG gateway](https://github.com/lucascarper/toteminterface/blob/main/backend/app/infrastructure/sgg/http_gateway.py): `backend/app/infrastructure/sgg/http_gateway.py`
- **SGG system**
- [SQL persistence](https://github.com/lucascarper/toteminterface/blob/main/backend/app/infrastructure/persistence/repositories.py): `backend/app/infrastructure/persistence/repositories.py`
- **Local database**

### Other components

- **Patient**

## Connections

- Patient → App routes: uses kiosk (evidence: `README.md`)
- App routes → Check-in flow: routes to (evidence: `frontend/src/App.tsx`)
- Check-in flow → Flow state: dispatches events (evidence: `frontend/src/features/totem/TotemApp.tsx`)
- Check-in flow → CPF validation: validates CPF (evidence: `frontend/src/features/totem/TotemApp.tsx`)
- Check-in flow → Kiosk API client: requests patient and check-in (evidence: `frontend/src/features/totem/TotemApp.tsx`)
- Kiosk API client → Totem endpoints: calls API
- Patient → Admin panel: uses panel (evidence: `README.md`)
- Admin panel → Agenda configuration: shows configuration
- Admin panel → Operation logs: shows logs
- Agenda configuration → Admin API client: requests configuration
- Operation logs → Admin API client: requests logs
- Admin API client → Admin endpoints: calls API
- FastAPI service → Totem endpoints: mounts routes (evidence: `backend/app/main.py`)
- FastAPI service → Admin endpoints: mounts routes (evidence: `backend/app/main.py`)
- FastAPI service → Dependency container: builds dependencies (evidence: `backend/app/main.py`)
- Dependency container → Check-in use case: constructs (evidence: `backend/app/api/container.py`)
- Dependency container → Patient identification: constructs (evidence: `backend/app/api/container.py`)
- Dependency container → Agenda operations: constructs use cases (evidence: `backend/app/api/container.py`)
- Dependency container → Background scheduler: configures (evidence: `backend/app/api/container.py`)
- Background scheduler → Agenda operations: runs synchronization and cleanup (evidence: `backend/app/infrastructure/scheduler.py`)
- Check-in use case → SGG gateway: looks up and registers arrival (evidence: `README.md`)
- Check-in use case → Reception domain: uses domain types (evidence: `backend/app/application/use_cases/realizar_checkin.py`)
- Agenda operations → SGG gateway: synchronizes agendas (evidence: `README.md`)
- SGG gateway → SGG system: sends API requests (evidence: `README.md`)
- Dependency container → SQL persistence: configures unit of work (evidence: `backend/app/api/container.py`)
- SQL persistence → Local database: reads and writes
