TorbatYar/docs/architecture/service-architecture.md
Mortezakoohjani 12c8615615 Ship enterprise Accounting FE/API with CRUD parity and production wiring.
Adds accounting-service PATCH/archive, fiscal helpers, COA templates and setup status, plus SuperApp Accounting UI (DS, scoreboard, masters, vouchers, ledger, ops modules) with session refresh and HTTPS public API URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 15:26:43 +03:30

1.3 KiB

Service Architecture

Internal Layering (every backend service)

API (routers)  →  Services (business logic)  →  Repositories  →  Models (DB)
                         ↑
                     Schemas (Pydantic DTOs)
Layer Allowed Forbidden
API / Views Auth deps, validation, HTTP mapping Business rules, raw SQL
Services Domain logic, orchestration, events HTTP concerns, UI
Repositories Queries/persistence Business decisions
Models Schema mapping Business workflows

Core Package Layout

  • core/ — config, database, cache, security, logging
  • middlewares/ — tenant resolution
  • workers/ — Celery tasks (outbox, SSL provision, …)
  • api/v1/ — versioned routers
  • tests/ — automated tests

Adding a Service

  1. New folder under backend/services/<name>/
  2. Independent database + Alembic
  3. Register in Core service/module registry
  4. Document in module-registry.md
  5. UI only in frontend/, API-only access
  6. Follow coding-standards.md