InkFlow AI - Multi-Agent AI Blog Generation Platform

LangGraphLangChainFastAPINext.jsMistral AITavily APIPollinations AIAgentic AI

āœ’ļø Inkflow AI — Autonomous Multi-Agent AI Blog Writer

Inkflow AI is an advanced, full-stack, autonomous multi-agent content generation platform. It converts high-level topics into deeply researched, structured, fully illustrated, and professionally formatted technical blog posts in real time.

Powered by LangGraph, FastAPI, Mistral AI, Tavily Search, and Next.js 16, Inkflow AI orchestrates a team of specialized AI agents that dynamically perform web research, formulate execution blueprints, write sections in parallel, plan visual assets, generate custom illustrations on the fly, and stream progress live to an interactive dark-themed web application.


šŸ—ļø System Architecture & Workflow

                                    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                    │      Next.js 16 Web Application        │
                                    │    (Zustand State & SSE Listener)      │
                                    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                      SSE Stream / REST │ POST /blog/stream
                                                        ā–¼
                                    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                    │          FastAPI Async Backend         │
                                    │        (Middleware & Static Server)    │
                                    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                                        ā–¼
                                    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                    │       LangGraph Multi-Agent DAG        │
                                    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                     ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                     │                                     │
                                     ā–¼                                     ā–¼
                        ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”            ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                        │      Router Agent      │            │     Research Agent     │
                        │ (Mistral AI Reasoning) │            │   (Tavily Search API)  │
                        ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜            ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                     │                                     │
                                     ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                                        ā–¼
                                           ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                           │   Orchestrator Agent   │
                                           │   (Outline & Strategy) │
                                           ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                                        ā–¼
                                           ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                           │ Parallel Worker Agents │
                                           │  (Fan-out Sub-sections)│
                                           ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                                        ā–¼
                                           ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                           │    Reducer Subgraph    │
                                           │ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │
                                           │ │ Merge Markdown     │ │
                                           │ ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤ │
                                           │ │ Decide Images      │ │
                                           │ ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤ │
                                           │ │ Pollinations.ai    │ │
                                           │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ │
                                           ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                                        ā–¼
                                           ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                                           │ Markdown & Image Asset │
                                           │        Export          │
                                           ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

🌟 Key Concepts & Architectural Highlights

1. LangGraph Multi-Agent Orchestration

Instead of relying on a single prompt-response LLM call, Inkflow AI decomposes blog creation into a deterministic state machine managed by LangGraph (StateGraph):

  • Shared Execution State (State): Tracks topic context, recency parameters, evidence list, writing plan, section outputs, image specs, and final markdown content.
  • Router Agent (router.py): Classifies user queries into execution modes:
    • Open Book (7-Day Cutoff): Used for breaking news and current events. Forces format to news_roundup.
    • Hybrid (45-Day Cutoff): Used for ongoing industry developments and tech updates.
    • Closed Book (3650-Day Cutoff): Used for evergreen/educational topics using LLM parametric knowledge.
  • Research Agent (research.py): Executes targeted Tavily web queries in parallel, extracts structured evidence (EvidencePack), deduplicates URLs, and filters out stale references based on recency rules.
  • Orchestrator Agent (orchestrator.py): Acts as the managing editor. Constructs a detailed writing Plan defining blog title, target audience, tone, style constraints, and section tasks (Task).
  • Worker Agents (worker.py): Executes section-writing tasks in parallel using LangGraph fan-out routing (fanout). Workers strictly adhere to word count targets and cite evidence URLs.
  • Reducer Subgraph (reducer.py):
    1. merge_content: Aggregates and orders drafted sections into a cohesive markdown draft.
    2. decide_images: Analyzes text flow and proposes image placements (GlobalImagePlan) with visual prompts.
    3. generate_and_place_images: Concurrently fetches image binaries from Pollinations.ai, saves them to output/images/, updates image tags, and exports the final .md file.

2. ⚔ 3-Tier Resilient SSE Streaming Architecture

The frontend web application communicates with the backend through a 3-tier resilient streaming engine (api.ts):

  • Tier 1 (Live SSE Stream): Connects to /blog/stream via text/event-stream POST request. Parses incoming events in real time to update progress indicators, node step labels, evidence counters, and terminal logs without polling.
  • Tier 2 (Snapshot Recovery): If network interruptions terminate the stream prematurely, state is recovered using the last parsed stream payload snapshot.
  • Tier 3 (Batch Rest Fallback): If streaming is unsupported or blocked by proxies, the frontend transparently falls back to POST /blog/generate.

3. šŸŽØ Dark-Themed Next.js 16 Web Workspace

