TorbatYar/docs/architecture/module-boundaries.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.5 KiB

Module Boundaries

Architecture only. Module inventory → module-registry.md

Core Platform

Owns: tenants, domains, plans, features, subscriptions, entitlement checks, service/module registry, internal service tokens, outbox/inbox (core), audit log, core users, tenant memberships (operational), onboarding, public tenant-site resolution.

Must not own: business journals, CRM entities, restaurant menus, file blobs, SMS campaigns.

Identity & Access

Owns: user profiles linked to Keycloak, identity-layer memberships, OIDC BFF (config/token/me), mobile OTP handoff/session redeem, Keycloak admin sync.

Must not own: workspace onboarding lifecycle, plan/subscription, operational tenant roles source of truth (Core).

Frontend

Owns: UI, theme application, client-side auth redirects, dashboards, onboarding wizard UX.

Must not own: business rules, direct DB access, SQLAlchemy/Alembic, entitlement computation.

Future Business Modules

Each module (Accounting, CRM, Restaurant, Ecommerce, …) owns its database and domain APIs. Cross-module coupling is API/event only. Financial postings go only through Accounting Posting Engine (ADR-010).

CRM (Sales CRM)

Owns: Lead, Contact, Organization (business account), Opportunity, Pipeline, PipelineStage, SalesActivity, Task, Meeting, CallLog, Sales Timeline, Comment/Mention, Bookmark, Sales Team, Playbook, Forecast, Goal, Target, Win/Loss, Quote (sales), CRM publish events.

Must not own: Automation/workflows, Customer360, Marketing, Notification delivery, Messaging, Communication, Helpdesk, Analytics, AI, Identity, Accounting, Inventory, Restaurant, Marketplace, Files, Search.

Shared Library (backend/shared-lib)

Owns: JWT validation helpers, phone normalization, event envelope types, shared exceptions/responses.

Must not own: tenant business workflows or service-specific repositories.

Boundary Rules

  1. No cross-database foreign keys.
  2. No importing another service's models.
  3. Feature gates use Core entitlement API.
  4. Frontend talks to public/versioned APIs only.
  5. Providers are integrated behind module/provider adapters — see integration-architecture.md.