Skip to content

Prachet-Dev-Singh/WorkFlowGen-Agentic-AI-RAG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– WorkFlowGen β€” Generative AI Document Intelligence Platform

Generative AI RAG FastAPI

An End-to-End Agentic RAG System for Intelligent Document Processing and Analysis

Key Features β€’ Tech Stack β€’ Architecture β€’ Installation β€’ Usage

WorkFlowGen moves beyond traditional chatbots by implementing a Semantic Router powered by Google Gemini 2.0 Flash.
It intelligently classifies user intent (QA vs. Summarization) and routes requests to specialized agents using a LangGraph State Machine.


πŸš€ Key Features

Feature Description
🧠 Agentic Workflow Replaces linear logic with a cyclic LangGraph state machine for decision-making.
🎯 Semantic Routing Uses structured JSON output to distinguish between "help/critique" (QA) and "overview" (Summary) requests without brittle keywords.
⚑ Structured Output Enforces strict JSON schemas on the LLM to prevent routing errors and hallucinations.
πŸ” Smart Retrieval Uses pgvector for similarity search to fetch precise context from documents.
πŸ“„ Async Ingestion Handles PDF/Text parsing and vectorization asynchronously using FastAPI.
πŸ“Š Modern UI Real-time, responsive dashboard built with Next.js 16, Tailwind CSS, and Lucide Icons.

πŸ› οΈ Tech Stack

Frontend Backend Data & AI Deployment
Next.js 16, Tailwind CSS, Lucide Icons FastAPI, LangGraph pgvector, Google Gemini 2.0 Flash Docker, PostgreSQL

πŸ—οΈ Architecture

The system follows a cyclic graph architecture rather than a linear chain:

flowchart TD
    A[User Input] --> B[FastAPI Endpoint]
    B --> C{LangGraph Workflow}

    subgraph Agent_Brain [Agent Brain]
        C --> D[Retriever Node]
        D --> E[Semantic Router]

        E -->|Intent: QA| F[QA Generator]
        E -->|Intent: SUMMARY| G[Summary Generator]
    end

    F --> H[Final Response]
    G --> H
Loading

πŸ’» Local Installation Guide

Follow these steps to set up and run the WorkFlowGen Agentic Stack on your local machine.


🧩 1. Prerequisites

Before installation, make sure you have the following:

Tool Version Purpose
🐳 Docker Desktop Latest To run PostgreSQL (with pgvector)
🐍 Python 3.10+ Backend (FastAPI + LangGraph)
πŸ’š Node.js 18+ Frontend (Next.js 16 + Tailwind CSS)

πŸ“₯ 2. Clone the Repository

git clone https://github.com/Prachet-Dev-Singh/WorkFlowGen.git
cd WorkFlowGen

πŸ—ƒοΈ 3. Database Setup (PostgreSQL + pgvector via Docker)

Spin up the database container:

docker compose -f infra/docker-compose.yml up -d

βœ… Verify that your database is running:

docker ps

This launches a PostgreSQL instance with pgvector extension pre-installed for efficient semantic search.


βš™οΈ 4. Backend Setup (FastAPI + LangGraph)

Navigate to the backend directory and create a virtual environment:

cd backend
python -m venv venv

Activate the environment:

# Windows (Git Bash)
source venv/Scripts/activate

# Mac/Linux
source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

πŸ”‘ Configure Environment Variables

Create a .env file inside the backend folder:

touch .env

Paste the following and replace YOUR_GEMINI_API_KEY_HERE:

# Local Docker Database
DATABASE_URL=postgresql+asyncpg://admin:password123@localhost:5432/workflowgen_db

# Google Gemini API Key
GEMINI_API_KEY=YOUR_GEMINI_API_KEY_HERE

πŸ—„οΈ Initialize the Database Schema

python init_db.py
# βœ… Tables created successfully!

πŸš€ Start the Backend Server

uvicorn app.main:app --reload

Backend runs on β†’ http://localhost:8000


🎨 5. Frontend Setup (Next.js + Tailwind CSS)

Open a new terminal and navigate to the frontend directory:

cd frontend
npm install
npm run dev

Frontend runs on β†’ http://localhost:3000


πŸ§ͺ 6. Testing the Application

  1. Open http://localhost:3000 in your browser.
  2. Upload a document (PDF or text) using the left upload panel.
  3. Try different queries:
    • πŸ“ β€œSummarize this document.” β†’ Routed to Summary Agent
    • πŸ’¬ β€œHow can I improve this email?” β†’ Routed to QA/Critique Agent
  4. Observe the backend terminal logs for real-time routing and reasoning steps.

🧹 7. Stopping the Containers

When done, stop Docker containers safely:

docker compose -f infra/docker-compose.yml down

🧰 Quick Recap

Component Tech Port Description
🧠 Backend FastAPI + LangGraph 8000 Handles semantic routing and agent logic
πŸ–₯️ Frontend Next.js + Tailwind 3000 Interactive UI for document upload and analysis
πŸ—ƒοΈ Database PostgreSQL + pgvector 5432 Vector similarity storage

πŸŽ‰ You’re all set!
WorkFlowGen is now fully functional on your local machine β€” explore, extend, and build agentic intelligence on your own data!


πŸ§ͺ How to Use

Once both servers are running:

  1. Open http://localhost:3000
  2. Use the Upload Panel to add PDFs or .txt files.
  3. Enter natural language queries:
    • 🧠 β€œSummarize this document.” β†’ Routed to Summary Agent
    • πŸ’¬ β€œWhat is the main argument of section 2?” β†’ Routed to QA Agent
  4. Watch the backend logs to see:
    • Intent classification (QA / SUMMARY)
    • Node transitions in the LangGraph
    • Final structured JSON response

πŸ’‘ Example Queries

Type Example Agent Invoked
Summary "Give me a short overview of this file" πŸ“ Summary Generator
Critique "How can I improve this paragraph?" πŸ’‘ QA Generator
Clarification "Explain section 3 in simple terms" πŸ’‘ QA Generator

πŸ“Š Debug View

In the backend terminal, you’ll see live logs like:

[Router] Intent detected: SUMMARY
[SummaryAgent] Fetching context from pgvector...
[SummaryAgent] Generating overview response...
[Graph] Returning final output to user.

This shows how the LangGraph state machine routes and executes agents dynamically.


πŸ“„ License

This project is licensed under the MIT License.


About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors