# cakeysama/retool architecture

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

- Interactive diagram: https://gitdiagram.com/cakeysama/retool
- Repository: https://github.com/cakeysama/retool

## Overview

ReTool is a role-based device and reuse-management application. Users sign in, browse device records, and—according to their permissions—manage device and classification data or submit and follow reuse requests. Administrators also manage users and review audit history. The README gives no further product detail; routing and several context-to-repository relationships are visible in excerpts or the SOURCE INDEX, while some page behavior and integrations are represented only by documented module names.

Main entry points: [`retool/src/App.tsx`](https://github.com/cakeysama/retool/blob/main/retool/src/App.tsx) (App routing and guards), [`retool/src/context/AuthContext.tsx`](https://github.com/cakeysama/retool/blob/main/retool/src/context/AuthContext.tsx) (Authentication and profiles), [`retool/src/context/ReToolContext.tsx`](https://github.com/cakeysama/retool/blob/main/retool/src/context/ReToolContext.tsx) (Application state and actions), [`retool/src/data/repositories`](https://github.com/cakeysama/retool/tree/main/retool/src/data/repositories) (Firestore repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application flow"]
  node_app["App routing and guards<br/>[App.tsx]"]
end

subgraph group_domain["Device workflows"]
  node_devices["Device catalogue<br/>[Dispositivos.tsx]"]
  node_device_detail["Device details"]
  node_device_form["Device editing"]
  node_categories["Classifications<br/>[Categorias.tsx]"]
  node_category_controller["Classification controller"]
  node_reuse["Reuse requests<br/>[Reutilizacoes.tsx]"]
  node_bulk_import["Device batch import"]
  node_spreadsheet["Spreadsheet import parsing"]
  node_domain_models["Domain records"]
end

subgraph group_access["Identity and oversight"]
  node_auth["Authentication and profiles<br/>[AuthContext.tsx]"]
  node_permissions["Role permissions<br/>[usePermissions.ts]"]
  node_user_admin["User administration"]
  node_audit_ui["Audit history<br/>[AuditLogsModal.tsx]"]
  node_notifications_ui["Notifications"]
end

subgraph group_data["Persistence and files"]
  node_state["Application state and actions<br/>[ReToolContext.tsx]"]
  node_repositories["Firestore repositories"]
  node_firebase[("Firebase data source<br/>[firebase.ts]")]
  node_storage_service["Attachment storage"]
end

node_user(("ReTool user"))
node_storage[("Firebase Storage")]

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"provides state"| node_state
node_app -->|"routes to"| node_devices
node_app -->|"routes to"| node_device_detail
node_app -->|"routes to"| node_categories
node_app -->|"routes to"| node_reuse
node_categories -->|"uses"| node_category_controller
node_category_controller -->|"reads and updates"| node_state
node_categories -->|"checks access"| node_permissions
node_device_detail -->|"reads and updates"| node_state
node_device_detail -->|"checks access"| node_permissions
node_state -->|"calls"| node_repositories
node_state -->|"invokes"| node_bulk_import
node_bulk_import -->|"imports batch"| node_repositories
node_auth -->|"calls"| node_repositories
node_auth -->|"auth services"| node_firebase
node_auth -->|"uses profiles and logs"| node_domain_models
node_state -->|"uses records"| node_domain_models
node_repositories -->|"reads and writes"| node_firebase
node_repositories -->|"uses attachments"| node_storage_service
node_storage_service -->|"uses Firebase client"| node_firebase
node_storage_service -->|"uploads and deletes"| node_storage
node_auth -.->|"exposes management"| node_user_admin
node_auth -.->|"exposes audit history"| node_audit_ui
node_auth -.->|"exposes notifications"| node_notifications_ui
node_spreadsheet -.->|"feeds parsed data"| node_bulk_import

click node_app "https://github.com/cakeysama/retool/blob/main/retool/src/App.tsx"
click node_devices "https://github.com/cakeysama/retool/blob/main/retool/src/pages/Dispositivos.tsx"
click node_device_detail "https://github.com/cakeysama/retool/blob/main/retool/src/pages/DispositivoDetails.tsx"
click node_device_form "https://github.com/cakeysama/retool/blob/main/retool/src/pages/DispositivoForm.tsx"
click node_categories "https://github.com/cakeysama/retool/blob/main/retool/src/pages/Categorias.tsx"
click node_category_controller "https://github.com/cakeysama/retool/blob/main/retool/src/presentation/hooks/useCategoriasController.ts"
click node_reuse "https://github.com/cakeysama/retool/blob/main/retool/src/pages/Reutilizacoes.tsx"
click node_bulk_import "https://github.com/cakeysama/retool/blob/main/retool/src/application/usecases/ImportarLoteUseCase.ts"
click node_spreadsheet "https://github.com/cakeysama/retool/blob/main/retool/src/application/importacao/planilhaDispositivos.ts"
click node_domain_models "https://github.com/cakeysama/retool/tree/main/retool/src/domain/entities"
click node_auth "https://github.com/cakeysama/retool/blob/main/retool/src/context/AuthContext.tsx"
click node_permissions "https://github.com/cakeysama/retool/blob/main/retool/src/hooks/usePermissions.ts"
click node_user_admin "https://github.com/cakeysama/retool/blob/main/retool/src/components/UsersManagementModal.tsx"
click node_audit_ui "https://github.com/cakeysama/retool/blob/main/retool/src/components/AuditLogsModal.tsx"
click node_notifications_ui "https://github.com/cakeysama/retool/blob/main/retool/src/components/NotificationsMenu.tsx"
click node_state "https://github.com/cakeysama/retool/blob/main/retool/src/context/ReToolContext.tsx"
click node_repositories "https://github.com/cakeysama/retool/tree/main/retool/src/data/repositories"
click node_firebase "https://github.com/cakeysama/retool/blob/main/retool/src/data/datasources/firebase.ts"
click node_storage_service "https://github.com/cakeysama/retool/blob/main/retool/src/data/services/FirebaseStorageService.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_app,node_user toneBlue
class node_devices,node_device_detail,node_device_form,node_categories,node_category_controller,node_reuse,node_bulk_import,node_spreadsheet,node_domain_models,node_storage toneAmber
class node_auth,node_permissions,node_user_admin,node_audit_ui,node_notifications_ui toneMint
class node_state,node_repositories,node_firebase,node_storage_service toneRose
```

## Components

### Application flow

- [App routing and guards](https://github.com/cakeysama/retool/blob/main/retool/src/App.tsx): `retool/src/App.tsx`

### Device workflows

- [Device catalogue](https://github.com/cakeysama/retool/blob/main/retool/src/pages/Dispositivos.tsx): `retool/src/pages/Dispositivos.tsx`
- [Device details](https://github.com/cakeysama/retool/blob/main/retool/src/pages/DispositivoDetails.tsx): `retool/src/pages/DispositivoDetails.tsx`
- [Device editing](https://github.com/cakeysama/retool/blob/main/retool/src/pages/DispositivoForm.tsx): `retool/src/pages/DispositivoForm.tsx`
- [Classifications](https://github.com/cakeysama/retool/blob/main/retool/src/pages/Categorias.tsx): `retool/src/pages/Categorias.tsx`
- [Classification controller](https://github.com/cakeysama/retool/blob/main/retool/src/presentation/hooks/useCategoriasController.ts): `retool/src/presentation/hooks/useCategoriasController.ts`
- [Reuse requests](https://github.com/cakeysama/retool/blob/main/retool/src/pages/Reutilizacoes.tsx): `retool/src/pages/Reutilizacoes.tsx`
- [Device batch import](https://github.com/cakeysama/retool/blob/main/retool/src/application/usecases/ImportarLoteUseCase.ts): `retool/src/application/usecases/ImportarLoteUseCase.ts`
- [Spreadsheet import parsing](https://github.com/cakeysama/retool/blob/main/retool/src/application/importacao/planilhaDispositivos.ts): `retool/src/application/importacao/planilhaDispositivos.ts`
- [Domain records](https://github.com/cakeysama/retool/tree/main/retool/src/domain/entities): `retool/src/domain/entities`

### Identity and oversight

- [Authentication and profiles](https://github.com/cakeysama/retool/blob/main/retool/src/context/AuthContext.tsx): `retool/src/context/AuthContext.tsx`
- [Role permissions](https://github.com/cakeysama/retool/blob/main/retool/src/hooks/usePermissions.ts): `retool/src/hooks/usePermissions.ts`
- [User administration](https://github.com/cakeysama/retool/blob/main/retool/src/components/UsersManagementModal.tsx): `retool/src/components/UsersManagementModal.tsx`
- [Audit history](https://github.com/cakeysama/retool/blob/main/retool/src/components/AuditLogsModal.tsx): `retool/src/components/AuditLogsModal.tsx`
- [Notifications](https://github.com/cakeysama/retool/blob/main/retool/src/components/NotificationsMenu.tsx): `retool/src/components/NotificationsMenu.tsx`

### Persistence and files

- [Application state and actions](https://github.com/cakeysama/retool/blob/main/retool/src/context/ReToolContext.tsx): `retool/src/context/ReToolContext.tsx`
- [Firestore repositories](https://github.com/cakeysama/retool/tree/main/retool/src/data/repositories): `retool/src/data/repositories`
- [Firebase data source](https://github.com/cakeysama/retool/blob/main/retool/src/data/datasources/firebase.ts): `retool/src/data/datasources/firebase.ts`
- [Attachment storage](https://github.com/cakeysama/retool/blob/main/retool/src/data/services/FirebaseStorageService.ts): `retool/src/data/services/FirebaseStorageService.ts`

### Other components

- **ReTool user**
- **Firebase Storage**

## Connections

- ReTool user → App routing and guards: uses
- App routing and guards → Authentication and profiles: provides auth (evidence: `retool/src/App.tsx`)
- App routing and guards → Application state and actions: provides state (evidence: `retool/src/App.tsx`)
- App routing and guards → Device catalogue: routes to (evidence: `retool/src/App.tsx`)
- App routing and guards → Device details: routes to (evidence: `retool/src/App.tsx`)
- App routing and guards → Classifications: routes to (evidence: `retool/src/App.tsx`)
- App routing and guards → Reuse requests: routes to (evidence: `retool/src/App.tsx`)
- Classifications → Classification controller: uses (evidence: `retool/src/pages/Categorias.tsx`)
- Classification controller → Application state and actions: reads and updates (evidence: `retool/src/presentation/hooks/useCategoriasController.ts`)
- Classifications → Role permissions: checks access (evidence: `retool/src/pages/Categorias.tsx`)
- Device details → Application state and actions: reads and updates (evidence: `retool/src/pages/DispositivoDetails.tsx`)
- Device details → Role permissions: checks access (evidence: `retool/src/pages/DispositivoDetails.tsx`)
- Application state and actions → Firestore repositories: calls (evidence: `retool/src/context/ReToolContext.tsx`)
- Application state and actions → Device batch import: invokes (evidence: `retool/src/context/ReToolContext.tsx`)
- Device batch import → Firestore repositories: imports batch (evidence: `retool/src/application/usecases/ImportarLoteUseCase.ts`)
- Authentication and profiles → Firestore repositories: calls (evidence: `retool/src/context/AuthContext.tsx`)
- Authentication and profiles → Firebase data source: auth services (evidence: `retool/src/context/AuthContext.tsx`)
- Authentication and profiles → Domain records: uses profiles and logs (evidence: `retool/src/context/AuthContext.tsx`)
- Application state and actions → Domain records: uses records (evidence: `retool/src/context/ReToolContext.tsx`)
- Firestore repositories → Firebase data source: reads and writes (evidence: `retool/src/data/repositories/FirestoreDispositivosRepository.ts`)
- Firestore repositories → Attachment storage: uses attachments (evidence: `retool/src/data/repositories/FirestoreDispositivosRepository.ts`)
- Attachment storage → Firebase data source: uses Firebase client (evidence: `retool/src/data/services/FirebaseStorageService.ts`)
- Attachment storage → Firebase Storage: uploads and deletes (evidence: `retool/src/data/services/FirebaseStorageService.ts`)
- Authentication and profiles → User administration: exposes management
- Authentication and profiles → Audit history: exposes audit history
- Authentication and profiles → Notifications: exposes notifications
- Spreadsheet import parsing → Device batch import: feeds parsed data
