How roy2392/txt2sql-gemini works
Main Components
a) Client Layer:
• External clients making HTTP requests
• Supported endpoints (/health, /query)
b) Application Layer:
• FastAPI Service (src/api/)
• Route handlers (src/api/routes.py)
• Data models (src/api/models.py)
c) Processing Layer:
• SQL Generator Module (src/utils/sql_generator.py)
• Gemini LLM Client (src/llm/gemini_client.py)
• Database Manager (src/database/db_manager.py)
d) Data Layer:
• PostgreSQL Database
• Initialization scripts (docker/init.sql)
e) Infrastructure Layer:
• Docker containers
• AWS Infrastructure (managed via Terraform)
Component Relationships and Data Flow
1. Client → FastAPI Service
• HTTP POST /query with natural language question
• HTTP GET /health for monitoring
2. FastAPI Service → SQL Generator
• Passes natural language query
• Receives generated SQL query
3. SQL Generator ↔ Gemini LLM
• Sends prompt for SQL generation
• Receives SQL query and explanation
4. Database Manager ↔ PostgreSQL
• Executes SQL queries
• Retrieves query results
5. FastAPI Service → Client
• Returns JSON response with:
• * Generated SQL query
• * Query results
• * Natural language explanation
Infrastructure Details
• Docker container architecture
• API container
• PostgreSQL container
• Network connections
• AWS infrastructure components (from Terraform)
• IAM roles
• EC2 instances
• Network configuration
Additional Elements
Supplementary information:
• Environment variables section
• Health monitoring flow
• Error handling paths
• Testing coverage indicators
Recommendations
• Create multiple views if needed (runtime view, deployment view)
• Version information and date
• Document any assumptions or constraints
Remember to emphasize the unique aspects of this project: the natural language processing capabilities, the SQL generation workflow, and the integration with Google's Gemini LLM.