How micic-mihajlo/datalore works
Project Type and Purpose
• Datalore is a Python‐based command‐line data‐analysis tool that leverages Anthropic’s Claude API for NL processing and integrates common data‐analysis libraries (pandas, numpy, matplotlib, etc.).
• It provides natural‐language interaction, data loading/cleaning/EDA/statistics/visualization, and a sandboxed custom‐code executor.
File Structure
• Top‐level scripts:
• datalore.py – main entrypoint (CLI orchestrator)
• redatalore.py – a variant or refactoring of the main script
• rnd.py – helper for randomness or utilities
• Configuration:
• requirements.txt – lists dependencies (pandas, anthropic, etc.)
• .env (not in tree, but mentioned in README) – stores the API key
• Persistence/Cache:
• .cursor/rules/data-rules.mdc – perhaps conversation history or rules storage
• No separate frontend or backend directories—this is a single‐process CLI application.
README for Architecture Clues
• Key components:
• CLI interface
• Natural‐language processing via external Anthropic Claude API
• Data‐loading modules (CSV, Excel, JSON)
• Data‐preprocessing/cleaning
• EDA/statistics modules
• Visualization modules
• Sandboxed custom code execution
• Conversation history management
• Technical stack: Python 3.7+, Anthropic API, pandas, matplotlib, etc.
Main Components
a. User & CLI Layer
– Terminal / Console (User input & output)
b. Core Orchestrator
– datalore.py (or redatalore.py)
– Input parser / command dispatcher
– Conversation history manager (.cursor/rules)
c. External Service
– Anthropic Claude API (cloud)
d. Data Modules (local in‐process)
– Data Loader (CSV, Excel, JSON)
– Preprocessing & Cleaning
– EDA & Statistical Analysis
– Visualization
e. Custom Code Executor
– Sandboxed Python runtime (executes user‐supplied code safely)
f. Configuration & Dependencies
– .env (ANTHROPIC_API_KEY)
– requirements.txt (pandas, numpy, matplotlib, anthropic, etc.)
g. Data Storage
– In‐memory DataFrames
– Local filesystem (source data files)
Relationships & Data Flows
• User → CLI → Core Orchestrator
• Core Orchestrator ⇄ Anthropic Claude API (for NL understanding and suggestions)
• Core → Data Loader → In‐memory DataFrame
• Core → Preprocessing / EDA / Statistics → DataFrame
• Core → Visualization → Matplotlib/Seaborn → Console or file outputs
• Core → Code Executor → Sandbox → Modified DataFrame
• Core ↔ Conversation History (append user queries & model responses)
Architectural Patterns & Principles
• Single‐process modular design (no microservices)
• Clear separation of concerns: CLI, NLP, data modules, sandbox execution
• Dependency injection for the API client via configuration (.env)
• Safety layer around code execution
• Pluggable data‐loading interfaces