# djdjoss/crm_erp architecture

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

- Interactive diagram: https://gitdiagram.com/djdjoss/crm_erp
- Repository: https://github.com/djdjoss/crm_erp

## Overview

CRM_ERP is a desktop accounting and dossier-management ERP backed by a FastAPI service. The principal workflow is to launch the desktop client, create or select a company dossier, then use accounting screens that call backend routes and persist dossier/accounting records; accounting changes can reach the client through server-sent events. The graph also preserves dossier company lookup and the documented accounting features, invoices, entries and financial reports. Source excerpts are partial, and the README provides no additional capability detail, so unverified links are omitted.

Main entry points: [`backend/modules/dossiers/api/routes_dossiers.py`](https://github.com/djdjoss/crm_erp/blob/main/backend/modules/dossiers/api/routes_dossiers.py) (Dossier API), [`backend/modules/accounting/api/routes_accounting.py`](https://github.com/djdjoss/crm_erp/blob/main/backend/modules/accounting/api/routes_accounting.py) (Accounting API), [`main.py`](https://github.com/djdjoss/crm_erp/blob/main/main.py) (Desktop application), [`backend/main.py`](https://github.com/djdjoss/crm_erp/blob/main/backend/main.py) (API application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Desktop client"]
  node_desktop["Desktop application<br/>[main.py]"]
  node_orchestrator["Runtime orchestrator"]
end

subgraph group_dossiers["Dossier management"]
  node_dossier_ui["Dossier screens<br/>[views.py]"]
  node_dossier_dialog["Dossier creation"]
  node_dossier_service["Dossier creation service"]
  node_dossier_api["Dossier API<br/>[routes_dossiers.py]"]
end

subgraph group_accounting["Accounting"]
  node_accounting_ui["Accounting screens<br/>[views.py]"]
  node_accounting_manager["Dossier accounting setup<br/>[dossier_manager.py]"]
  node_accounting_api["Accounting API"]
end

subgraph group_backend["Backend and persistence"]
  node_accounting_models["Accounting records<br/>[models.py]"]
  node_dossier_models["Dossier records<br/>[models.py]"]
  node_api_app["API application<br/>[main.py]"]
  node_db_sessions["Database sessions"]
  node_local_db[("Desktop SQLite store<br/>[database.py]")]
end

subgraph group_events["Realtime updates"]
  node_event_client["Realtime event client<br/>[realtime_events.py]"]
  node_event_route["Event stream route<br/>[events.py]"]
  node_event_manager["Event dispatcher<br/>[events_manager.py]"]
end

node_user(("ERP user"))
node_pappers["Pappers company data"]

node_user -->|"uses"| node_desktop
node_desktop -->|"starts runtime"| node_orchestrator
node_desktop -->|"opens"| node_accounting_ui
node_desktop -->|"opens"| node_dossier_ui
node_dossier_ui -->|"opens"| node_dossier_dialog
node_dossier_dialog -.->|"creates dossier"| node_dossier_service
node_dossier_service -->|"creates store"| node_local_db
node_accounting_ui -->|"manages dossier"| node_accounting_manager
node_accounting_manager -->|"reads and writes"| node_local_db
node_accounting_ui -.->|"calls API"| node_accounting_api
node_dossier_ui -.->|"calls API"| node_dossier_api
node_orchestrator -.->|"starts backend"| node_api_app
node_api_app -->|"registers routes"| node_accounting_api
node_api_app -->|"registers routes"| node_dossier_api
node_api_app -->|"registers route"| node_event_route
node_accounting_api -->|"gets sessions"| node_db_sessions
node_dossier_api -->|"gets sessions"| node_db_sessions
node_accounting_api -->|"queries records"| node_accounting_models
node_dossier_api -->|"queries records"| node_dossier_models
node_dossier_api -->|"checks entries"| node_accounting_models
node_dossier_api -->|"looks up company"| node_pappers
node_accounting_api -->|"publishes changes"| node_event_manager
node_event_route -->|"subscribes"| node_event_manager
node_event_client -->|"streams events"| node_event_route

click node_desktop "https://github.com/djdjoss/crm_erp/blob/main/main.py"
click node_orchestrator "https://github.com/djdjoss/crm_erp/blob/main/erp_orchestrator.py"
click node_accounting_ui "https://github.com/djdjoss/crm_erp/blob/main/modules/accounting/views.py"
click node_dossier_ui "https://github.com/djdjoss/crm_erp/blob/main/modules/dossiers/views.py"
click node_dossier_dialog "https://github.com/djdjoss/crm_erp/blob/main/modules/dossiers/dossier_create_dialog.py"
click node_dossier_service "https://github.com/djdjoss/crm_erp/blob/main/modules/dossiers/services/create_dossier_service.py"
click node_accounting_manager "https://github.com/djdjoss/crm_erp/blob/main/modules/accounting/dossier_manager.py"
click node_accounting_api "https://github.com/djdjoss/crm_erp/blob/main/backend/modules/accounting/api/routes_accounting.py"
click node_accounting_models "https://github.com/djdjoss/crm_erp/blob/main/backend/modules/accounting/models.py"
click node_dossier_api "https://github.com/djdjoss/crm_erp/blob/main/backend/modules/dossiers/api/routes_dossiers.py"
click node_dossier_models "https://github.com/djdjoss/crm_erp/blob/main/backend/modules/dossiers/models.py"
click node_api_app "https://github.com/djdjoss/crm_erp/blob/main/backend/main.py"
click node_db_sessions "https://github.com/djdjoss/crm_erp/blob/main/backend/connection_manager.py"
click node_local_db "https://github.com/djdjoss/crm_erp/blob/main/core/database.py"
click node_event_client "https://github.com/djdjoss/crm_erp/blob/main/modules/realtime_events.py"
click node_event_route "https://github.com/djdjoss/crm_erp/blob/main/backend/routes/events.py"
click node_event_manager "https://github.com/djdjoss/crm_erp/blob/main/backend/events_manager.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_desktop,node_orchestrator,node_user toneBlue
class node_dossier_ui,node_dossier_dialog,node_dossier_service,node_dossier_api toneAmber
class node_accounting_ui,node_accounting_manager,node_accounting_api toneMint
class node_accounting_models,node_dossier_models,node_api_app,node_db_sessions,node_local_db toneRose
class node_event_client,node_event_route,node_event_manager,node_pappers toneIndigo
```

## Components

### Desktop client

- [Desktop application](https://github.com/djdjoss/crm_erp/blob/main/main.py): `main.py`
- [Runtime orchestrator](https://github.com/djdjoss/crm_erp/blob/main/erp_orchestrator.py): `erp_orchestrator.py`

### Dossier management

- [Dossier screens](https://github.com/djdjoss/crm_erp/blob/main/modules/dossiers/views.py): `modules/dossiers/views.py`
- [Dossier creation](https://github.com/djdjoss/crm_erp/blob/main/modules/dossiers/dossier_create_dialog.py): `modules/dossiers/dossier_create_dialog.py`
- [Dossier creation service](https://github.com/djdjoss/crm_erp/blob/main/modules/dossiers/services/create_dossier_service.py): `modules/dossiers/services/create_dossier_service.py`
- [Dossier API](https://github.com/djdjoss/crm_erp/blob/main/backend/modules/dossiers/api/routes_dossiers.py): `backend/modules/dossiers/api/routes_dossiers.py`

### Accounting

- [Accounting screens](https://github.com/djdjoss/crm_erp/blob/main/modules/accounting/views.py): `modules/accounting/views.py`
- [Dossier accounting setup](https://github.com/djdjoss/crm_erp/blob/main/modules/accounting/dossier_manager.py): `modules/accounting/dossier_manager.py`
- [Accounting API](https://github.com/djdjoss/crm_erp/blob/main/backend/modules/accounting/api/routes_accounting.py): `backend/modules/accounting/api/routes_accounting.py`

### Backend and persistence

- [Accounting records](https://github.com/djdjoss/crm_erp/blob/main/backend/modules/accounting/models.py): `backend/modules/accounting/models.py`
- [Dossier records](https://github.com/djdjoss/crm_erp/blob/main/backend/modules/dossiers/models.py): `backend/modules/dossiers/models.py`
- [API application](https://github.com/djdjoss/crm_erp/blob/main/backend/main.py): `backend/main.py`
- [Database sessions](https://github.com/djdjoss/crm_erp/blob/main/backend/connection_manager.py): `backend/connection_manager.py`
- [Desktop SQLite store](https://github.com/djdjoss/crm_erp/blob/main/core/database.py): `core/database.py`

### Realtime updates

- [Realtime event client](https://github.com/djdjoss/crm_erp/blob/main/modules/realtime_events.py): `modules/realtime_events.py`
- [Event stream route](https://github.com/djdjoss/crm_erp/blob/main/backend/routes/events.py): `backend/routes/events.py`
- [Event dispatcher](https://github.com/djdjoss/crm_erp/blob/main/backend/events_manager.py): `backend/events_manager.py`

### Other components

- **ERP user**
- **Pappers company data**

## Connections

- ERP user → Desktop application: uses (evidence: `main.py`)
- Desktop application → Runtime orchestrator: starts runtime (evidence: `main.py`)
- Desktop application → Accounting screens: opens (evidence: `main.py`)
- Desktop application → Dossier screens: opens (evidence: `main.py`)
- Dossier screens → Dossier creation: opens (evidence: `modules/dossiers/views.py`)
- Dossier creation → Dossier creation service: creates dossier
- Dossier creation service → Desktop SQLite store: creates store (evidence: `modules/dossiers/services/create_dossier_service.py`)
- Accounting screens → Dossier accounting setup: manages dossier (evidence: `modules/accounting/views.py`)
- Dossier accounting setup → Desktop SQLite store: reads and writes (evidence: `modules/accounting/dossier_manager.py`)
- Accounting screens → Accounting API: calls API
- Dossier screens → Dossier API: calls API
- Runtime orchestrator → API application: starts backend
- API application → Accounting API: registers routes (evidence: `backend/main.py`)
- API application → Dossier API: registers routes (evidence: `backend/main.py`)
- API application → Event stream route: registers route (evidence: `backend/main.py`)
- Accounting API → Database sessions: gets sessions (evidence: `backend/modules/accounting/api/routes_accounting.py`)
- Dossier API → Database sessions: gets sessions (evidence: `backend/modules/dossiers/api/routes_dossiers.py`)
- Accounting API → Accounting records: queries records (evidence: `backend/modules/accounting/api/routes_accounting.py`)
- Dossier API → Dossier records: queries records (evidence: `backend/modules/dossiers/api/routes_dossiers.py`)
- Dossier API → Accounting records: checks entries (evidence: `backend/modules/dossiers/api/routes_dossiers.py`)
- Dossier API → Pappers company data: looks up company (evidence: `backend/modules/dossiers/api/routes_dossiers.py`)
- Accounting API → Event dispatcher: publishes changes (evidence: `backend/modules/accounting/api/routes_accounting.py`)
- Event stream route → Event dispatcher: subscribes (evidence: `backend/routes/events.py`)
- Realtime event client → Event stream route: streams events (evidence: `modules/realtime_events.py`)
