Skip to content

NullLabTests/optiflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โšก OptiFlow

Intelligent Workflow Orchestrator & Self-Optimizing System

Python FastAPI Next.js PostgreSQL React Flow Docker License AI Status


Define โ†’ Execute โ†’ Profile โ†’ Optimize โ†’ Repeat.
OptiFlow turns complex multi-step workflows into self-improving pipelines.

๐Ÿง  What is OptiFlow?

OptiFlow is a full-stack application that lets you define complex, multi-step workflows as directed acyclic graphs (DAGs), executes them with full parallelism and error handling, profiles every run down to the millisecond, automatically detects bottlenecks, and uses AI to suggest and apply optimizations.

The system embodies a continuous improvement loop: build โ†’ run โ†’ measure โ†’ learn โ†’ improve.

โœจ Features

๐ŸŽฏ Core

  • DAG Workflow Editor โ€” Visual drag-and-drop with React Flow
  • Natural Language Creation โ€” Describe a workflow, AI generates the DAG
  • 4 Task Types โ€” Python, HTTP, File, Simulate (for profiling demos)
  • Execution Engine โ€” Async DAG scheduler with parallelism, retries, timeouts
  • Real-time Dashboard โ€” Run history, execution timelines, live status

๐Ÿš€ Intelligence

  • Deep Profiling โ€” Per-task timing, resource estimates, variance analysis
  • Bottleneck Detection โ€” Automatic identification of slow paths
  • AI Optimization โ€” DeepSeek-powered suggestions (parallelize, cache, restructure)
  • One-Click Apply โ€” Apply suggestions and re-run to measure impact
  • Analytics โ€” Success rates, avg durations, optimization impact over time

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    ๐Ÿ–ฅ๏ธ  Frontend (Next.js 16)                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚Dashboard โ”‚  โ”‚ DAG Editorโ”‚  โ”‚  Profile โ”‚  โ”‚Analytics  โ”‚  โ”‚
โ”‚  โ”‚          โ”‚  โ”‚React Flow โ”‚  โ”‚  Viewer  โ”‚  โ”‚ Dashboard โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚              โ”‚              โ”‚              โ”‚
        โ–ผ              โ–ผ              โ–ผ              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   โš™๏ธ  Backend (FastAPI)                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  REST API  โ”‚  โ”‚ Execution โ”‚  โ”‚Profilerโ”‚  โ”‚Optimizer  โ”‚  โ”‚
โ”‚  โ”‚            โ”‚  โ”‚  Engine   โ”‚  โ”‚Service โ”‚  โ”‚Service    โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                    โ”‚        โ”‚
โ”‚                                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚                                         โ”‚  AI Service     โ”‚ โ”‚
โ”‚                                         โ”‚ (DeepSeek API)  โ”‚ โ”‚
โ”‚                                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     ๐Ÿ—„๏ธ  PostgreSQL 16                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚Workflows โ”‚  โ”‚   Tasks  โ”‚  โ”‚   Runs   โ”‚  โ”‚Suggestions  โ”‚  โ”‚
โ”‚  โ”‚  + DAGs  โ”‚  โ”‚          โ”‚  โ”‚+ Profilesโ”‚  โ”‚+ Optimiz.   โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Tech Stack

Layer Technology Why
๐Ÿ–ฅ๏ธ Frontend Next.js 16 + Tailwind + React Flow + Recharts Modern, fast, best-in-class DAG visualization
โš™๏ธ Backend FastAPI + SQLAlchemy + asyncio Async-native Python, seamless AI/ML integration
๐Ÿ—„๏ธ Database PostgreSQL 16 Mature, reliable, native JSON support
๐Ÿค– AI DeepSeek API (OpenAI-compatible SDK) Superior reasoning for optimization tasks
๐Ÿšฆ Queue In-process asyncio (Redis-ready) Zero overhead for MVP, drop-in Celery later
๐Ÿณ Infra Docker Compose One-command full-stack deployment

๐Ÿš€ Quick Start

๐Ÿณ Docker (Recommended)

# Clone and launch everything
git clone https://github.com/NullLabTests/optiflow.git
cd optiflow
docker compose up --build

Then open http://localhost:3000 ๐ŸŽ‰

๐Ÿ”ง Manual Setup

# Backend
cd backend
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env          # Edit DB URL + DeepSeek key
uvicorn app.main:app --reload --port 8000 &

# Frontend
cd ../frontend
npm install
npm run dev
Service URL
๐ŸŒ Frontend http://localhost:3000
๐Ÿ“ก API http://localhost:8000
๐Ÿ“– Docs http://localhost:8000/docs
๐Ÿ“˜ ReDoc http://localhost:8000/redoc

๐ŸŽฎ Usage

Creating a Workflow

Method How
๐Ÿ–ฑ๏ธ Visual Editor Navigate to Workflows โ†’ New Workflow โ†’ Add Tasks โ†’ Drag edges between nodes
๐Ÿ’ฌ Natural Language On Dashboard, type "Fetch data from an API, transform it with Python, then simulate heavy processing" โ†’ click Create with AI

