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:
- Middleware (header/URL resolution).
TenantMiddleware - QuerySet filtering ().
filter(tenant=request.tenant) - Cryptographic secret isolation (Fernet encryption per tenant config).
- Middleware (
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), input validation serializers, and encrypted database attributes.IsAgencyAdmin
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.