# sm85-code/sm85-arch architecture

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

- Interactive diagram: https://gitdiagram.com/sm85-code/sm85-arch
- Repository: https://github.com/sm85-code/sm85-arch

## Overview

This repository is a multi-tenant business application: a shared FastAPI entry point mounts separate Bumi Lestari finance, madrasah administration, marketplace ERP, and online-store APIs. The principal workflow is an API request routed to a tenant’s application logic and its isolated database; commerce and education add distinct operational capabilities. The README is empty, so capabilities and relationships here are based on the file tree and SOURCE INDEX references; unsampled subsystems are represented at directory level where needed.

Main entry points: [`main.py`](https://github.com/sm85-code/sm85-arch/blob/main/main.py) (FastAPI application), [`tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py`](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py) (Finance services), [`tenants/madrasah/adapters/api/v1/madrasah_router.py`](https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/adapters/api/v1/madrasah_router.py) (Madrasah API), [`tenants/bumi_lestari/adapters/api/v1/bumi_lestari_router.py`](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/adapters/api/v1/bumi_lestari_router.py) (Bumi API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared runtime"]
  node_app["FastAPI application<br/>[main.py]"]
  node_security["Tenant security<br/>[security.py]"]
end

subgraph group_bumi["Bumi finance"]
  node_bl_api["Bumi API"]
  node_bl_keu_api["Finance API<br/>[keu_router.py]"]
  node_bl_services["Bumi services<br/>[services.py]"]
  node_keu_services["Finance services<br/>[keu_services.py]"]
  node_keu_ledger["Ledger operations<br/>[keu_ledger.py]"]
  node_keu_accounting["Accounting operations<br/>[keu_accounting.py]"]
  node_bl_models["Finance records<br/>[models.py]"]
  node_bl_keu_models["Finance models<br/>[models_keu.py]"]
  node_bl_db[("Bumi database<br/>[database.py]")]
end

subgraph group_madrasah["Madrasah operations"]
  node_mad_api["Madrasah API<br/>[madrasah_router.py]"]
  node_mad_services["Madrasah services<br/>[services.py]"]
  node_kk_parser["Family-card parser<br/>[kk_parser.py]"]
  node_ocr["OCR adapter"]
  node_mad_models["Madrasah records<br/>[models.py]"]
  node_mad_db[("Madrasah database<br/>[database.py]")]
end

subgraph group_commerce["Commerce"]
  node_market_api["Marketplace API"]
  node_market_services["Marketplace services<br/>[services.py]"]
  node_market_adapters["Marketplace channels"]
  node_market_db[("Marketplace database<br/>[database.py]")]
  node_store_admin["Store admin API"]
  node_store_buyer["Store buyer API"]
  node_store_services["Store services<br/>[services.py]"]
  node_store_media["Media storage<br/>[media_storage.py]"]
  node_store_integrations["Store integrations"]
  node_store_db[("Store database<br/>[database.py]")]
end

node_operator(("API user"))

node_operator -->|"sends request"| node_app
node_app -->|"mounts routes"| node_bl_api
node_app -->|"initializes tenant"| node_bl_db
node_app -->|"mounts routes"| node_mad_api
node_app -->|"initializes tenant"| node_mad_db
node_app -->|"mounts routes"| node_market_api
node_app -->|"initializes tenant"| node_market_db
node_app -->|"mounts routes"| node_store_admin
node_app -->|"mounts routes"| node_store_buyer
node_app -->|"initializes tenant"| node_store_db
node_bl_api -->|"calls"| node_bl_services
node_bl_api -->|"uses records"| node_bl_models
node_bl_keu_api -->|"calls"| node_keu_services
node_keu_services -->|"uses ledger"| node_keu_ledger
node_keu_services -->|"records orders"| node_keu_accounting
node_keu_services -->|"queries records"| node_bl_keu_models
node_mad_api -->|"calls"| node_mad_services
node_mad_api -->|"uses parser"| node_kk_parser
node_mad_api -->|"uses OCR"| node_ocr
node_mad_services -->|"queries records"| node_mad_models
node_market_api -->|"calls"| node_market_services
node_market_services -->|"uses channels"| node_market_adapters
node_store_admin -->|"calls"| node_store_services
node_store_buyer -->|"calls"| node_store_services
node_store_services -->|"stores media"| node_store_media
node_store_buyer -->|"uses integrations"| node_store_integrations

click node_app "https://github.com/sm85-code/sm85-arch/blob/main/main.py"
click node_security "https://github.com/sm85-code/sm85-arch/blob/main/shared/security.py"
click node_bl_api "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/adapters/api/v1/bumi_lestari_router.py"
click node_bl_keu_api "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/adapters/api/v1/keu_router.py"
click node_bl_services "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/services.py"
click node_keu_services "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py"
click node_keu_ledger "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/keu_ledger.py"
click node_keu_accounting "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/keu_accounting.py"
click node_bl_models "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/infrastructure/models.py"
click node_bl_keu_models "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/infrastructure/models_keu.py"
click node_bl_db "https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/infrastructure/database.py"
click node_mad_api "https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/adapters/api/v1/madrasah_router.py"
click node_mad_services "https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/application/services.py"
click node_kk_parser "https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/application/kk_parser.py"
click node_ocr "https://github.com/sm85-code/sm85-arch/blob/main/adapters/external/ocr_space_adapter.py"
click node_mad_models "https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/infrastructure/models.py"
click node_mad_db "https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/infrastructure/database.py"
click node_market_api "https://github.com/sm85-code/sm85-arch/blob/main/tenants/marketplace_erp/adapters/api/v1/marketplace_erp_router.py"
click node_market_services "https://github.com/sm85-code/sm85-arch/blob/main/tenants/marketplace_erp/modules/marketplace_erp/application/services.py"
click node_market_adapters "https://github.com/sm85-code/sm85-arch/tree/main/tenants/marketplace_erp/modules/marketplace_erp/infrastructure/adapters"
click node_market_db "https://github.com/sm85-code/sm85-arch/blob/main/tenants/marketplace_erp/modules/marketplace_erp/infrastructure/database.py"
click node_store_admin "https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/adapters/api/v1/store_admin_router.py"
click node_store_buyer "https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/adapters/api/v1/store_buyer_router.py"
click node_store_services "https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/modules/store/application/services.py"
click node_store_media "https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/modules/store/infrastructure/media_storage.py"
click node_store_integrations "https://github.com/sm85-code/sm85-arch/tree/main/tenants/store/modules/store/infrastructure"
click node_store_db "https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/modules/store/infrastructure/database.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_app,node_security,node_operator toneBlue
class node_bl_api,node_bl_keu_api,node_bl_services,node_keu_services,node_keu_ledger,node_keu_accounting,node_bl_models,node_bl_keu_models,node_bl_db toneAmber
class node_mad_api,node_mad_services,node_kk_parser,node_ocr,node_mad_models,node_mad_db toneMint
class node_market_api,node_market_services,node_market_adapters,node_market_db,node_store_admin,node_store_buyer,node_store_services,node_store_media,node_store_integrations,node_store_db toneRose
```

## Components

### Shared runtime

- [FastAPI application](https://github.com/sm85-code/sm85-arch/blob/main/main.py): `main.py`
- [Tenant security](https://github.com/sm85-code/sm85-arch/blob/main/shared/security.py): `shared/security.py`

### Bumi finance

- [Bumi API](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/adapters/api/v1/bumi_lestari_router.py): `tenants/bumi_lestari/adapters/api/v1/bumi_lestari_router.py`
- [Finance API](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/adapters/api/v1/keu_router.py): `tenants/bumi_lestari/adapters/api/v1/keu_router.py`
- [Bumi services](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/services.py): `tenants/bumi_lestari/modules/bumi_lestari/application/services.py`
- [Finance services](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py): `tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py`
- [Ledger operations](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/keu_ledger.py): `tenants/bumi_lestari/modules/bumi_lestari/application/keu_ledger.py`
- [Accounting operations](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/application/keu_accounting.py): `tenants/bumi_lestari/modules/bumi_lestari/application/keu_accounting.py`
- [Finance records](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/infrastructure/models.py): `tenants/bumi_lestari/modules/bumi_lestari/infrastructure/models.py`
- [Finance models](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/infrastructure/models_keu.py): `tenants/bumi_lestari/modules/bumi_lestari/infrastructure/models_keu.py`
- [Bumi database](https://github.com/sm85-code/sm85-arch/blob/main/tenants/bumi_lestari/modules/bumi_lestari/infrastructure/database.py): `tenants/bumi_lestari/modules/bumi_lestari/infrastructure/database.py`

### Madrasah operations

- [Madrasah API](https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/adapters/api/v1/madrasah_router.py): `tenants/madrasah/adapters/api/v1/madrasah_router.py`
- [Madrasah services](https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/application/services.py): `tenants/madrasah/modules/madrasah/application/services.py`
- [Family-card parser](https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/application/kk_parser.py): `tenants/madrasah/modules/madrasah/application/kk_parser.py`
- [OCR adapter](https://github.com/sm85-code/sm85-arch/blob/main/adapters/external/ocr_space_adapter.py): `adapters/external/ocr_space_adapter.py`
- [Madrasah records](https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/infrastructure/models.py): `tenants/madrasah/modules/madrasah/infrastructure/models.py`
- [Madrasah database](https://github.com/sm85-code/sm85-arch/blob/main/tenants/madrasah/modules/madrasah/infrastructure/database.py): `tenants/madrasah/modules/madrasah/infrastructure/database.py`

### Commerce

- [Marketplace API](https://github.com/sm85-code/sm85-arch/blob/main/tenants/marketplace_erp/adapters/api/v1/marketplace_erp_router.py): `tenants/marketplace_erp/adapters/api/v1/marketplace_erp_router.py`
- [Marketplace services](https://github.com/sm85-code/sm85-arch/blob/main/tenants/marketplace_erp/modules/marketplace_erp/application/services.py): `tenants/marketplace_erp/modules/marketplace_erp/application/services.py`
- [Marketplace channels](https://github.com/sm85-code/sm85-arch/tree/main/tenants/marketplace_erp/modules/marketplace_erp/infrastructure/adapters): `tenants/marketplace_erp/modules/marketplace_erp/infrastructure/adapters`
- [Marketplace database](https://github.com/sm85-code/sm85-arch/blob/main/tenants/marketplace_erp/modules/marketplace_erp/infrastructure/database.py): `tenants/marketplace_erp/modules/marketplace_erp/infrastructure/database.py`
- [Store admin API](https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/adapters/api/v1/store_admin_router.py): `tenants/store/adapters/api/v1/store_admin_router.py`
- [Store buyer API](https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/adapters/api/v1/store_buyer_router.py): `tenants/store/adapters/api/v1/store_buyer_router.py`
- [Store services](https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/modules/store/application/services.py): `tenants/store/modules/store/application/services.py`
- [Media storage](https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/modules/store/infrastructure/media_storage.py): `tenants/store/modules/store/infrastructure/media_storage.py`
- [Store integrations](https://github.com/sm85-code/sm85-arch/tree/main/tenants/store/modules/store/infrastructure): `tenants/store/modules/store/infrastructure`
- [Store database](https://github.com/sm85-code/sm85-arch/blob/main/tenants/store/modules/store/infrastructure/database.py): `tenants/store/modules/store/infrastructure/database.py`

### Other components

- **API user**

## Connections

- API user → FastAPI application: sends request (evidence: `main.py`)
- FastAPI application → Bumi API: mounts routes (evidence: `main.py`)
- FastAPI application → Bumi database: initializes tenant (evidence: `main.py`)
- FastAPI application → Madrasah API: mounts routes (evidence: `main.py`)
- FastAPI application → Madrasah database: initializes tenant (evidence: `main.py`)
- FastAPI application → Marketplace API: mounts routes (evidence: `main.py`)
- FastAPI application → Marketplace database: initializes tenant (evidence: `main.py`)
- FastAPI application → Store admin API: mounts routes (evidence: `main.py`)
- FastAPI application → Store buyer API: mounts routes (evidence: `main.py`)
- FastAPI application → Store database: initializes tenant (evidence: `main.py`)
- Bumi API → Bumi services: calls (evidence: `tenants/bumi_lestari/adapters/api/v1/bumi_lestari_router.py`)
- Bumi API → Finance records: uses records (evidence: `tenants/bumi_lestari/adapters/api/v1/bumi_lestari_router.py`)
- Finance API → Finance services: calls (evidence: `tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py`)
- Finance services → Ledger operations: uses ledger (evidence: `tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py`)
- Finance services → Accounting operations: records orders (evidence: `tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py`)
- Finance services → Finance models: queries records (evidence: `tenants/bumi_lestari/modules/bumi_lestari/application/keu_services.py`)
- Madrasah API → Madrasah services: calls (evidence: `tenants/madrasah/adapters/api/v1/madrasah_router.py`)
- Madrasah API → Family-card parser: uses parser (evidence: `tenants/madrasah/adapters/api/v1/madrasah_router.py`)
- Madrasah API → OCR adapter: uses OCR (evidence: `tenants/madrasah/adapters/api/v1/madrasah_router.py`)
- Madrasah services → Madrasah records: queries records (evidence: `tenants/madrasah/modules/madrasah/application/services.py`)
- Marketplace API → Marketplace services: calls (evidence: `tenants/marketplace_erp/adapters/api/v1/marketplace_erp_router.py`)
- Marketplace services → Marketplace channels: uses channels (evidence: `tenants/marketplace_erp/modules/marketplace_erp/application/services.py`)
- Store admin API → Store services: calls (evidence: `tenants/store/adapters/api/v1/store_admin_router.py`)
- Store buyer API → Store services: calls (evidence: `tenants/store/adapters/api/v1/store_buyer_router.py`)
- Store services → Media storage: stores media (evidence: `tenants/store/modules/store/application/services.py`)
- Store buyer API → Store integrations: uses integrations (evidence: `tenants/store/adapters/api/v1/store_buyer_router.py`)