The Optimization Loop

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Build  โ”‚โ”€โ”€โ”€โ–ถโ”‚  Execute โ”‚โ”€โ”€โ”€โ–ถโ”‚  Profile  โ”‚โ”€โ”€โ”€โ–ถโ”‚Analyze โ”‚โ”€โ”€โ”€โ–ถโ”‚ Optimizeโ”‚
โ”‚ Workflowโ”‚    โ”‚  DAG     โ”‚    โ”‚  Metrics  โ”‚    โ”‚  Bottl.โ”‚    โ”‚  +Apply โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
      โ–ฒ                                                            โ”‚
      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Re-run โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. Run โ†’ Click Execute on any workflow
  2. Profile โ†’ View per-task timing, bottlenecks, critical path
  3. Analyze โ†’ Click Analyze for AI/rule-based optimization suggestions
  4. Apply โ†’ One-click apply suggestions (parallelize, cache, restructure)
  5. Re-run โ†’ Measure the improvement, rinse and repeat

๐Ÿ“ก API Reference

All endpoints under /api/v1/. Auth via Bearer token.

Authentication

Method Endpoint Description
POST /auth/register Create account
POST /auth/login Sign in
GET /auth/me Current user

Workflows

Method Endpoint Description
POST /workflows Create workflow
GET /workflows List all workflows
GET /workflows/{id} Get workflow + DAG
PUT /workflows/{id} Update workflow
DELETE /workflows/{id} Delete workflow
POST /workflows/from-nl Create from natural language
POST /workflows/{id}/execute Execute workflow
GET /workflows/{id}/runs List run history

Profiling & Optimization

Method Endpoint Description
GET /runs/{id}/profile Profile report with bottlenecks
POST /workflows/{id}/analyze Generate optimization suggestions
GET /workflows/{id}/suggestions List all suggestions
POST /optimizations/apply Apply a suggestion

Analytics

Method Endpoint Description
GET /analytics/summary Aggregate stats

๐Ÿงช Testing

cd backend
source venv/bin/activate
python -m pytest tests/ -v
โœ“ test_password_hashing
โœ“ test_jwt_tokens
โœ“ test_profile_report_generation
โœ“ test_profile_with_failures
โœ“ test_profile_parallelism_efficiency
โœ“ test_empty_run
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
6 passed in 0.61s

๐Ÿ“ Project Structure

optiflow/
โ”œโ”€โ”€ ๐Ÿณ docker-compose.yml
โ”‚
โ”œโ”€โ”€ โš™๏ธ backend/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ api/          # FastAPI route handlers
โ”‚   โ”‚   โ”œโ”€โ”€ core/         # Config, DB engine, auth
โ”‚   โ”‚   โ”œโ”€โ”€ models/       # SQLAlchemy ORM models
โ”‚   โ”‚   โ”œโ”€โ”€ schemas/      # Pydantic request/response schemas
โ”‚   โ”‚   โ””โ”€โ”€ services/     # Business logic layer
โ”‚   โ”‚       โ”œโ”€โ”€ execution_service.py   # ๐Ÿง  DAG scheduler + task runner
โ”‚   โ”‚       โ”œโ”€โ”€ profiler_service.py    # ๐Ÿ“Š Metrics + bottleneck detection
โ”‚   โ”‚       โ”œโ”€โ”€ optimization_service.py # ๐Ÿ’ก Rule-based suggestions
โ”‚   โ”‚       โ”œโ”€โ”€ ai_service.py          # ๐Ÿค– DeepSeek integration
โ”‚   โ”‚       โ””โ”€โ”€ workflow_service.py    # ๐Ÿ“‹ CRUD operations
โ”‚   โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ Dockerfile
โ”‚
โ””โ”€โ”€ ๐Ÿ–ฅ๏ธ frontend/
    โ””โ”€โ”€ src/
        โ”œโ”€โ”€ app/           # Next.js 16 app router pages
        โ”œโ”€โ”€ components/    # React components
        โ””โ”€โ”€ lib/           # API client, utilities

๐Ÿค– AI Integration

OptiFlow leverages DeepSeek (via OpenAI-compatible SDK) for three capabilities:

Feature Without API Key With DeepSeek API Key
๐Ÿงฉ Natural Language โ†’ Workflow Mock template (3-task pipeline) AI generates optimal DAG from description
๐Ÿ” Optimization Analysis Rule-based (parallelize, cache, structure) Context-aware AI suggestions with code diffs
๐Ÿ“ Code Review Static tips Deep analysis with specific improvements
# In backend/.env
DEEPSEEK_API_KEY=sk-your-key-here
DEEPSEEK_MODEL=deepseek-chat

๐Ÿ“Š The Optimization Loop in Action

Before Optimization                    After Optimization
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Task A โ†’ 1200ms  โ”‚                  โ”‚ Task A โ†’ 800ms   โ”‚
โ”‚ Task B โ†’ 1100ms  โ”‚    AI Analyzes  โ”‚ Task B โ†’ 800ms   โ”‚โ—€โ”€โ”€ Parallelized!
โ”‚ Task C โ†’ 1300ms  โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ โ”‚ Task C โ†’ 900ms   โ”‚
โ”‚ Total:  3600ms   โ”‚    + Caching    โ”‚ Total:  2500ms   โ”‚
โ”‚ Bottleneck: A,B,Cโ”‚                  โ”‚ 31% faster! ๐ŸŽ‰   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“œ License

MIT License โ€” see LICENSE.


Built with ๐Ÿง  by NullLabTests

โญ Star this repo if you find it useful!
๐Ÿ› Report a Bug ยท ๐Ÿ’ก Request Feature

About

Intelligent Workflow Orchestrator & Self-Optimizing System. Define DAG workflows, execute with parallelism, profile runs, detect bottlenecks, and auto-optimize with AI

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors