Date: 2025-11-29
Accepted
The IndiaAI IDP Platform needs to run in diverse environments:
- Local Development: Developers need to run the full stack on their laptops without complex infrastructure (Redis, S3, PostgreSQL).
- Production: The system needs to scale using robust cloud-native services (Cloud Storage, Managed Queues, Managed DB).
We need an architecture that supports both without requiring code changes or conditional logic scattered throughout the codebase.
We will implement a Modular Service Architecture using the Strategy Pattern. Key infrastructure components will be defined as abstract base classes (interfaces) with multiple implementations.
- Storage:
StorageServiceinterface.LocalStorageService: Saves files to the local filesystem.R2StorageService: Saves files to Cloudflare R2 (S3-compatible).
- Queue:
QueueServiceinterface.MemoryQueueService: Uses Python'sasyncio.Queuefor in-process queuing.RedisQueueService: Uses Redis for distributed queuing.
- OCR:
OCRServiceinterface.PaddleOCRService: Uses PaddleOCR.EasyOCRService: Uses EasyOCR (future/alternative).
The active implementation will be selected at runtime based on environment variables (e.g., STORAGE_TYPE=local vs STORAGE_TYPE=s3) using a factory pattern in app/core/config.py or service getters.
- Zero-Setup Dev Environment: Developers can
git cloneandrunwithout installing Redis or MinIO. - Testability: Easy to mock services for unit testing.
- Vendor Lock-in Avoidance: Switching from R2 to AWS S3 or Azure Blob Storage only requires adding a new
StorageServiceimplementation.
- Complexity: Adds a layer of abstraction. Simple direct calls (e.g.,
open()) are replaced by service calls (storage.upload()). - Feature Intersection: The "lowest common denominator" of features must be supported by all implementations, or specific features ( like S3 presigned URLs) might not be available in the Local implementation.