How bachngoh/aio_data_analyst works
Project type and purpose
• This is a full-stack, AI-powered data analysis application built on Chainlit.
• Purpose: provide an interactive UI for uploading CSV data, running automated analyses (via PandasAI and custom LLM-based agents), generating visualizations, and returning AI-driven insights.
File structure
• Top level:
• .chainlit/ → Chainlit configuration and localization
• app.py → Entry point tying Chainlit to your app logic
• chainlit.md → Chainlit interface instructions
• public/ → Static assets (project logo)
• data/ → Sample CSVs for training, testing, submission
• src/ → Core application code
• src breakdown:
• agents/ → Agent abstractions and concrete LLM-powered agents
– base.py → Agent interface
– llm_compiler_agent/ → Agent that compiles/generates code via LLM
– pandasai_agent/ → Agent that orchestrates PandasAI for data tasks
• tools/ → Modular “tools” invoked by agents
– data_analysis/ → Parsers, prompts, execution logic for data analysis
– pandas_tool.py → Thin wrapper for Pandas operations
• utils/ → Shared utilities
– llm_utils.py → LLM request/response handling
– chainlit_response.py → Formatting responses for Chainlit UI
• const.py → Constants (e.g., prompt templates, timeouts)
README for additional insights
• Key dependencies: Pandas, PandasAI, LlamaIndex (RAG), Chainlit (UI layer)
• Features: automated analysis, interactive visualizations, AI recommendations
• Launch command: chainlit run app.py (implies a frontend served by Chainlit, backend logic in app.py invoking src modules)
a. Main components
• User & Browser (web UI)
• Chainlit Server / Frontend Layer
• Application Core (app.py)
• Agent Manager (src/agents/base.py orchestrator)
• Specific Agents
– LLM Compiler Agent (code generation, advanced prompts)
– PandasAI Agent (data manipulation, visualizations)
• Tools Layer (src/tools)
– Data Analysis Tool (output parser, prompts)
– Pandas Tool (wrapper for data ops)
• Data Store (local CSV files)
• External Services
– LLM Provider (OpenAI, etc.)
– LlamaIndex (for vector retrieval/RAG)
b. Relationships & interactions
1. User interacts with Chainlit UI
2. Chainlit forwards requests to app.py
3. app.py invokes the Agent Manager
4. Agent Manager dispatches to the correct Agent
5. Agent calls Tools or LLM via llm_utils & LlamaIndex
6. Results are formatted by chainlit_response and sent back to the UI
7. CSV data can be read/written from the data folder via Pandas Tool
c. Architectural patterns & principles
• Modular “agent” pattern: each agent has a single responsibility
• Tool abstraction: decouples business logic from LLM prompts and parsing
• Clear separation: UI (Chainlit) ↔ Orchestration (app.py + Agent Manager) ↔ Execution (Agents/Tools)
d. Key technologies to call out
• Chainlit (UI framework)
• Pandas & PandasAI (data operations)
• LLM Provider & LlamaIndex (RAG retrieval)
• Python modules (src/agents, src/tools, src/utils)