How grupototum/totum-system works
1. This repository is a multi-surface operational platform, not a single app. The main product is the TOTUM ecosystem: a React/Vite frontend, a Supabase-backed data layer, a small Node/TypeScript API for tasks, and a set of AI/automation scripts around agents, knowledge ingestion, transcription, and publishing.
2. The primary user interface lives under src/. It is a large React application organized by domain pages and reusable components. The main boundaries are visible in src/pages/ and src/components/: tasks, clients, projects, financial, agents, Alexandria/knowledge, admin/settings, and workspace/ops.
3. The frontend is stateful through React contexts and hooks rather than a single global store. src/contexts/ handles auth, theme, demo/loading state; src/hooks/ contains domain accessors such as tasks, clients, agents, Asaas, RAG, permissions, dashboards, and transcription. This is where UI components connect to backend services.
4. Supabase is the central persistence and backend platform. The repo contains extensive migration history in supabase/migrations/ and feature functions in supabase/functions/, including recurring task generation, checklist generation, task archiving, admin bootstrap, and Asaas proxy/webhook handling. The frontend uses the Supabase client in src/integrations/supabase/.
5. The data model is broad and business-oriented: tasks, projects, clients, contracts, users/roles, financial entries, packages, registries, delivery checklists, SLA rules, and agent logs. The UI modules mirror these tables closely, so the architecture diagram should show tight coupling between feature pages and Supabase tables/functions.
6. There is a secondary backend service in src/stark-api/. It is a standalone Node/TypeScript API with its own build output, routes, controllers, and Supabase connection, centered on task operations. Architecturally, it sits beside the main frontend/Supabase flow as a dedicated service boundary rather than part of the React app.
7. The AI/knowledge subsystem is split from the core business UI. src/components/alexandria/, src/pages/alexandria/, src/hooks/useRAG.ts, and src/services/embeddingService.ts define the knowledge hub in the frontend, while src/context_hub/core/ contains Python code for a curator agent and vector store. This suggests a retrieval/curation pipeline that feeds the Alexandria portal and related skills/context screens.
8. Agent orchestration is a major concept throughout the repo. There are agent definitions in src/agents/, richer agent UI in src/components/agents/ and src/pages/agents/, plus catalogs and docs under agents/, apps/alexandria/, and tarefas/. The architecture likely treats agents as first-class operational entities with hierarchy, metrics, chat, tasks, and execution logs.
9. Automation and content pipelines live in scripts/ and data/. These scripts process transcriptions, ingest content to Supabase, generate daily reports, handle Ollama fallbacks, simulate or publish content for Wanda/Scrivo, and interface with TikTok and Telegram. The data/outputs/, data/logs/, data/backups/, and local .db files act as file-based working storage and audit artifacts for those jobs.
10. External services materially shaping the design are Supabase, Asaas, TikTok, Ollama, Gemini/Groq, Telegram, and sometimes Google Drive/n8n. You can see setup and integration docs for each, plus edge functions and scripts that act as adapters. These are not incidental; they are the integration layer around the product.
11. The repo also includes deployment and operational infrastructure in infra/, with Docker Compose, shell scripts, monitoring, sync, backup, and bootstrap tooling. CI is present via GitHub Actions, and there are local configuration files for environment and workspace state. This makes the system deployable as a mix of frontend, backend, edge functions, and worker scripts.
12. There are multiple UI variants and snapshots, but they are secondary to the main src/ application: apps/totum/ is a standalone packaged frontend, and data-unifica-agentes-ui/ is another agent/dashboard UI prototype. For an architecture diagram, treat these as adjacent presentation surfaces or derivative apps, not the central platform.
13. In practice, the core data flow is: user action in React UI → hook/service layer → Supabase or stark-api → persisted tables/functions → updated dashboards/agent views. Around that core, the AI pipelines ingest documents/transcriptions into local artifacts or vectors, then surface results back into the Alexandria, agents, and content modules.
Main entry points: pages Business Pages · scripts Pipeline Scripts · contexts State Hooks · components Feature UI
Components 18
Main UI
Primary React/Vite application for the TOTUM ecosystem.
- TOTUM UI · Main multi-domain frontend shell and navigation.
src/App.tsx - Business Pages · Core operational screens for tasks, clients, projects, financial, reports, and settings.
src/pages - Feature UI · Reusable UI for tasks, clients, contracts, financial, registries, POP/SLA, and workspace views.
src/components - State Hooks · Auth, demo, loading, permissions, dashboard, and domain access hooks.
src/contexts
Backend Data
Supabase persistence, edge functions, and the small task API service.
- Supabase Client · Frontend integration point for Supabase auth and data access.
src/integrations/supabase/client.ts - Schema Migrations · Business data model history for tasks, clients, contracts, financials, agents, and permissions.
supabase/migrations - Edge Functions · Automation endpoints for recurring tasks, checklists, archiving, admin bootstrap, and Asaas proxy/webhooks.
supabase/functions - Stark API · Standalone Node/TypeScript service for task operations with its own routes and controllers.
src/stark-api/src/index.ts - Task Controller · Task routes and controller logic served by the Stark API boundary.
src/stark-api/src/controllers/tarefasController.ts
Agents & AI
Agent UI, orchestration, knowledge retrieval, and AI services.
- Agents UI · Agent dashboards, chat surfaces, hierarchy views, and execution logs in the frontend.
src/components/agents - Agent Catalog · Markdown-defined agents, roles, and operational prompts used across the platform.
src/agents - Alexandria Hub · Knowledge, skills, and context portal for curation and retrieval workflows.
src/pages/alexandria - RAG Services · Frontend RAG hooks and embedding services backing Alexandria experiences.
src/hooks/useRAG.ts - Curator Core · Python curator agent and vector store for local knowledge processing.
src/context_hub/core - AI Services · Integration layer for Gemini, Ollama, transcription, embeddings, skills, and Telegram.
src/services
Automation Pipelines
Scripts and local artifacts for ingestion, transcription, publishing, and reporting.
- Pipeline Scripts · Batch jobs for ingestion, transcription processing, fallback generation, and publishing automation.
scripts - Working Data · Local outputs, logs, backups, and embedded working files for automation jobs.
data
Ops & Infra
Deployment, sync, backup, and environment tooling.
- Infra Stack · Docker, sync, monitoring, and bootstrap scripts for local and server deployment.
infra
Connections 22
- TOTUM UI → Business Pages: routes to · Main shell routes users into the business and operational screens.
- TOTUM UI → Feature UI: composes · The UI shell is assembled from reusable domain components.
- Business Pages → State Hooks: uses state · Pages rely on hooks and contexts for auth, permissions, data, and dashboard state.
- Feature UI → State Hooks: binds to · Feature components read/write domain state through hooks.
- State Hooks → Supabase Client: fetches data · Hooks bridge UI state to Supabase auth and data access.
- Supabase Client → Schema Migrations: reads schema · Client-side models reflect the migrated database schema.
- Business Pages → Schema Migrations: mirrors tables · Business pages map closely to the underlying business tables and views.
- Edge Functions → Schema Migrations: operates on · Edge functions implement workflows over persisted tables and rules.
- Stark API → Task Controller: exposes · The Stark API hosts task-focused routes and controllers.
- Task Controller → Supabase Client: persists via · Task operations are stored through Supabase connectivity.
- Business Pages → Stark API: delegates tasks · The main UI can use the dedicated task service boundary for task operations.
- Agents UI → Agent Catalog: renders · Agent screens surface the markdown-based agent catalog and roles.
- Agents UI → State Hooks: uses state · Agent dashboards and chat use hooks for execution, classification, and task data.
- Alexandria Hub → RAG Services: uses retrieval · Alexandria screens consume RAG and embedding services.
- RAG Services → Curator Core: feeds curator · Frontend retrieval features connect to the curator/vector-store pipeline.
- AI Services → RAG Services: supports · AI adapters provide embeddings, model calls, and transcription support to RAG flows.
- Pipeline Scripts → Working Data: writes artifacts · Automation jobs produce logs, outputs, backups, and processed media artifacts.
- Pipeline Scripts → Edge Functions: ingests to · Scripts coordinate with Supabase-backed workflows and edge endpoints.
- Pipeline Scripts → AI Services: calls models · Batch pipelines use Ollama, Gemini, Whisper, and Telegram integrations.
- Infra Stack → Pipeline Scripts: runs jobs · Deployment and bootstrap tooling support the automation scripts and workers.
- Infra Stack → Edge Functions: deploys · Infra scripts support local and server-side Supabase function operations.
- Feature UI → Agents UI: links ops · Operational components expose agent-centric views, metrics, and execution controls.