How kitadmin01/farm-financial-rag works
Project Type and Purpose
• This is a full-stack Retrieval-Augmented Generation (RAG) application for farm financial data.
• Users interact via CLI, REST API (FastAPI + static HTML), or an interactive demo.
• The core logic uses an OpenAI LLM to translate natural-language questions into SQL, executes them against an embedded SQLite database, and returns contextual insights.
File Structure
Top-level
• README.md / WINDOWS_README.md – project overview and setup.
• requirements.txt – Python dependencies (FastAPI, OpenAI SDK, SQLite, pandas, etc.).
• start_rag_app.sh, user_setup.bat/ps1 – environment-setup and launch scripts.
• test_db_creation.py – root-level test for DB.
• src/ – main application code and utilities.
src/
• create_database.py, create_simple_db.py, add_sample_data_minimal.py – DB schema creation & data ingestion.
• check_database*.py, check_schema.py, check_table_schema.py – DB verification utilities.
• farm_rag_app.py – CLI interface.
• farm_rag_api.py – FastAPI server exposing /ask, /schema, /examples, /health.
• web_interface.html – simple front-end served by FastAPI.
• quick_test.py, test_rag_app.py, demo.py – smoke tests, full test suite, interactive demo.
• finbin_farm_data.db (created at runtime) – SQLite database file.
README Insights
• Architecture overview: User Question → OpenAI LLM → SQL Generation → SQLite Execution → Data Analysis → AI Response.
• Multiple interfaces (CLI, API+web, demo).
• Environment variables: OPENAI_API_KEY, DATABASE_PATH, OPENAI_MODEL, etc.
• Deployment via shell/PowerShell scripts.
Diagramming Recommendations
• Use clear, consistent labels for all components (e.g., “OpenAI API,” “SQLite DB,” “FastAPI Server”).
• From clients → API/Core (requests)
• Core → OpenAI API (prompt) → Core (SQL)
• Core → SQLite (SQL execution) → Core (results)
• Core → clients (responses)
• Blue for interfaces
• Green for core logic/processing
• Orange for external services
• Brown for database
• Rectangles for services/modules
• Clouds for external APIs