Skip to content

aarushi211/ImpactLink

Repository files navigation

⬑ ImpactLink

AI Grant Intelligence Platform for NGOs

Find grants Β· Write proposals Β· Build budgets

FastAPI React Supabase Groq

πŸŽ₯ Live Demo | πŸ—οΈ AI Architecture Deep-Dive


🌟 Overview

ImpactLink is a production-grade AI platform designed to bridge the resource gap for under-served NGOs. By combining Stateful Agentic Workflows with Deterministic Financial Logic, it transforms a complex 40-hour grant application cycle into a streamlined, high-quality output in minutes.

This repository demonstrates enterprise-level engineering, featuring Reflection Patterns, Graph Orchestration, and Localized RAG architecture.


⚑ Performance Metrics

All latency numbers below are real measurements captured via the built-in instrumentation layer (utils/metrics.py). Timings were recorded on a local development environment using Llama 3.3 70B on Groq LPU inference.

System-Level Summary

Metric Measured Value
Full 10-Section Proposal (Scratch) 19.7s end-to-end (parallel drafting + scoring + retries)
3-Section Rewrite (Improve) 2.8s end-to-end (parallel rewrite + scoring)
Average LLM Call Latency 0.99s (Groq LPU, Llama 3.3 70B)
Slot Extraction (per question) 0.31 – 0.78s including JSON parsing
Budget Generation Pipeline 1.33s (rule extraction + personnel + allocation)
API Request Overhead < 50ms for data endpoints

Pipeline Step Latencies (Measured)

Flow A: Improve Existing Proposal

Step Category Duration Details
Extract Funder Vocab Agent β†’ Node 0.71s 1 LLM call (0.67s) + JSON parse
Gap Analysis Agent β†’ Node 1.34s 1 LLM call (1.30s) + JSON parse
Rewrite Section (Γ—3 parallel) Node 2.84s wall-clock 3 sections rewritten concurrently
↳ executive_summary Agent + Score 1.43s Score: 85/100, 0 retries
↳ evaluation_plan Agent + Score 1.71s Score: 88/100, 0 retries
↳ program_description Agent + Score 1.40s Score: 85/100, 0 retries
Total Session (create β†’ review) API 5.48s

Flow B: Scratch Proposal (10 Sections)

Step Category Duration Details
Init Slots + Vocab Node 0.001s No grant description β†’ instant
Slot Filling (7 rounds) Agent 0.28 – 0.78s each LLM extraction + JSON parse per answer
Draft Sections (Γ—10 parallel) Node 19.68s wall-clock 2 workers, 10 sections
↳ executive_summary Draft + Score 2.55s Score: 85, 0 retries
↳ problem_statement Draft + Score 3.46s Score: 87, 0 retries
↳ proposed_solution Draft + Score 3.42s Score: 92, 0 retries
↳ target_beneficiaries Draft + Score 2.90s Score: 88, 0 retries
↳ budget_narrative Draft + Score + 2 Retries 9.80s Score: 70β†’70β†’92
↳ evaluation_plan Draft + Score 3.51s Score: 85, 0 retries
↳ sustainability Draft + Score 2.75s Score: 85, 0 retries
↳ equity_statement Draft + Score 2.69s Score: 85, 0 retries
Total Session (draft advance) API 19.99s

Budget Generation Pipeline

Step Duration Details
Extract Grant Rules Service ~0.3s
Extract Personnel Service 0.29 – 0.38s
Secondary Allocation LLM 0.94s
Compliance Enforcement CPU <10ms
Total Pipeline Service 1.33s

Key Insight β€” Self-Correction Cost: The budget_narrative section triggered 2 automatic retries (scored 70 β†’ 70 β†’ 92), adding ~6.3s. Sections passing on the first attempt average 2.5 – 3.5s each. The reflection loop is the primary latency variable.


πŸ—οΈ Architectural Topology: Stateful Reflection

Instead of a linear prompt chain, ImpactLink utilizes a LangGraph StateGraph to manage complex, multi-turn proposal drafting. This architecture enables Map-Reduce parallelism for section generation and iterative Self-Correction (Reflection).

graph TD
    A[User Prompt] --> B[VocabExtractor: init_slots]
    B --> C[slot_filling: Conversational Q&A]
    C -->|All slots filled| D[slot_confirm: Human Gate]
    D --> E[node_draft_sections: Parallel Orchestrator]

    subgraph "SectionSubgraph (Γ—10 parallel)"
        E --> F[SectionDraftAgent]
        F --> G[SectionScoringAgent]
        G -->|score β‰₯ 75| H[Section Approved]
        G -->|score < 75| I[SectionRewriteAgent]
        I --> G
    end

    H --> J[draft_review: Human Gate]
    J --> K[final_save]
    K --> L[complete: PDF Export]
Loading

