# mafrix07/monexa architecture

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

- Interactive diagram: https://gitdiagram.com/mafrix07/monexa
- Repository: https://github.com/mafrix07/monexa

## Overview

MoneXa is a Django treasury platform for West African SMEs, with a mobile-oriented API and admin back office. The main workflow captures a Mobile Money receipt or SMS, extracts payment details, records and reconciles the payment, then exposes treasury reporting and alerts. The README also documents forecasting, anomaly detection, audit-chain verification, chatbot assistance, and SYSCOHADA/CSV exports. The mobile source and several service implementations are not present in the supplied tree, so their internal wiring is not inferred.

Main entry points: [`backend/finance/viewsets.py`](https://github.com/mafrix07/monexa/blob/main/backend/finance/viewsets.py) (Finance API), [`backend/finance/services/ingest.py`](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/ingest.py) (Payment ingestion), [`backend/reporting/services.py`](https://github.com/mafrix07/monexa/blob/main/backend/reporting/services.py) (KPI computation), [`backend/finance/services/ai_pipeline.py`](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/ai_pipeline.py) (Receipt extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and ledger"]
  node_finance_api["Finance API<br/>[viewsets.py]"]
  node_receipt_extract["Receipt extraction<br/>[ai_pipeline.py]"]
  node_sms_parser["SMS parser<br/>[sms_parser.py]"]
  node_connectors["Transaction connectors<br/>[registry.py]"]
  node_ingest["Payment ingestion<br/>[ingest.py]"]
  node_matcher["Invoice matching<br/>[matcher.py]"]
end

subgraph group_intelligence["Finance intelligence"]
  node_anomalies["Anomaly detection<br/>[anomalies.py]"]
  node_forecast["Cashflow forecast<br/>[forecast.py]"]
  node_llm_client["LLM client<br/>[llm.py]"]
end

subgraph group_oversight["Reporting and audit"]
  node_reporting_api["Reports API<br/>[views.py]"]
  node_kpis["KPI computation<br/>[services.py]"]
  node_exports["Financial exports<br/>[exports.py]"]
  node_assistant_api["TresorIA API<br/>[views.py]"]
  node_assistant_service["TresorIA service<br/>[services.py]"]
  node_audit["Audit chain<br/>[services.py]"]
end

subgraph group_platform["Identity and API"]
  node_accounts_api["Accounts API<br/>[views.py]"]
  node_account_model["User and tenancy<br/>[models.py]"]
end

node_business(("SME staff"))
node_mobile(("Mobile client"))
node_admin(("Django Admin"))
node_llm_provider{{"LLM provider"}}
node_database[("PostgreSQL")]

node_business -->|"uses"| node_mobile
node_mobile -->|"submits evidence"| node_finance_api
node_admin -->|"manages finance"| node_finance_api
node_finance_api -->|"extracts receipt"| node_receipt_extract
node_finance_api -->|"parses SMS"| node_sms_parser
node_finance_api -->|"records payment"| node_ingest
node_receipt_extract -->|"requests extraction"| node_llm_client
node_receipt_extract -->|"parses text"| node_sms_parser
node_llm_client -.->|"calls model"| node_llm_provider
node_connectors -->|"supplies transactions"| node_ingest
node_ingest -->|"matches payment"| node_matcher
node_ingest -->|"checks payment"| node_anomalies
node_reporting_api -->|"computes report"| node_kpis
node_reporting_api -->|"serves exports"| node_exports
node_kpis -->|"forecasts cashflow"| node_forecast
node_assistant_api -->|"answers question"| node_assistant_service
node_assistant_service -->|"gets KPIs"| node_kpis
node_assistant_service -->|"requests wording"| node_llm_client
node_finance_api -->|"reads and writes"| node_database
node_ingest -->|"writes payment"| node_database
node_matcher -->|"reads and updates"| node_database
node_anomalies -->|"reads payment"| node_database
node_kpis -->|"reads finance data"| node_database
node_audit -->|"writes and verifies"| node_database
node_accounts_api -->|"manages accounts"| node_account_model
node_account_model -->|"persists users"| node_database

click node_finance_api "https://github.com/mafrix07/monexa/blob/main/backend/finance/viewsets.py"
click node_receipt_extract "https://github.com/mafrix07/monexa/blob/main/backend/finance/services/ai_pipeline.py"
click node_sms_parser "https://github.com/mafrix07/monexa/blob/main/backend/finance/services/sms_parser.py"
click node_connectors "https://github.com/mafrix07/monexa/blob/main/backend/finance/connectors/registry.py"
click node_ingest "https://github.com/mafrix07/monexa/blob/main/backend/finance/services/ingest.py"
click node_matcher "https://github.com/mafrix07/monexa/blob/main/backend/finance/services/matcher.py"
click node_anomalies "https://github.com/mafrix07/monexa/blob/main/backend/finance/services/anomalies.py"
click node_forecast "https://github.com/mafrix07/monexa/blob/main/backend/finance/services/forecast.py"
click node_llm_client "https://github.com/mafrix07/monexa/blob/main/backend/finance/services/llm.py"
click node_reporting_api "https://github.com/mafrix07/monexa/blob/main/backend/reporting/views.py"
click node_kpis "https://github.com/mafrix07/monexa/blob/main/backend/reporting/services.py"
click node_exports "https://github.com/mafrix07/monexa/blob/main/backend/reporting/exports.py"
click node_assistant_api "https://github.com/mafrix07/monexa/blob/main/backend/assistant/views.py"
click node_assistant_service "https://github.com/mafrix07/monexa/blob/main/backend/assistant/services.py"
click node_audit "https://github.com/mafrix07/monexa/blob/main/backend/auditing/services.py"
click node_accounts_api "https://github.com/mafrix07/monexa/blob/main/backend/accounts/views.py"
click node_account_model "https://github.com/mafrix07/monexa/blob/main/backend/accounts/models.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_finance_api,node_receipt_extract,node_sms_parser,node_connectors,node_ingest,node_matcher,node_mobile toneBlue
class node_anomalies,node_forecast,node_llm_client,node_database toneAmber
class node_reporting_api,node_kpis,node_exports,node_assistant_api,node_assistant_service,node_audit toneMint
class node_accounts_api,node_account_model toneRose
class node_business,node_admin,node_llm_provider toneIndigo
```

## Components

### Capture and ledger

- [Finance API](https://github.com/mafrix07/monexa/blob/main/backend/finance/viewsets.py): `backend/finance/viewsets.py`
- [Receipt extraction](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/ai_pipeline.py): `backend/finance/services/ai_pipeline.py`
- [SMS parser](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/sms_parser.py): `backend/finance/services/sms_parser.py`
- [Transaction connectors](https://github.com/mafrix07/monexa/blob/main/backend/finance/connectors/registry.py): `backend/finance/connectors/registry.py`
- [Payment ingestion](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/ingest.py): `backend/finance/services/ingest.py`
- [Invoice matching](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/matcher.py): `backend/finance/services/matcher.py`

### Finance intelligence

- [Anomaly detection](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/anomalies.py): `backend/finance/services/anomalies.py`
- [Cashflow forecast](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/forecast.py): `backend/finance/services/forecast.py`
- [LLM client](https://github.com/mafrix07/monexa/blob/main/backend/finance/services/llm.py): `backend/finance/services/llm.py`

### Reporting and audit

- [Reports API](https://github.com/mafrix07/monexa/blob/main/backend/reporting/views.py): `backend/reporting/views.py`
- [KPI computation](https://github.com/mafrix07/monexa/blob/main/backend/reporting/services.py): `backend/reporting/services.py`
- [Financial exports](https://github.com/mafrix07/monexa/blob/main/backend/reporting/exports.py): `backend/reporting/exports.py`
- [TresorIA API](https://github.com/mafrix07/monexa/blob/main/backend/assistant/views.py): `backend/assistant/views.py`
- [TresorIA service](https://github.com/mafrix07/monexa/blob/main/backend/assistant/services.py): `backend/assistant/services.py`
- [Audit chain](https://github.com/mafrix07/monexa/blob/main/backend/auditing/services.py): `backend/auditing/services.py`

### Identity and API

- [Accounts API](https://github.com/mafrix07/monexa/blob/main/backend/accounts/views.py): `backend/accounts/views.py`
- [User and tenancy](https://github.com/mafrix07/monexa/blob/main/backend/accounts/models.py): `backend/accounts/models.py`

### Other components

- **SME staff**
- **Mobile client**
- **Django Admin**
- **LLM provider**
- **PostgreSQL**

## Connections

- SME staff → Mobile client: uses
- Mobile client → Finance API: submits evidence
- Django Admin → Finance API: manages finance
- Finance API → Receipt extraction: extracts receipt
- Finance API → SMS parser: parses SMS
- Finance API → Payment ingestion: records payment
- Receipt extraction → LLM client: requests extraction
- Receipt extraction → SMS parser: parses text
- LLM client → LLM provider: calls model
- Transaction connectors → Payment ingestion: supplies transactions
- Payment ingestion → Invoice matching: matches payment
- Payment ingestion → Anomaly detection: checks payment
- Reports API → KPI computation: computes report
- Reports API → Financial exports: serves exports
- KPI computation → Cashflow forecast: forecasts cashflow
- TresorIA API → TresorIA service: answers question
- TresorIA service → KPI computation: gets KPIs
- TresorIA service → LLM client: requests wording
- Finance API → PostgreSQL: reads and writes
- Payment ingestion → PostgreSQL: writes payment
- Invoice matching → PostgreSQL: reads and updates
- Anomaly detection → PostgreSQL: reads payment
- KPI computation → PostgreSQL: reads finance data
- Audit chain → PostgreSQL: writes and verifies
- Accounts API → User and tenancy: manages accounts
- User and tenancy → PostgreSQL: persists users
