How hxtanishq/rag-based-function-execution-api works
Project Type and Purpose
• Full-stack “automation orchestration” service with three interfaces (CLI, Web, REST API)
• Translates natural-language prompts into system calls via semantic search & function registry
Core Architectural Components
A. Presentation Layer (Interfaces)
• CLI Interface (cli.py)
• Streamlit Web Interface (web.py)
• REST API Server (FastAPI: api/routes.py, api/main.py)
B. Application Layer (Orchestration)
• Prompt Controller / API Handlers
• Session Manager (utils/session_manager.py) – maintains conversational context
• Error Handler (utils/error_handler.py) – central error logging & recovery
C. Domain Layer (Business Logic)
• Semantic Function Discovery
– Embedding/search module (could live in registry or automation_functions)
• Function Registry (registry/function_registry.py) – metadata & lookup of available functions
• Automation Functions (automation_functions/system_functions.py) – concrete system tasks
D. Infrastructure Layer
• OS/External Shell – actual execution environment for system commands
• Logging (function_execution.log) – persistent log of all executions & errors
• Requirements & Deployment (requirements.txt, uvicorn, streamlit)
Relationships & Data Flows
1. User enters prompt in CLI or Web UI, or issues HTTP POST to the API.
2. Interface forwards the prompt + optional params to the Prompt Controller.
3. Controller invokes Session Manager to retrieve or create context.
4. Controller calls into the Semantic Search / Function Registry to pick the best‐matching function.
5. Controller dispatches to the chosen Automation Function.
6. Automation Function executes on the OS or shell, returns result.
7. Error Handler intercepts any exceptions, logs them.
8. Controller logs the call in function_execution.log and returns the output (or error) back to the UI layer.
Highlighted Architectural Patterns & Design Principles
• Layered Architecture: clear separation of presentation, application, domain, infrastructure
• Plugin/Registry Pattern: functions are registered centrally and discovered at runtime
• Single Responsibility: each module (session_manager, error_handler, registry, system_functions) has a well-defined role
• Extensibility: adding new automation functions only requires updating the registry and function folder
Checklist for the Principal Software Engineer
[ ] All major components (UI, Controller, Registry, Functions, OS, Logs) drawn as distinct nodes
[ ] Zoomed-in inset (optional) for the orchestration core, showing session_manager + error_handler