How eshaanpra/grantops works
Request path from UI to backend
The web app renders the user-facing workflows for grants, matches, pipeline, review, organization analysis, and workspaces. UI components call the API through a small client layer in apps/web/lib/api.ts, and most pages map directly to major product areas such as /grants, /matches, /pipeline, /review, /organization, and /workspaces/{id}.
API layer and domain boundaries
The FastAPI app exposes versioned endpoints under apps/api/app/api/v1. These endpoints are grouped by domain: auth, dashboard, grants, grantors, IRS 990, matches, orgs, pipeline, review, snapshots, sources, workspaces, and applicants. This is the main synchronous boundary for reads, writes, and action-triggered state changes.
Core business services
The API is structured around a service layer in apps/api/app/services rather than placing logic in endpoints. Key service clusters include:
• Ingestion for external data collection and source discovery
• Matching for grant-to-organization fit evaluation
• Parsing / extraction for turning documents into structured evidence
• Organization model analysis for uploaded org documents and boilerplate support
• Grant summaries and grantor verification for opportunity normalization and validation
• Audit and applicant profile support for workflow history and org profile data
Data model and persistence
The backend uses a relational database with Alembic migrations in apps/api/alembic. Models are split by domain in apps/api/app/models and include grants, applicants, IRS 990 data, matching, pipeline, sources, tenancy/workspaces, and shared enums/mixins. The presence of versioned migrations shows the schema is a first-class part of the architecture, with multi-step evolution already tracked.
Asynchronous processing
Background work is handled by Celery. The worker package contains tasks for ingestion, matching, applicant processing, and alerts. Redis is the broker/result backend in the default local stack, and Celery beat schedules recurring jobs such as IRS 990 intelligence refresh. This is the main async boundary between user actions and slow or periodic processing.
External data ingestion pipeline
A major subsystem ingests grant-related data from external/public sources. The repository includes adapters and registry logic for sources like Grants.gov and SAM assistance, plus IRS 990 ingestion and non-government source handling. Discovery logic promotes credible funders and then searches for official grant pages. This ingestion pipeline feeds the grant/source tables and downstream matching and review flows.
Document parsing and extraction
Uploaded or fetched documents pass through parsing and extraction services. There are dedicated PDF and HTML parsers, plus normalization and rule-based extraction components. This supports evidence-backed claim generation, confidence-aware review, and snapshot/history behavior rather than treating extracted text as raw blobs.
Organization analysis and local model integration
Organization document analysis is a specialized flow used by the /organization area. The repo explicitly supports a local LLM runtime via Docker Model Runner and a configurable model URL. Uploaded evidence documents are analyzed asynchronously, and the model produces concise evidence bullets while the human-edited boilerplate remains separate and user-owned.
Storage and identity backends
The system is designed with pluggable infrastructure. Auth can run either through a local JWT flow or Supabase Auth, while storage can use S3/MinIO or Supabase Storage. The API enforces org-level RBAC regardless of auth provider, using membership data in the application database.
Workspace and pipeline workflow
The product’s operational core is the grant-writing workspace and pipeline. Users start from matches or grants, create a reusable workspace for an organization/grant pair, then manage tasks, drafts, budget, attachments, review, submission, and award states. Pipeline stages are action-driven and can be moved by explicit workflow events like eligibility checks, sending to review, approving, submitting, or archiving.
Frontend stateful surfaces
The web app is not just a static viewer; it contains interactive surfaces for dashboard summaries, match triage, pipeline drag/drop, review queues, workspace detail views, rich text editing, and source monitoring. Several components have tests alongside them, suggesting the frontend includes meaningful client-side business logic.
Infrastructure and deployment
Local development uses Docker Compose with separate containers for API, web, worker, scheduler, Postgres, Redis, and MinIO. Production supports both Supabase-backed and AWS ECS/Terraform-backed deployments. The infra folder also includes bootstrap state setup, Dockerfiles for each app, and seed scripts for curated non-government grant data.
Testing and quality boundaries
The repository includes backend E2E and service tests, frontend component tests, and CI workflows. That indicates the key architecture boundaries are enforced at multiple layers: API contracts, matching/extraction logic, ingestion adapters, and UI behavior.
Main entry points: services Services · tasks Worker tasks · v1 API routes · core Core
Components 21
API backend
FastAPI app, domain services, and persistence
- API routes · Versioned domain endpoints for auth, grants, matches, pipeline, review, workspaces, and related resources
apps/api/app/api/v1 - Services · Business logic for ingestion, matching, extraction, summaries, analysis, and audit
apps/api/app/services - Models · Database models for grants, applicants, IRS 990, matching, pipeline, sources, tenancy, and workspaces
apps/api/app/models - Schemas · Request and response shapes shared across API domains
apps/api/app/schemas - Core · Application config, logging, security, dependencies, and DB session wiring
apps/api/app/core - Database · Relational persistence and Alembic-managed schema evolution
apps/api/alembic - Ingestion · Grant-source discovery and adapters for public and non-government data
apps/api/app/services/ingestion - Matching · Grant-to-organization fit and match evaluation
apps/api/app/services/matching.py - Parsing · PDF and HTML parsing plus normalization and extraction rules
apps/api/app/services/parsing - Org analysis · Organization document analysis and evidence bullet generation
apps/api/app/services/organization_model_analysis.py - Grant logic · Grant summaries, grantor verification, and enrichment helpers
apps/api/app/services/grant_summaries.py - Task queue · Dispatch boundary for background and scheduled jobs
apps/api/app/services/task_queue.py
Web frontend
Next.js user workflows and client state
- Web app · User-facing grant, workspace, review, and dashboard screens
apps/web/app - API client · Small client layer used by frontend pages and components
apps/web/lib/api.ts - UI flows · Dashboard, matches, pipeline, review, and workspace components
apps/web/components
Async jobs
Celery tasks and scheduled processing
- Worker app · Background worker and beat scheduler entrypoint
apps/worker/worker_app.py - Worker tasks · Ingestion, matching, applicant, and alert tasks
apps/worker/tasks
Infrastructure
Docker, Terraform, and local bootstrap
- Docker stack · Compose setup and service containers for API, web, worker, Postgres, Redis, and MinIO
infra/docker/docker-compose.yml - Terraform · Production infrastructure and bootstrap state for cloud deployment
infra/aws/terraform
Shared code
Cross-package shared types and UI
- Shared types · Generated and shared type definitions used across packages
packages/shared/src - UI primitives · Reusable shared UI components
packages/ui/src
Connections 27
- Web app → API client: calls · Pages use the frontend API client for backend requests
- UI flows → API client: fetches · Interactive views load and mutate data through the client layer
- Web app → API routes: uses · User workflows are backed by versioned API endpoints
- API routes → Services: delegates · Endpoints hand off business logic to services
- Services → Models: reads/writes · Services coordinate domain state via ORM models
- Services → Schemas: shapes · Services and routes exchange typed contracts
- Core → API routes: wires · Core config and dependencies assemble the API surface
- Core → Database: connects · Database sessions and migrations support persistence
- Ingestion → Models: loads · Ingestion populates grant and source tables
- Matching → Models: scores · Match scoring uses grant, applicant, and workspace data
- Parsing → Services: feeds · Parsed text and normalized evidence flow into service logic
- Org analysis → Parsing: consumes · Org analysis builds on extracted document content
- Grant logic → Services: supports · Grant normalization and verification support API workflows
- Services → Task queue: enqueues · Long-running work is handed to background jobs
- Worker app → Worker tasks: runs · Celery runtime executes task modules
- Worker tasks → Task queue: consumes · Tasks are scheduled and dispatched through the queue boundary
- Worker tasks → Ingestion: executes · Background jobs perform source ingestion and refreshes
- Worker tasks → Matching: executes · Worker processes run matching and scoring jobs
- Worker tasks → Services: invokes · Tasks reuse backend services for applicant and alert workflows
- UI flows → UI primitives: composes · Frontend screens are built from shared UI primitives
- API routes → Shared types: aligns · Backend contracts are mirrored in shared types
- API client → Shared types: types · The frontend client consumes shared API shapes
- Docker stack → Web app: packages · Compose brings up the web runtime
- Docker stack → Core: packages · Compose brings up the API runtime
- Docker stack → Worker app: packages · Compose brings up worker and scheduler services
- Terraform → Core: deploys · Cloud infrastructure targets the API stack
- Terraform → Web app: deploys · Cloud infrastructure targets the frontend stack