# omnisoft-africa-it-engineering/femi_api architecture

> Architecture diagram of the GitHub repository omnisoft-africa-it-engineering/femi_api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/omnisoft-africa-it-engineering/femi_api
- Repository: https://github.com/omnisoft-africa-it-engineering/femi_api

## Overview

Femi is an AI accounting and financial assistant for SMEs. A WhatsApp user sends text, an image, or audio; the background task resolves the account, hands the message to the router, and returns its response. The agent layer handles intent routing and specialized accounting, customer, and analytical work; an older extraction pipeline also handles OCR/audio and operation creation. Account data, KPI reporting, fiscal deadlines, payments, and notifications are supporting product capabilities. Sampled code confirms the WhatsApp task and legacy extraction paths; wiring among several newer agent stages is not fully visible, so uncertain links are omitted.

Main entry points: [`apps/femi_whatsapp/tasks.py`](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/tasks.py) (Message task), [`apps/femi_account/models.py`](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/models.py) (Account records), [`apps/femi_agent/agent/router_manager.py`](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/router_manager.py) (Intent router), [`apps/femi_whatsapp/whatsapp_client.py`](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/whatsapp_client.py) (WhatsApp client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_channels["User channels"]
  node_whatsapp_webhook["WhatsApp webhook<br/>[views.py]"]
  node_whatsapp_task["Message task<br/>[tasks.py]"]
  node_whatsapp_client["WhatsApp client<br/>[whatsapp_client.py]"]
  node_api["REST API<br/>[views.py]"]
end

subgraph group_agent["AI agent"]
  node_router["Intent router<br/>[router_manager.py]"]
  node_router_executor["Router executor<br/>[router_executor.py]"]
  node_specialists["Specialist agents"]
  node_schemas["Agent schemas"]
  node_legacy_manager["Extraction manager<br/>[manager.py]"]
  node_pipeline["Extraction pipeline<br/>[pipeline.py]"]
  node_parsers["Media parsers"]
end

subgraph group_accounting["Accounting services"]
  node_accounting_manager["Accounting persistence"]
  node_account_views["Account endpoints<br/>[views.py]"]
  node_account_models[("Account records<br/>[models.py]")]
  node_kpi_views["KPI endpoints<br/>[kpi_views.py]"]
  node_kpi_service["KPI calculations<br/>[kpi_service.py]"]
  node_fiscal["Fiscal deadlines<br/>[services.py]"]
end

subgraph group_account["Account platform"]
  node_payments["Payment integration<br/>[fedapay_payment.py]"]
  node_storage["Evidence storage"]
  node_notifications["Notifications<br/>[notifications.py]"]
end

node_user(("SME user"))
node_meta(("Meta WhatsApp"))
node_supabase[("Supabase Storage")]
node_fedapay(("FedaPay"))

node_user -->|"sends message"| node_whatsapp_webhook
node_whatsapp_webhook -->|"enqueues"| node_whatsapp_task
node_whatsapp_task -->|"downloads media"| node_whatsapp_client
node_whatsapp_client -->|"requests media"| node_meta
node_whatsapp_task -->|"resolves user"| node_account_models
node_whatsapp_task -->|"routes content"| node_router
node_router -->|"classifies intent"| node_router_executor
node_router -->|"dispatches intents"| node_specialists
node_router -->|"validates results"| node_schemas
node_router -->|"returns response"| node_whatsapp_task
node_whatsapp_task -->|"sends reply"| node_whatsapp_client
node_whatsapp_client -->|"sends message"| node_meta
node_user -->|"submits request"| node_api
node_legacy_manager -->|"extracts operation"| node_pipeline
node_pipeline -->|"extracts media text"| node_parsers
node_legacy_manager -->|"reads and saves"| node_account_models
node_accounting_manager -->|"persists transactions"| node_account_models
node_account_views -->|"reads and updates"| node_account_models
node_kpi_views -->|"calculates metrics"| node_kpi_service
node_kpi_service -->|"aggregates records"| node_account_models
node_fiscal -->|"creates deadlines"| node_account_models
node_payments -.->|"calls payment API"| node_fedapay
node_storage -->|"uploads evidence"| node_supabase

click node_whatsapp_webhook "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/views.py"
click node_whatsapp_task "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/tasks.py"
click node_whatsapp_client "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/whatsapp_client.py"
click node_api "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_api/views.py"
click node_router "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/router_manager.py"
click node_router_executor "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/router_executor.py"
click node_specialists "https://github.com/omnisoft-africa-it-engineering/femi_api/tree/main/apps/femi_agent/agent"
click node_schemas "https://github.com/omnisoft-africa-it-engineering/femi_api/tree/main/apps/femi_agent/schemas"
click node_legacy_manager "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/manager.py"
click node_pipeline "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/pipeline.py"
click node_parsers "https://github.com/omnisoft-africa-it-engineering/femi_api/tree/main/apps/femi_agent/parsers"
click node_accounting_manager "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/accounting_manager.py"
click node_account_views "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/views.py"
click node_account_models "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/models.py"
click node_kpi_views "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/kpi_views.py"
click node_kpi_service "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/kpi_service.py"
click node_fiscal "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/services.py"
click node_payments "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/integrations/fedapay_payment.py"
click node_storage "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/integrations/supabase_storage.py"
click node_notifications "https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/notifications.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_whatsapp_webhook,node_whatsapp_task,node_whatsapp_client,node_api,node_user toneBlue
class node_router,node_router_executor,node_specialists,node_schemas,node_legacy_manager,node_pipeline,node_parsers,node_supabase toneAmber
class node_accounting_manager,node_account_views,node_account_models,node_kpi_views,node_kpi_service,node_fiscal toneMint
class node_payments,node_storage,node_notifications toneRose
class node_meta,node_fedapay toneIndigo
```

## Components

### User channels

- [WhatsApp webhook](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/views.py): `apps/femi_whatsapp/views.py`
- [Message task](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/tasks.py): `apps/femi_whatsapp/tasks.py`
- [WhatsApp client](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_whatsapp/whatsapp_client.py): `apps/femi_whatsapp/whatsapp_client.py`
- [REST API](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_api/views.py): `apps/femi_api/views.py`

### AI agent

- [Intent router](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/router_manager.py): `apps/femi_agent/agent/router_manager.py`
- [Router executor](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/router_executor.py): `apps/femi_agent/agent/router_executor.py`
- [Specialist agents](https://github.com/omnisoft-africa-it-engineering/femi_api/tree/main/apps/femi_agent/agent): `apps/femi_agent/agent`
- [Agent schemas](https://github.com/omnisoft-africa-it-engineering/femi_api/tree/main/apps/femi_agent/schemas): `apps/femi_agent/schemas`
- [Extraction manager](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/manager.py): `apps/femi_agent/agent/manager.py`
- [Extraction pipeline](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/pipeline.py): `apps/femi_agent/agent/pipeline.py`
- [Media parsers](https://github.com/omnisoft-africa-it-engineering/femi_api/tree/main/apps/femi_agent/parsers): `apps/femi_agent/parsers`

### Accounting services

- [Accounting persistence](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_agent/agent/accounting_manager.py): `apps/femi_agent/agent/accounting_manager.py`
- [Account endpoints](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/views.py): `apps/femi_account/views.py`
- [Account records](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/models.py): `apps/femi_account/models.py`
- [KPI endpoints](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/kpi_views.py): `apps/femi_account/kpi_views.py`
- [KPI calculations](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/kpi_service.py): `apps/femi_account/kpi_service.py`
- [Fiscal deadlines](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/services.py): `apps/femi_account/services.py`

### Account platform

- [Payment integration](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/integrations/fedapay_payment.py): `apps/femi_account/integrations/fedapay_payment.py`
- [Evidence storage](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/integrations/supabase_storage.py): `apps/femi_account/integrations/supabase_storage.py`
- [Notifications](https://github.com/omnisoft-africa-it-engineering/femi_api/blob/main/apps/femi_account/notifications.py): `apps/femi_account/notifications.py`

### Other components

- **SME user**
- **Meta WhatsApp**
- **Supabase Storage**
- **FedaPay**

## Connections

- SME user → WhatsApp webhook: sends message
- WhatsApp webhook → Message task: enqueues
- Message task → WhatsApp client: downloads media
- WhatsApp client → Meta WhatsApp: requests media
- Message task → Account records: resolves user
- Message task → Intent router: routes content
- Intent router → Router executor: classifies intent
- Intent router → Specialist agents: dispatches intents
- Intent router → Agent schemas: validates results
- Intent router → Message task: returns response
- Message task → WhatsApp client: sends reply
- WhatsApp client → Meta WhatsApp: sends message
- SME user → REST API: submits request
- Extraction manager → Extraction pipeline: extracts operation
- Extraction pipeline → Media parsers: extracts media text
- Extraction manager → Account records: reads and saves
- Accounting persistence → Account records: persists transactions
- Account endpoints → Account records: reads and updates
- KPI endpoints → KPI calculations: calculates metrics
- KPI calculations → Account records: aggregates records
- Fiscal deadlines → Account records: creates deadlines
- Payment integration → FedaPay: calls payment API
- Evidence storage → Supabase Storage: uploads evidence
