Ad163/InsightFlow-
Transform scattered communications into strategic intelligence - ML-powered weekly analysis engine
InsightFlow
Transform scattered communications into strategic intelligence
๐ฏ What is InsightFlow?
InsightFlow automatically ingests emails and meetings, uses ML-powered topic detection to identify patterns, and generates weekly strategic briefs that help leaders stay ahead of organizational drift.
Key Features:
- ๐ค AI-Optional Design: Works perfectly without AI; Gemini enhancement is optional
- ๐ Smart Topic Detection: HDBSCAN clustering + embeddings find emerging patterns
- ๐ฏ Rules-First Intelligence: Deterministic metrics with 28-day baseline comparison
- ๐ Evidence-Backed: Full audit trail linking insights to original sources
- ๐ Production Ready: Docker-containerized, fully tested, zero-config startup
โก Quick Start (5 Minutes)
Option 1: Docker (Recommended - No Setup Required)
# 1. Clone the repository
git clone https://github.com/yourusername/InsightFlow.git
cd InsightFlow
# 2. Create .env file (uses defaults, no API keys needed)
copy .env.example .env
# 3. Start all services
docker-compose up -d
# 4. Open dashboard
# http://localhost:8000/static/index.html
# That's it! ๐What you get:
- โ PostgreSQL with pgvector
- โ FastAPI backend with dashboard
- โ Rules-only mode (no AI required)
- โ Manual analysis trigger
- โ Beautiful web UI
Option 2: Add AI Enhancement (Optional)
# 1. Get free Gemini API key
# Visit: https://makersuite.google.com/app/apikey
# 2. Edit .env file
# Set: LLM_ENABLED=true
# Set: GEMINI_API_KEY=your-key-here
# 3. Restart services
docker-compose restart api
# Now you have AI-enhanced strategic insights! โจOption 3: Local Development
# 1. Create virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # Linux/Mac
# 2. Install dependencies
pip install -r requirements.txt
# 3. Set up PostgreSQL
createdb insightflow_db
psql insightflow_db < sql/schema.sql
# 4. Configure .env
copy .env.example .env
# Edit DATABASE_URL if needed
# 5. Start API server
uvicorn api.main:app --reload
# 6. Access dashboard
# http://localhost:8000/static/index.html๐ Documentation
- Setup Guide - Detailed installation instructions
- Docker Guide - Container deployment
- Project Documentation - Complete technical spec
- N8N Testing Guide - Workflow integration
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ
โ Data Sources โ Gmail, Read.ai, etc.
โ (via n8n) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ FastAPI โ /ingest/email, /ingest/meeting
โ Ingestion โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ PostgreSQL + โ Vector storage + relational data
โ pgvector โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Weekly Analysis โ Embeddings โ Clustering โ Rules โ LLM (optional)
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Dashboard + โ Web UI + Slack delivery
โ Delivery โ
โโโโโโโโโโโโโโโโโโโ
Processing Pipeline:
- Ingestion - Validate & store events (emails/meetings)
- Embeddings - Generate 384-dim vectors (MiniLM)
- Clustering - HDBSCAN topic detection
- Metrics - Compute deltas vs 28-day baseline
- Rules - Apply 4 deterministic finding rules
- LLM - Optional Gemini enhancement
- Render - Markdown brief + JSON audit trail
- Deliver - Dashboard + Slack notification
๐จ Dashboard Features
Access at http://localhost:8000/static/index.html
- Overview - Real-time metrics, charts, latest brief preview
- Weekly Briefs - Historical briefs with LLM enhancement indicators
- Trends - Week-over-week visualizations
- Recent Events - Sortable table with source links for traceability
- Manual Trigger - "Run Analysis Now" button (no wait for weekly timer)
- LLM Status - Visual indicator showing AI enhancement status
๐ง Configuration
Environment Variables
Edit .env file to configure:
| Variable | Default | Description |
|---|---|---|
LLM_ENABLED |
false |
Enable/disable AI enhancement |
GEMINI_API_KEY |
- | API key for Gemini (optional) |
DATABASE_URL |
docker default | PostgreSQL connection string |
SLACK_WEBHOOK_URL |
- | Slack delivery (optional) |
CLUSTERING_MIN_SIZE |
3 |
Minimum events per topic |
EMERGING_RISK_FREQ_PCT |
30 |
Risk detection threshold |
See .env.example for all options.
Toggle AI Enhancement
# Disable AI (rules-only mode)
LLM_ENABLED=false
# Enable AI (requires API key)
LLM_ENABLED=true
GEMINI_API_KEY=your-key-here
# Restart to apply
docker-compose restart api๐ Data Ingestion
Via n8n Workflows (Recommended)
Import workflows from n8n/workflows/:
gmail-ingestion.json- Email automationreadai-ingestion.json- Meeting transcripts
Direct API
# Ingest an email
curl -X POST http://localhost:8000/ingest/email \
-H "Content-Type: application/json" \
-d '{
"id": "email_001",
"source": "email",
"timestamp": "2026-01-08T10:00:00Z",
"actor": "alice@company.com",
"direction": "inbound",
"subject": "Q1 Budget Review",
"text": "Attached is the revised budget...",
"thread_id": "thread_001",
"decision": "deferred",
"action_owner": null,
"follow_up_required": true,
"urgency_score": 7,
"sentiment": "unknown",
"raw_ref": "https://mail.google.com/..."
}'๐งช Testing
# Run all tests
pytest
# With coverage
pytest --cov=src --cov-report=html
# Specific test suite
pytest tests/unit/
pytest tests/api/
pytest tests/integration/๐ฆ Project Structure
InsightFlow/
โโโ api/ # FastAPI backend
โ โโโ main.py # Ingestion endpoints
โ โโโ dashboard.py # Dashboard API + settings
โ โโโ schemas.py # Pydantic models
โโโ src/insight/ # Core engine
โ โโโ clustering.py # HDBSCAN topic detection
โ โโโ llm_client.py # Gemini integration
โ โโโ rules.py # Finding generation
โ โโโ renderer.py # Markdown + JSON output
โ โโโ services.py # Metrics computation
โโโ scripts/ # Automation
โ โโโ weekly_run.py # Main orchestration
โ โโโ export_brief.py # Export utilities
โโโ static/ # Web dashboard
โ โโโ index.html # Single-page app
โโโ sql/ # Database schema
โ โโโ schema.sql # PostgreSQL + pgvector
โโโ n8n/ # Workflow templates
โโโ tests/ # Test suites
โโโ docker-compose.yml # Container orchestration
๐ Deployment
Docker (Recommended)
# Production deployment
docker-compose -f docker-compose.prod.yml up -d
# Set up weekly automation
sudo cp systemd/insightflow-weekly.* /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable insightflow-weekly.timer
sudo systemctl start insightflow-weekly.timerManual Deployment
See SETUP_GUIDE.md for Hostinger VPS deployment.
๐ Security
- API keys in
.env(gitignored) - Database credentials in environment variables
- No sensitive data sent to LLM (only pre-computed metrics)
- Slack webhooks for secure delivery
๐ค Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Make changes and add tests
- Run test suite (
pytest) - Commit with conventional commits
- Push and open Pull Request
๐ License
MIT License - See LICENSE for details
๐ Use Cases
For Teams
- Clone and run immediately (Docker)
- Add to existing n8n workflows
- Customize rules for your domain
- Self-host on any VPS
For Developers
- Clean architecture example
- Production-ready FastAPI patterns
- ML pipeline best practices
- Docker deployment templates
For Researchers
- Embedding-based clustering
- LLM-optional design patterns
- Deterministic + AI hybrid systems
- Full audit trail for reproducibility
๐ก Tips
First Time Setup:
- Start with Docker (zero config)
- Test with manual analysis trigger
- Add sample data via API
- Enable AI when ready
Customization:
- Edit rules in
src/insight/rules.py - Adjust thresholds in
.env - Modify dashboard in
static/index.html - Add new metrics in
src/insight/services.py
Troubleshooting:
- Check logs:
docker-compose logs -f api - Test API:
http://localhost:8000/docs - Verify DB:
docker-compose exec db psql -U insightflow - LLM status: Dashboard header shows active/disabled
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: johnsavilesh@gmail.com
Transform your organization's communication into strategic intelligence ๐