TorbatYar/docs/architecture/database-architecture.md
Mortezakoohjani 064d67f099 Ship CRM Core Platform (phases 6.0–6.3) with docs and prod deploy.
Add the Sales CRM service through collaboration, sync architecture/registry docs, expose crm.torbatyar.ir, and include a production deploy script.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 20:32:00 +03:30

2.0 KiB

Database Architecture

Architecture only. Column-level reference → database-schema.md

Pattern

Database-per-service (ADR-001).

Service Database
Core Platform core_platform_db
Identity & Access identity_access_db
Accounting (future) accounting_db
CRM crm_db
Ecommerce (future) ecommerce_db
Website Builder (future) website_builder_db
Live Chat (future) live_chat_db
AI Assistant (future) ai_assistant_db
Smart Messenger (future) smart_messenger_db
SMS Panel (future) sms_panel_db
Link Shortener (future) link_shortener_db
Notification (future) notification_db
File Storage (future) file_storage_db
Restaurant (future) restaurant_db

Hard Rules

  1. No direct queries across service databases.
  2. No cross-DB foreign keys.
  3. Every business table includes tenant_id (ADR-003).
  4. IDs are UUID; timestamps are timezone-aware.
  5. Migrations via Alembic per service; never edit applied migrations in production.
  6. Conceptual schemas for future services are documented in reference docs until migrations exist.

Core Platform Ownership

Tenants, domains, plans/features/subscriptions, registries, internal tokens, outbox/inbox, audit logs, core users, operational tenant_memberships.

Identity Ownership

user_profiles, identity-layer tenant_memberships (not the Core table — ADR-007).

Dual Membership Clarification

Database Table Role
core_platform_db tenant_memberships Workspace authorization source of truth
identity_access_db tenant_memberships SSO membership listing