GitHunt
AD

Ad163/InsightFlow-

Transform scattered communications into strategic intelligence - ML-powered weekly analysis engine

InsightFlow

Transform scattered communications into strategic intelligence

License: MIT
Python 3.10+
Docker

๐ŸŽฏ 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)

# 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


๐Ÿ—๏ธ 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:

  1. Ingestion - Validate & store events (emails/meetings)
  2. Embeddings - Generate 384-dim vectors (MiniLM)
  3. Clustering - HDBSCAN topic detection
  4. Metrics - Compute deltas vs 28-day baseline
  5. Rules - Apply 4 deterministic finding rules
  6. LLM - Optional Gemini enhancement
  7. Render - Markdown brief + JSON audit trail
  8. 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

Import workflows from n8n/workflows/:

  • gmail-ingestion.json - Email automation
  • readai-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

# 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.timer

Manual 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

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Make changes and add tests
  4. Run test suite (pytest)
  5. Commit with conventional commits
  6. 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:

  1. Start with Docker (zero config)
  2. Test with manual analysis trigger
  3. Add sample data via API
  4. 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


Transform your organization's communication into strategic intelligence ๐Ÿš€

Ad163/InsightFlow- | GitHunt