The frontend provides a dark-themed user interface:

  • Interactive Generation Suite: Real-time progress tracker (ProgressTracker.tsx) and live terminal log stream (EventLog.tsx).
  • Multi-Tab Workspace:
    • Blog Reader: Renders styled GitHub-flavored markdown with code syntax highlighting and resolved image URLs (BlogRenderer.tsx).
    • Plan Blueprint: Displays multi-agent task breakdown, target word counts, and audience strategy (PlanPanel.tsx).
    • Evidence Panel: Interactive list of research web sources and citations (EvidencePanel.tsx).
    • Gallery & Image Specs: Image grid browser and raw prompt JSON inspector.
    • ZIP Bundle Export: One-click export bundling markdown and local image assets into a .zip archive using JSZip (ExportMenu.tsx).

šŸ“ Repository Structure

inkflow-ai/
ā”œā”€ā”€ backend/                     # FastAPI & LangGraph Python Engine
│   ā”œā”€ā”€ app/
│   │   ā”œā”€ā”€ api/                 # REST routes (/generate, /stream) & schemas
│   │   ā”œā”€ā”€ config/              # App settings & LLM initialization (Mistral AI)
│   │   ā”œā”€ā”€ graph/               # LangGraph DAG (router, research, orchestrator, worker, reducer)
│   │   ā”œā”€ā”€ models/              # Pydantic state & data domain models
│   │   ā”œā”€ā”€ prompts/             # System prompts for AI agents
│   │   ā”œā”€ā”€ services/            # File I/O, Tavily search, Pollinations.ai image generator
│   │   └── main.py              # FastAPI entry point & CORS configuration
│   ā”œā”€ā”€ output/                  # Generated .md blogs & output/images directory
│   ā”œā”€ā”€ .env                     # Environment variables (API Keys)
│   ā”œā”€ā”€ requirements.txt         # Python backend dependencies
│   └── README.md                # Detailed Backend Documentation
ā”œā”€ā”€ frontend/                    # Next.js 16 Web Application
│   ā”œā”€ā”€ app/                     # App Router pages & layout
│   ā”œā”€ā”€ components/              # UI components (Generation, Reader, Layout)
│   ā”œā”€ā”€ lib/                     # Zustand store, API SSE client, Export utilities
│   ā”œā”€ā”€ package.json             # Frontend Node dependencies
│   └── README.md                # Detailed Frontend Documentation
└── README.md                    # Root Project Documentation

šŸ› ļø Tech Stack & Key Libraries

ComponentStack / LibraryKey Purpose
Backend FrameworkFastAPI + UvicornHigh-performance async REST & streaming web server
Agentic FrameworkLangGraph + LangChainStateful multi-agent workflow orchestration & DAG execution
LLM ProviderMistral AI (mistral-medium-latest)Reasoning, planning, evidence synthesis, and content generation
Web ResearchTavily Search APIReal-time web research and citation extraction
Image SynthesisPollinations.aiContextual AI image generation REST API
Frontend FrameworkNext.js 16 (App Router) + React 19SSR/CSR web framework
State ManagementZustand 5Global reactive state store
Styling & MotionTailwind CSS v4 + Framer Motion 12Dark-themed UI and smooth animations
Markdown Processingreact-markdown + remark-gfmGitHub-flavored markdown rendering
File Archivingjszip + date-fnsClient-side ZIP bundle packaging

šŸš€ Quickstart Guide

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Valid API Keys for Mistral AI and Tavily

1. Backend Setup

bash
# Navigate to backend directory
cd backend

# Create and activate virtual environment
python -m venv .venv
# On Windows (PowerShell):
.venv\Scripts\Activate.ps1
# On Linux/macOS:
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file in backend/ root
cat <<EOT > .env
MISTRAL_API_KEY=your_mistral_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
EOT

# Start FastAPI dev server
uvicorn app.main:app --reload --port 8000

Backend API will be running at: http://localhost:8000 (Swagger docs at http://localhost:8000/docs).


2. Frontend Setup

bash
# Open a new terminal and navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Create .env.local file in frontend/ root
cat <<EOT > .env.local
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
EOT

# Start Next.js development server
npm run dev

Frontend web application will be accessible at: http://localhost:3000.


šŸ“” API Endpoints Reference

EndpointMethodDescription
GET /GETAPI Health Check.
POST /blog/streamPOSTServer-Sent Events (SSE) endpoint. Streams live LangGraph node updates and final result payload.
POST /blog/generatePOSTSynchronous REST endpoint. Runs the graph to completion and returns full blog JSON payload.

šŸ“ License

Distributed under the MIT License. See LICENSE for details.