πŸ› οΈ Core Engineering Challenges & Solutions

1. The "Hallucination-Proof" Budget Engine

  • Challenge: LLMs are probabilistic, but financial budgets require deterministic exactness.
  • Solution: Built a Deterministic-Agentic Hybrid. The LLM only parses intent (e.g., "Add a Project Manager"). That intent is fed into a rigid Python engine that enforces real-world constraints like local minimum wage laws and proportional indirect cost caps. Math is always perfect; AI is only the interface.

2. Robust RAG & Relational Search

  • Challenge: Most RAG implementations fail on long documents, and NGOs need grants that match hard metadata (e.g., Region: "Kenya"), not just semantic similarity.
  • Solution:
    • Tiered Retrieval: Uses SemanticChunker (percentile-based) to split documents contextually.
    • Unified Querying: Migrated to Supabase (PostgreSQL + pgvector). This enables SQL queries that filter by relational metadata first, then rank by semantic similarity in a single database round-trip.
    • Idempotent Lifecycle: Handled via PostgreSQL ON CONFLICT, ensuring grant updates or re-indexing operations are atomic and never duplicate data.

3. Output Observability: LLM-as-a-Judge

  • Challenge: Zero-shot drafts often lack the nuance required for high-stakes grant writing.
  • Solution: Every generated proposal section is audited by an autonomous Scoring Agent using a strict 100-point rubric assessing Alignment, Vocabulary, Specificity, and Persuasion. Sections scoring below 75 are automatically sent back to the Rewrite Node with targeted feedback.

4. Production Security & Resilience

  • Challenge: Public LLM APIs have strict rate limits, and serverless architectures face cold-start/clock-skew issues.
  • Solution:
    • Provider-Agnostic Failover: Architected a custom provider factory (utils/llm.py) that handles rate-limiting and service disruptions with exponential backoff, ensuring drafting sessions are highly available.
    • Auth Resilience: Custom verify_token middleware handles 1.5s clock-skew retries for Firebase JWTs, critical for cross-region serverless deployments.

πŸ“ Project Structure

impactlink/
β”œβ”€β”€ impactlink-backend/
β”‚   β”œβ”€β”€ agents/          # Multi-agent specialized logic (Draft, Build, Scoring)
β”‚   β”œβ”€β”€ api/             # FastAPI routers and SSE implementations
β”‚   β”œβ”€β”€ services/        # Core logic: Vector store, Budget engine, NGO matching
β”‚   β”œβ”€β”€ utils/           # Provider failover, Retry logic, and formatting
β”‚   β”œβ”€β”€ Data/            # Seed data and localization indices
β”‚   └── main.py          # Application entry point
└── impactlink-frontend/
    └── src/
        β”œβ”€β”€ pages/       # Dashboard and feature-specific views
        β”œβ”€β”€ hooks/       # AI state management (SSE, Drafting, Budgets)
        └── services/    # Centralized API logic (Axios)

βš™οΈ Setup & Verification

Prerequisites

  • Node.js (v18+)
  • Python (3.11+)
  • Docker (Optional)
  • Environment Variables: GROQ_API_KEY, DATABASE_URL, FIREBASE_STORAGE_BUCKET

Local Development

# 1. Start the Backend
cd impactlink-backend
pip install -r requirements.txt
python main.py

# 2. Start the Frontend
cd ../impactlink-frontend
npm install
npm run start

Automated Testing (E2E Pipeline) You can run the full integration test pipeline to verify the AI stack (PDF Parse -> RAG Search -> Scoring -> Budget Logic):

cd impactlink-backend
python testpipeline.py

πŸ“ˆ Roadmap: Enterprise Hardening (Next Steps)

[x] Production Migration: Transition from flat JSON/ChromaDB to Supabase + Cloud Run.
[x] API Resilience: Implemented robust failover handling for inference rate limits.
[ ] Database-Level RAG Execution: Migrating application-layer Python vector filtering into a unified Supabase RPC function to process hard metadata constraints (e.g., Region) and pgvector similarity in a single atomic database query.
[ ] Enterprise Data Security: Implementing Supabase Row Level Security (RLS) for cryptographic tenant isolation, alongside a custom PII Redaction Middleware to scrub sensitive NGO data before payloads reach the LLM inference layer.
[ ] Graph-Based RAG: Transitioning to Knowledge Graphs to map funder-to-NGO relationships visually.
[ ] Financial API Integrations: Direct integration with NGO-specific accounting software for real-time spend tracking.

Engineering Social Impact through Intelligent Automation

A production-grade AI platform for NGOs.

About

ImpactLink is an end-to-end AI platform that helps under-resourced NGOs compete for grant funding. Upload your proposal, get AI-matched grants, draft funder-specific applications, build localized budgets, and find partner organizations, all in one workflow.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors