How ombhojane/dbrx-nexus works
Project type and purpose
• This is a single‐service conversational AI web application built with Streamlit.
• It accepts natural‐language queries, translates them into SQL via an LLM (Google Gemini), executes against a local SQLite database, then formats and returns the result conversationally.
File structure
• Top‐level files:
• app.py – contains both the Streamlit UI and the orchestration logic (NLU, SQL generation, database calls, response formatting).
• create_database.py – one‐off script to populate phones.db.
• phones.db – the SQLite database file.
• style.css – custom styling for the Streamlit UI.
• .env – holds GEMINI_API_KEY for Google Generative AI.
• requirements.txt – Python dependencies (streamlit, sqlite3, google-generativeai).
Key architecture details from the README
• Streamlit provides the interactive UI layer.
• Google’s Generative AI (via GEMINI_API_KEY) is the external LLM service.
• SQLite is the local datastore.
• Data flow: User → NLU (LLM) → SQL → SQLite → formatting (LLM) → UI.
Main components and their relationships
a. Components
1. Streamlit UI (app.py + style.css)
2. Conversational AI module
• NL Parser / SQL Generator (calls Google Gemini API)
• Response Formatter (also uses LLM)
3. Local SQLite Database (phones.db)
4. Database‐setup script (create_database.py) – optional/off‐line
5. External LLM service (Google Generative AI via GEMINI_API_KEY)
b. Interactions
• User enters text in the Streamlit UI.
• app.py sends input to the NL Parser, which invokes the external LLM API to generate an SQL query.
• app.py executes the SQL against phones.db via sqlite3.
• Raw results are passed to the Response Formatter, which again calls the LLM to turn rows into natural‐language.
• The formatted answer is rendered back in the UI.
Architectural patterns & principles
• Monolithic service with clear logical layers (Presentation, Business Logic, Data Access).
• Separation of concerns: UI styling (style.css), orchestration (app.py), data layer (phones.db).
• External dependency isolation: LLM calls abstracted into functions in app.py.