Microservice orchestration platform for Retrieval-Augmented Generation (RAG) using Temporal workflows. Features distributed document processing, vector search, and interactive chat interface with full workflow visibility and monitoring.
SmartÆgent X-7 demonstrates microservice orchestration using Temporal workflows for distributed RAG operations. Each service runs as an independent container with Temporal coordinating complex document processing pipelines.
Core Orchestration Pattern:
Gradio UI → Temporal Workflows → Distributed Activities → Vector Database
- Reliability: Automatic retries, error handling, and state persistence
- Scalability: Horizontal scaling of individual microservices
- Visibility: Full workflow execution monitoring via Temporal UI
- Durability: Workflow state survives service restarts and failures
- Composition: Complex pipelines built from simple, reusable activities
- System: SmartÆgent X-7 — Temporal-orchestrated RAG platform demonstrating microservice coordination
- Users:
- End Users (Gradio chat interface)
- Developers (Temporal workflow monitoring)
- DevOps (Container orchestration)
- External Systems:
- OpenAI API (LLM completions)
- Temporal Server (workflow orchestration)
- Vector Database (Qdrant)
Temporal-Orchestrated Services:
- Gradio Service: Interactive chat interface with Temporal workflow triggers
- Temporal Service: Workflow orchestration engine executing distributed activities
- Retriever Service: Vector search microservice (Temporal activities)
- Embedding Service: Document embedding microservice (Temporal activities)
- Workflow Composer Service: Advanced workflow composition and agent orchestration
Infrastructure Services:
- Temporal Server: Workflow engine with persistence and monitoring
- Qdrant: Vector database for semantic search
- PostgreSQL: Temporal metadata storage
Microservice Communication Pattern:
Chat Request → Temporal Workflow → Activity Tasks → Service Workers → Results
All service coordination flows through Temporal workflows, eliminating point-to-point service dependencies.
Document Processing Workflow:
- Document Upload Activity: Handles file ingestion and validation
- Text Chunking Activity: Splits documents into semantic chunks
- Embedding Activity: Generates vector embeddings for chunks
- Vector Storage Activity: Stores embeddings in Qdrant
RAG Query Workflow:
- Query Processing Activity: Normalizes and validates user queries
- Vector Retrieval Activity: Searches for relevant document chunks
- Context Assembly Activity: Combines retrieved chunks for LLM context
- Response Generation Activity: Integrates with OpenAI for final response
Workflow Orchestration Benefits:
- Each activity runs in isolated microservices
- Automatic retry and error handling
- Full execution history and monitoring
- Horizontal scaling of individual activities
Microservice Implementation:
services/temporal_service/workflows.py: Workflow definitions for document processing and RAGservices/temporal_service/activities.py: Cross-cutting workflow activitiesservices/retriever_service/activities.py: Vector search activitiesservices/embedding_service/activities.py: Text embedding activitiesservices/gradio_service/main.py: Chat UI with Temporal workflow integrationservices/workflow_composer_service/: Advanced workflow composition engine
Key Architecture Patterns:
- Activity Pattern: Each microservice exposes Temporal activities
- Workflow Pattern: Complex operations composed of distributed activities
- Saga Pattern: Long-running transactions with compensation
- Event Sourcing: Full workflow execution history
| Service | Role | Temporal Integration |
|---|---|---|
| Gradio | Chat UI + Workflow Triggers | Temporal client, workflow API |
| Temporal Worker | Workflow orchestration | Workflow definitions, routing |
| Retriever | Vector search microservice | Temporal activities |
| Embedding | Text embedding microservice | Temporal activities |
| Workflow Composer | Advanced orchestration | Meta-workflows, composition |
| Qdrant | Vector Database | Data persistence layer |
| PostgreSQL | Temporal State Store | Workflow state persistence |
Orchestration Flow:
- User interaction → Gradio triggers Temporal workflow
- Temporal Worker coordinates distributed activities
- Activities execute in isolated microservices
- Results flow back through workflow to UI
- Full execution history available in Temporal UI
- Unit Tests: Individual service tests in
services/*/tests/ - Workflow Tests: Temporal workflow integration tests
- Activity Tests: Distributed activity execution tests
- E2E Tests: Full pipeline orchestration tests
# Test all microservices
python run_tests.py
# Test end-to-end workflows
scripts/e2e_test.sh
# Clean test data
scripts/cleanup_collections.sh- Docker and Docker Compose
- OpenAI API key in
.envfile:OPENAI_API_KEY=your_key_here
# 1. Build and start all microservices
docker-compose up --build && docker-compose up -d
# 2. Upload documents (only local setup required)
python upload_documents.py-
Monitor Workflows: http://localhost:8081 (Temporal UI)
- Watch document processing workflows in real-time
- See activity execution across distributed services
- Monitor workflow history and performance
-
Chat Interface: http://localhost:7860 (Gradio UI)
- Ask questions about uploaded documents
- Observe retrieved document chunks in responses
- Each query triggers a complete RAG workflow
-
Vector Database: http://localhost:6333/dashboard (Qdrant UI)
- Explore processed document embeddings
- View vector search operations
- Document Upload → Web interface at http://localhost:7861 → Temporal orchestrates: chunking → embedding → storage
- Chat Query → Web interface at http://localhost:7860 → Temporal orchestrates: search → retrieval → response generation
- All Operations → Visible in Temporal UI with full execution traces at http://localhost:8081
├── docker-compose.yml # Microservice orchestration with Temporal
├── upload_documents.py # Simplified upload launcher (see web interface)
├── scripts/ # Testing and maintenance automation
│ ├── e2e_test.sh # End-to-end workflow testing
│ └── cleanup_collections.sh # Vector database cleanup
├── tests/ # Workflow and integration tests
│ ├── test_temporal_e2e.py # Temporal workflow tests
│ └── test_*.py # Service integration tests
├── document_files/ # Sample documents for testing
├── services/ # Temporal-orchestrated microservices
│ ├── gradio_service/ # Chat UI + Document Upload interfaces
│ │ ├── app.py # Main chat interface (port 7860)
│ │ ├── upload_app.py # Document upload interface (port 7861)
│ │ ├── launch_both.py # Launcher for both interfaces
│ │ ├── rag_service.py # RAG workflow client
│ │ └── Dockerfile # Containerized UI service
│ ├── temporal_service/ # Workflow orchestration engine
│ │ ├── workflows.py # Document and RAG workflow definitions
│ │ ├── activities.py # Workflow activities
│ │ ├── worker.py # Temporal worker process
│ │ └── normalization.py # Data transformation utilities
│ ├── retriever_service/ # Vector search microservice
│ │ ├── activities.py # Vector search Temporal activities
│ │ ├── worker.py # Activity worker process
│ │ └── Dockerfile # Containerized retrieval service
│ ├── embedding_service/ # Text embedding microservice
│ │ ├── activities.py # Embedding Temporal activities
│ │ ├── worker.py # Activity worker process
│ │ └── Dockerfile # Containerized embedding service
│ └── workflow_composer_service/ # Advanced workflow orchestration
│ ├── activities.py # Composition activities
│ ├── agents/ # AI agent workflows
│ └── api/ # GraphQL workflow API
└── ci/
└── ci_pipeline.py # CI/CD automation
MIT License - see LICENSE file for details.