{"id":51059127,"url":"https://github.com/erishen/langgraph-csv-analyst","last_synced_at":"2026-06-23T00:01:36.765Z","repository":{"id":365583860,"uuid":"1272805729","full_name":"erishen/langgraph-csv-analyst","owner":"erishen","description":"CSV → Multi-Agent Analysis Pipeline → Visual HTML Report. Built with LangGraph StateGraph: data profiling, trend analysis, anomaly detection, and investment portfolio analysis.","archived":false,"fork":false,"pushed_at":"2026-06-18T00:40:50.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-18T02:21:29.461Z","etag":null,"topics":["asset-lens","csv-analysis","data-visualization","investment-analysis","langchain","langgraph","multi-agent","plotly","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erishen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-18T00:31:25.000Z","updated_at":"2026-06-18T00:45:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/erishen/langgraph-csv-analyst","commit_stats":null,"previous_names":["erishen/langgraph-csv-analyst"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/erishen/langgraph-csv-analyst","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Flanggraph-csv-analyst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Flanggraph-csv-analyst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Flanggraph-csv-analyst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Flanggraph-csv-analyst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erishen","download_url":"https://codeload.github.com/erishen/langgraph-csv-analyst/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erishen%2Flanggraph-csv-analyst/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34669839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asset-lens","csv-analysis","data-visualization","investment-analysis","langchain","langgraph","multi-agent","plotly","python"],"created_at":"2026-06-23T00:01:34.878Z","updated_at":"2026-06-23T00:01:36.728Z","avatar_url":"https://github.com/erishen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LangGraph CSV Analyst\n\n[中文文档](README.zh-CN.md)\n\nA CSV analysis tool using LangGraph multi-agent pipeline for automated data profiling, trend analysis, anomaly detection, and **investment portfolio analysis** (asset-lens integration) with HTML report generation.\n\n## Architecture\n\n```\n                    ┌─────────────┐\n                    │   CSV File   │\n                    └──────┬──────┘\n                           │\n                    ┌──────▼──────┐\n                    │    Parser    │\n                    └──────┬──────┘\n                           │\n              ┌────────────┼────────────┬────────────┐\n              │            │            │            │\n     ┌────────▼───┐ ┌──────▼─────┐ ┌───▼────────┐ ┌──▼──────────┐\n     │  Profiler   │ │   Trend    │ │  Anomaly   │ │ Investment  │\n     │   Agent     │ │ Analyzer   │ │  Detector  │ │  Analyzer   │\n     └────────┬───┘ └──────┬─────┘ └───┬────────┘ └──┬──────────┘\n              │            │            │              │\n              └────────────┼────────────┼──────────────┘\n                           │            │\n                  ┌────────▼────────────▼┐\n                  │     Report           │\n                  │    Generator         │\n                  └────────┬─────────────┘\n                           │\n                  ┌────────▼────────┐\n                  │   HTML Report   │\n                  └─────────────────┘\n```\n\n### Investment Analyzer (asset-lens)\n\nWhen the input CSV is an asset-lens output (e.g. `investment_return_analysis_*.csv`), the Investment Analyzer automatically:\n\n- **Detects** asset-lens format by column keywords (return rate, IRR, annualized, etc.)\n- **Calculates** return distribution (loss / 0-2% / 2-5% / 5-10% / 10-20% / 20%+)\n- **Assesses** portfolio risk (low return, negative return products)\n- **Generates** LLM-powered insights (health assessment, rebalancing suggestions)\n- **Visualizes** return distribution pie chart, return stats bar chart, risk assessment chart\n\n## Project Structure\n\n```\nlanggraph-csv-analyst/\n├── src/langgraph_csv_analyst/\n│   ├── __init__.py          # Package init with version\n│   ├── config.py            # Configuration (pydantic-settings)\n│   ├── csv_parser.py        # CSV parsing and profiling\n│   ├── agents.py            # Multi-agent definitions\n│   ├── graph.py             # LangGraph state graph\n│   ├── visualization.py     # Plotly chart generation + HTML report\n│   ├── api.py               # FastAPI service\n│   └── cli.py               # CLI (Typer)\n├── tests/\n│   ├── __init__.py\n│   └── test_csv_parser.py   # CSV parser tests\n├── pyproject.toml\n├── .env.example\n├── .gitignore\n├── Makefile\n├── README.md\n└── README.zh-CN.md\n```\n\n## Quick Start\n\n### 1. Install Dependencies\n\n```bash\ncd invest-kit/apps/langgraph-csv-analyst\nuv sync\n```\n\n### 2. Configure Environment\n\n```bash\ncp .env.example .env\n# Edit .env and set your OPENAI_API_KEY\n```\n\n### 3. Run Analysis\n\n```bash\n# Full analysis with HTML report\nuv run langgraph-analyst analyze sample.csv\n\n# Quick data profile\nuv run langgraph-analyst profile sample.csv\n\n# Start API server\nuv run langgraph-analyst-api\n```\n\nOr use Make:\n\n```bash\nmake install\nmake analyze FILE=sample.csv\nmake profile FILE=sample.csv\nmake api\n```\n\n## API Endpoints\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| `POST` | `/api/v1/analyze` | Upload CSV and run full analysis |\n| `GET` | `/api/v1/report/{task_id}` | Get analysis report |\n| `GET` | `/api/v1/health` | Health check |\n\n### Example: Upload and Analyze\n\n```bash\ncurl -X POST \"http://localhost:8001/api/v1/analyze\" \\\n  -F \"file=@sample.csv\"\n```\n\n### Example: Get Report\n\n```bash\ncurl \"http://localhost:8001/api/v1/report/{task_id}\"\n```\n\n## Configuration\n\nAll settings are loaded from `.env` file using pydantic-settings:\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `DEFAULT_MODEL` | `deepseek-chat` | LLM model name |\n| `OPENAI_API_KEY` | - | OpenAI-compatible API key |\n| `OPENAI_BASE_URL` | `https://api.deepseek.com` | API base URL |\n| `CSV_MAX_SIZE_MB` | `50` | Maximum CSV file size in MB |\n| `MAX_ROWS_DISPLAY` | `100` | Maximum rows to display |\n| `API_HOST` | `0.0.0.0` | API server host |\n| `API_PORT` | `8001` | API server port |\n| `DEBUG` | `False` | Debug mode |\n\n## LangGraph State Graph\n\nThe analysis pipeline is built as a LangGraph `StateGraph` with the following flow:\n\n1. **load_csv** - Load and validate the CSV file\n2. **profile** - Profile data types, statistics, and null counts\n3. **Parallel Execution**:\n   - **trend_analyzer** - Analyze trends and patterns using LLM\n   - **anomaly_detector** - Detect outliers using IQR method + LLM analysis\n   - **investment_analyzer** - Analyze investment portfolio (asset-lens format)\n4. **generate_report** - Compile all results into an HTML report\n\nThe `AnalysisState` TypedDict tracks:\n\n```python\nclass AnalysisState(TypedDict, total=False):\n    csv_path: str              # Input CSV file path\n    dataframe_info: dict       # Shape, columns, dtypes\n    profile: dict              # Full data profile\n    trends: dict               # Trend analysis results\n    anomalies: dict            # Anomaly detection results\n    investment_analysis: dict  # Investment portfolio analysis\n    report: str                # Generated HTML report\n    errors: list[str]          # Collected errors\n```\n\nError handling is integrated via conditional edges that route to an `error_handler` node when errors are detected at any stage.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferishen%2Flanggraph-csv-analyst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferishen%2Flanggraph-csv-analyst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferishen%2Flanggraph-csv-analyst/lists"}