FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
Git ContextEngineering Handbook
Design Principles
Docsgit-contextEngineering HandbookDesign Principles
GitHub Live Sync

Design Principles

Live technical documentation fetched from GitHub repository omghante/metapilot/docs/engineering/design-principles.md

MetaPilot Design Principles

The MetaPilot engineering team follows six core design principles to build a reliable, maintainable, and scalable Multi-Tenant SaaS.

1. Modular Monolith Over Microservices

  • Build self-contained, loosely coupled Django applications (
    users
    ,
    tenants
    ,
    campaigns
    ,
    messaging
    ,
    inbox
    ,
    scheduler
    ,
    chatbot
    ,
    notifications
    ).
  • Communicate across modules using explicit Python service functions and Django signals — avoiding network serialization overhead until physical microservice boundaries are strictly needed.

2. Strict Tenant Data Isolation

  • Data belonging to one tenant must never leak or be accessible by another tenant.
  • Enforce tenant isolation at three levels:
    1. Middleware (
      TenantMiddleware
      header/URL resolution).
    2. QuerySet filtering (
      filter(tenant=request.tenant)
      ).
    3. Cryptographic secret isolation (Fernet encryption per tenant config).

3. Defense-in-Depth Security

  • Never rely on a single layer of security.
  • Combine JWT authentication, Role-Based Access Control (RBAC), tenant permission classes (
    IsTenantAdmin
    ,
    IsAgencyAdmin
    ), input validation serializers, and encrypted database attributes.

4. Asynchronous & Non-Blocking Execution

  • Keep HTTP request-response cycles fast (< 100ms).
  • Offload long-running operations (WhatsApp broadcast generation, AI LLM API calls, batch notification sending, media downloads) to background Celery workers via Redis queues.

5. Resilience to External System Failures

  • The Meta WhatsApp API and OpenRouter LLM APIs are external dependencies subject to rate limits, network latency, and outages.
  • Design every external API call with token bucket rate limits, exponential backoff retries, explicit timeouts, and graceful fallbacks.

6. Empirical Verification & Testability

  • Code is not done until it is tested.
  • Write unit tests for models/services and integration tests for REST & WebSocket endpoints.
  • Base diagnostic hypotheses strictly on empirical logs and full tracebacks.