# cyber-core-technology/pycore architecture

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

- Interactive diagram: https://gitdiagram.com/cyber-core-technology/pycore
- Repository: https://github.com/cyber-core-technology/pycore

## Overview

PyCore ERP is a multi-tenant ERP for Mexican SMBs, with a React/PWA client and Django REST backend. The main user flow is an employee using the protected client to authenticate, work in an operational module, and receive a result through the API; the README describes the backend’s ViewSet → Service → Repository → Model layering. Operational domains include inventory, purchasing, sales, finance, HR, and storefront, alongside administration and customer records. Domain events are queued for Celery processing and can update WebSocket clients. Relationships not directly demonstrated by excerpts are included only where the README or source index documents them; unsampled modules are not treated as inspected.

Main entry points: [`backend/pycore/urls.py`](https://github.com/cyber-core-technology/pycore/blob/main/backend/pycore/urls.py) (Django API), [`backend/shared/events/event_bus.py`](https://github.com/cyber-core-technology/pycore/blob/main/backend/shared/events/event_bus.py) (Domain event bus), [`backend/apps/storefront/services/cliente_auth_service.py`](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/storefront/services/cliente_auth_service.py) (Store customer auth), [`frontend/src/App.tsx`](https://github.com/cyber-core-technology/pycore/blob/main/frontend/src/App.tsx) (React ERP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_spa["React ERP<br/>[App.tsx]"]
  node_client_routes["Protected routes<br/>[routes.ts]"]
  node_client_api["API clients"]
end

subgraph group_identity["Identity and tenancy"]
  node_api["Django API<br/>[urls.py]"]
  node_auth["User authentication<br/>[auth_service.py]"]
  node_twofa["Two-factor auth<br/>[two_fa_service.py]"]
  node_tenant["Tenant context"]
  node_core_admin["Company setup"]
  node_store_auth["Store customer auth"]
end

subgraph group_operations["Business operations"]
  node_catalogs["Business catalogs"]
  node_customers["Customers and suppliers"]
  node_inventory["Inventory and scanning"]
  node_purchases["Purchasing<br/>[compra_service.py]"]
  node_sales["POS and sales<br/>[venta_service.py]"]
  node_finance["Finance and payments<br/>[cxc_service.py]"]
  node_hr["HR and attendance"]
  node_storefront["Online storefront"]
end

subgraph group_platform["Events and realtime"]
  node_audit["Audit logging<br/>[handlers.py]"]
  node_event_bus["Domain event bus<br/>[event_bus.py]"]
  node_event_tasks["Async event tasks<br/>[tasks.py]"]
  node_websocket["WebSocket consumers<br/>[consumers.py]"]
  node_sync["Offline POS sync<br/>[push_service.py]"]
  node_notifications["Push notifications<br/>[push_service.py]"]
end

subgraph group_data["Persistence and integrations"]
  node_store_models[("Storefront records")]
  node_database[("PostgreSQL")]
end

node_employee(("ERP user"))

node_employee -->|"uses"| node_spa
node_spa -->|"navigates"| node_client_routes
node_client_routes -.->|"requests data"| node_client_api
node_client_api -->|"HTTPS API"| node_api
node_api -.->|"routes requests"| node_auth
node_auth -->|"verifies second factor"| node_twofa
node_api -->|"resolves tenant"| node_tenant
node_tenant -.->|"scopes company context"| node_core_admin
node_api -.->|"routes operations"| node_catalogs
node_api -.->|"routes operations"| node_customers
node_api -.->|"routes operations"| node_inventory
node_api -.->|"routes operations"| node_purchases
node_api -.->|"routes operations"| node_sales
node_api -.->|"routes operations"| node_finance
node_api -.->|"routes operations"| node_hr
node_api -.->|"serves store"| node_storefront
node_store_auth -->|"checks second factor"| node_twofa
node_store_auth -->|"authenticates customers"| node_store_models
node_storefront -->|"uses records"| node_store_models
node_inventory -.->|"persists stock"| node_database
node_api -->|"publishes events"| node_event_bus
node_event_bus -->|"queues processing"| node_event_tasks
node_event_tasks -->|"processes events"| node_event_bus
node_event_bus -->|"bridges updates"| node_websocket
node_event_bus -->|"dispatches events"| node_audit
node_event_bus -.->|"handlers persist records"| node_database
node_api -.->|"supports offline sync"| node_sync
node_api -.->|"serves notifications"| node_notifications

click node_spa "https://github.com/cyber-core-technology/pycore/blob/main/frontend/src/App.tsx"
click node_client_routes "https://github.com/cyber-core-technology/pycore/blob/main/frontend/src/router/routes.ts"
click node_client_api "https://github.com/cyber-core-technology/pycore/tree/main/frontend/src/api"
click node_api "https://github.com/cyber-core-technology/pycore/blob/main/backend/pycore/urls.py"
click node_auth "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/auth_module/services/auth_service.py"
click node_twofa "https://github.com/cyber-core-technology/pycore/blob/main/backend/shared/two_fa_service.py"
click node_tenant "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/core/middleware/tenant_middleware.py"
click node_core_admin "https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/core/services"
click node_catalogs "https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/catalogs/services"
click node_customers "https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/terceros/services"
click node_inventory "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/inventory/services/movimiento_service.py"
click node_purchases "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/purchases/services/compra_service.py"
click node_sales "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/sales/services/venta_service.py"
click node_finance "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/finance/services/cxc_service.py"
click node_hr "https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/hr/services"
click node_storefront "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/storefront/services/storefront_service.py"
click node_store_auth "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/storefront/services/cliente_auth_service.py"
click node_store_models "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/storefront/models/cliente_storefront.py"
click node_audit "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/audit/events/handlers.py"
click node_event_bus "https://github.com/cyber-core-technology/pycore/blob/main/backend/shared/events/event_bus.py"
click node_event_tasks "https://github.com/cyber-core-technology/pycore/blob/main/backend/shared/events/tasks.py"
click node_websocket "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/ws/consumers.py"
click node_sync "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/sync/services/push_service.py"
click node_notifications "https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/notifications/services/push_service.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_spa,node_client_routes,node_client_api,node_employee toneBlue
class node_api,node_auth,node_twofa,node_tenant,node_core_admin,node_store_auth toneAmber
class node_catalogs,node_customers,node_inventory,node_purchases,node_sales,node_finance,node_hr,node_storefront toneMint
class node_audit,node_event_bus,node_event_tasks,node_websocket,node_sync,node_notifications toneRose
class node_store_models,node_database toneIndigo
```

## Components

### Client experience

- [React ERP](https://github.com/cyber-core-technology/pycore/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Protected routes](https://github.com/cyber-core-technology/pycore/blob/main/frontend/src/router/routes.ts): `frontend/src/router/routes.ts`
- [API clients](https://github.com/cyber-core-technology/pycore/tree/main/frontend/src/api): `frontend/src/api`

### Identity and tenancy

- [Django API](https://github.com/cyber-core-technology/pycore/blob/main/backend/pycore/urls.py): `backend/pycore/urls.py`
- [User authentication](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/auth_module/services/auth_service.py): `backend/apps/auth_module/services/auth_service.py`
- [Two-factor auth](https://github.com/cyber-core-technology/pycore/blob/main/backend/shared/two_fa_service.py): `backend/shared/two_fa_service.py`
- [Tenant context](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/core/middleware/tenant_middleware.py): `backend/apps/core/middleware/tenant_middleware.py`
- [Company setup](https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/core/services): `backend/apps/core/services`
- [Store customer auth](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/storefront/services/cliente_auth_service.py): `backend/apps/storefront/services/cliente_auth_service.py`

### Business operations

- [Business catalogs](https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/catalogs/services): `backend/apps/catalogs/services`
- [Customers and suppliers](https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/terceros/services): `backend/apps/terceros/services`
- [Inventory and scanning](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/inventory/services/movimiento_service.py): `backend/apps/inventory/services/movimiento_service.py`
- [Purchasing](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/purchases/services/compra_service.py): `backend/apps/purchases/services/compra_service.py`
- [POS and sales](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/sales/services/venta_service.py): `backend/apps/sales/services/venta_service.py`
- [Finance and payments](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/finance/services/cxc_service.py): `backend/apps/finance/services/cxc_service.py`
- [HR and attendance](https://github.com/cyber-core-technology/pycore/tree/main/backend/apps/hr/services): `backend/apps/hr/services`
- [Online storefront](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/storefront/services/storefront_service.py): `backend/apps/storefront/services/storefront_service.py`

### Events and realtime

- [Audit logging](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/audit/events/handlers.py): `backend/apps/audit/events/handlers.py`
- [Domain event bus](https://github.com/cyber-core-technology/pycore/blob/main/backend/shared/events/event_bus.py): `backend/shared/events/event_bus.py`
- [Async event tasks](https://github.com/cyber-core-technology/pycore/blob/main/backend/shared/events/tasks.py): `backend/shared/events/tasks.py`
- [WebSocket consumers](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/ws/consumers.py): `backend/apps/ws/consumers.py`
- [Offline POS sync](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/sync/services/push_service.py): `backend/apps/sync/services/push_service.py`
- [Push notifications](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/notifications/services/push_service.py): `backend/apps/notifications/services/push_service.py`

### Persistence and integrations

- [Storefront records](https://github.com/cyber-core-technology/pycore/blob/main/backend/apps/storefront/models/cliente_storefront.py): `backend/apps/storefront/models/cliente_storefront.py`
- **PostgreSQL**

### Other components

- **ERP user**

## Connections

- ERP user → React ERP: uses
- React ERP → Protected routes: navigates (evidence: `frontend/src/App.tsx`)
- Protected routes → API clients: requests data
- API clients → Django API: HTTPS API
- Django API → User authentication: routes requests
- User authentication → Two-factor auth: verifies second factor (evidence: `backend/apps/auth_module/services/auth_service.py`)
- Django API → Tenant context: resolves tenant
- Tenant context → Company setup: scopes company context
- Django API → Business catalogs: routes operations
- Django API → Customers and suppliers: routes operations
- Django API → Inventory and scanning: routes operations
- Django API → Purchasing: routes operations
- Django API → POS and sales: routes operations
- Django API → Finance and payments: routes operations
- Django API → HR and attendance: routes operations
- Django API → Online storefront: serves store
- Store customer auth → Two-factor auth: checks second factor (evidence: `backend/apps/storefront/services/cliente_auth_service.py`)
- Store customer auth → Storefront records: authenticates customers (evidence: `backend/apps/storefront/services/cliente_auth_service.py`)
- Online storefront → Storefront records: uses records (evidence: `backend/apps/storefront/services/storefront_service.py`)
- Inventory and scanning → PostgreSQL: persists stock
- Django API → Domain event bus: publishes events
- Domain event bus → Async event tasks: queues processing (evidence: `backend/shared/events/event_bus.py`)
- Async event tasks → Domain event bus: processes events (evidence: `backend/shared/events/tasks.py`)
- Domain event bus → WebSocket consumers: bridges updates (evidence: `backend/shared/events/event_bus.py`)
- Domain event bus → Audit logging: dispatches events (evidence: `backend/apps/audit/events/handlers.py`)
- Domain event bus → PostgreSQL: handlers persist records
- Django API → Offline POS sync: supports offline sync
- Django API → Push notifications: serves notifications
