Skip to main content

Documentation Index

Fetch the complete documentation index at: https://grantmaster.dev/llms.txt

Use this file to discover all available pages before exploring further.

Engineering reference: For service contracts, EventBus events, and data-layer details see src/features/grants/grants.md.

Grants

Overview

The Grants feature provides comprehensive grant management across four interconnected modules: Discovery (finding opportunities), Pipeline (tracking applications), Application (managing proposals), and Post-Award (managing active grants). It enables organizations to discover funding, evaluate eligibility, submit proposals with AI-assisted writing, track applications through a Kanban pipeline, and manage compliance, disbursements, and reporting for awarded grants. This feature is the grant lifecycle hub, connecting funders (via Grantors), projects (via GrantAward links), and financial tracking (via expenses and budget allocations).

Data Model

Firestore Collections

CollectionDocument TypeDescription
grantOpportunitiesGrantOpportunityDiscoverable grant opportunities from external sources or manual entries; contains eligibility, funding, deadlines, and AI-enhanced match scoring.
grantPipelineGrantPipelineEntryOpportunities tracked through application stages (prospect → won/lost); includes probability, weighted value, team assignments, tasks, documents, and activity.
grantApplicationsGrantApplicationFormal grant applications linked to pipeline entries; contains proposal sections, budget, compliance checks, and submission metadata.
activeGrantsActiveGrantPost-award active grants with award details, disbursement schedule, reporting obligations, and impact goals; represents a won grant under execution.
Supporting Collections (one-to-many to pipeline entries):
  • pipelineTasks — Task items within a grant workspace
  • pipelineDocuments — Documents uploaded to a grant workspace
  • pipelineActivities — Activity log entries (comments, status changes, uploads)

Key TypeScript Types

GrantOpportunity
  • Core fields: title, description, grantorId, source (EU Portal, fundsforNGOs, etc.)
  • Funding: fundingRange (min/max, currency)
  • Eligibility: geographicScope, sectors, organizationTypes
  • Deadlines: openDate, closeDate, rollingDeadline
  • AI: matchScore (0–100 per org), sdgAlignment (UN goals), extractedRequirements, tags
  • Status: active|closed|upcoming|archived
GrantPipelineEntry
  • State: stage (prospect, preparation, submitted, won, lost, dead), probability (0–100)
  • Financial: requestedAmount, weightedValue (amount × probability/100)
  • Dates: targetSubmissionDate, actualSubmissionDate, decisionDate, expectedDecisionDate
  • Team: assignedTo (user IDs), leadContact
  • Workspace metadata: tasksCount, documentsCount, commentsCount, lastActivityAt
  • History: stageHistory array tracking stage transitions with timestamps and reasons
  • Notes: notes, rejectionReason
GrantApplication
  • Links: pipelineId, opportunityId (empty if not discovery-linked)
  • Content: proposal (array of ProposalSection with word counts), budget (line items + total)
  • Compliance: complianceChecks (status + findings array)
  • Submission: submittedAt, submittedBy, confirmationNumber
ActiveGrant
  • Award details: awardedAmount, startDate, endDate, grantNumber, awardDate
  • Budget tracking: approvedBudget (line items), totalSpent, budgetUtilization (percentage)
  • Disbursements: disbursementSchedule (tranches with expected/actual dates and status)
  • Reporting: reports (type + dueDate + status) per reporting rule
  • Links: projectId|projectIds (one or many per award), allowsProjectSplit flag
  • Status: active|completed|terminated|suspended
PipelineTask, PipelineDocument, PipelineActivity
  • Tasks: pipelineId, title, assignedTo, dueDate, status (todo, in_progress, completed), priority (low, medium, high)
  • Documents: pipelineId, name, type (proposal, budget, supporting, contract, report), storageUrl (Firebase path), versioning
  • Activities: pipelineId, type (comment, status_change, document_upload, task_update, assignment), userId, userName, content, metadata

Key Behaviors

Grant Discovery

Module: src/features/grants/discovery/ Route: /grant-discovery/:tab — Tabs: Search (default), Recommendations, Deadlines View Modes: Grid, List, Table (with virtual scrolling via @tanstack/react-virtual)
  • Grant Opportunity Search: Fetch opportunities from external sources or browse manual entries, with advanced filtering via GrantFiltersPanel (funding range, eligibility, sector, deadline, AI match score).
  • Eligibility Evaluation: Assess organization eligibility against geographic scope, organization type, and sectoral criteria; flag ineligible opportunities.
  • AI-Enhanced Matching: Calculate match score (0–100) and SDG alignment for each opportunity relative to organization’s mission and sectors. Recommendations tab highlights high-match opportunities.
  • Deadline Calendar: Deadlines tab shows upcoming close dates with severity visualization.
  • Manual Entry: Create custom opportunities for known funders or tracking external grants not in automated sources.
  • Source Display: Color-coded source badges (RVO, EU Portal, DUS-I, ZonMw, Overheid.nl, Rijksoverheid, Manual).

Pipeline Management (Grant Tracker)

Module: src/features/grants/tracker/ Route: /grant-tracker/:tab — Tabs: Pipeline (default), Deadlines, Analytics, Archive
  • Pipeline (Kanban): Drag-and-drop board for transitioning opportunities through stages (prospect → preparation → submitted → won/lost/dead). Filter by stage, probability, and conversion status.
  • Probability & Weighted Value: Assign probability per stage (prospect: 10%, preparation: 25%, submitted: 40%, won: 100%); calculate weighted value for revenue forecasting.
  • Deadlines Tab: Deadline-based severity visualization (overdue, within 7 days, within 30 days) across all pipeline entries.
  • Analytics Tab: Conversion rates, average deal size, time-to-decision metrics, and stage stats with count and weighted value.
  • Archive Tab: Won, lost, and dead grants for historical review.
  • Stage History: Track all stage transitions with timestamp, user, and optional reason; support reversals and case history.
  • Workspace Artifacts: Organize tasks, documents, and comments per pipeline entry; auto-count and surface via metadata.

Grant Application & Proposal Writing

Module: src/features/grants/application/ Route: /grant-application/:tab — Tabs: Active (default), Pipeline, Archive The page organizes applications across three lifecycle tabs. Within each application, the editing workflow provides Proposal Editor, Budget Builder, and Compliance Check capabilities.
  • Active Tab: Current in-progress applications with editing and submission capabilities.
  • Pipeline Tab: Kanban-style view of applications in different stages.
  • Archive Tab: Completed, submitted, and archived applications.
  • Proposal Editor: Create and edit multi-section proposals with word-count tracking and section-level requirements (max words, mandatory).
  • AI-Assisted Writing: Leverage Genkit + Gemini to generate proposal sections, refine language, and assess quality; ProposalAIService provides context-aware suggestions.
  • Budget Builder: Construct line-item budgets (personnel, equipment, travel, etc.) with quantity/unit-cost calculations; link to grant’s requested amount.
  • Compliance Check: Automated assessment against eligibility criteria, sectoral restrictions, and organizational constraints; flag warnings and failures with dynamic compliance percentage badges.
  • Application State: Save drafts, resubmit, and track submission metadata (confirmation number, timestamp).

Post-Award Grant Management (Grant Control)

Module: src/features/grants/post-award/ Route: /grant-control/:tab — Tabs: Overview (default), Financials, Milestones, Reports, Contacts The page features a grant selection sidebar on the left for switching between active grants, with tab content on the right. Uses OperatingKpiStrip and OperatingInsightStrip for contextual KPIs and alerts.
  • Overview Tab: Award summary, KPIs (awarded amount, budget utilization, disbursements, reporting status), and operational insights.
  • Financials Tab: Budget progress visualization with color-coded budget lines, disbursement schedule with expected/actual tracking.
  • Milestones Tab: Project milestones and deliverables linked to the grant.
  • Reports Tab: Reporting obligations tracking (financial, narrative, impact, interim, final) per funder rules.
  • Contacts Tab: Grantor contacts and portal token management for stakeholder visibility.
  • Award Registration: Convert a won pipeline entry to an ActiveGrant, capturing award amount, start/end dates, disbursement schedule, and reporting rules.
  • Project Linking: Link award to one project (default) or multiple projects (if split allowed); seed project timelines with reporting deadlines.
  • Grant Lifecycle Status: Track as active, completed, terminated, or suspended; auto-mark at-risk if budget utilization exceeds 90%.

Service Contract

ServiceOwnsKey Methods
GrantServiceAll CRUD operations, validation, event emission, audit logginggetOpportunities(), addToPipeline(), createOpportunity(), getPipeline(), updatePipelineStage(), updatePipelineEntry(), removePipelineEntry(), getTasks/addTask/updateTask/removeTask(), getDocuments/addDocument/removeDocument(), getActivities/addActivity(), getApplications(), saveApplication(), submitApplication(), getActiveGrants(), convertToActiveGrant(), updateActiveGrant()
useGrantsList (Query Hook)Aggregated query of all four collections per organization, powered by React QueryuseGrantsList() returns { opportunities, pipeline, applications, activeGrants } with individual loading states
useGrantMutations (Mutation Hook)Mutation wrappers for all write operations with optimistic updates and error handlingupdatePipelineStage(), updatePipelineEntry(), saveApplication(), submitApplication(), convertToActiveGrant(), updateActiveGrant(), etc.

Events

Emitted

EventTriggerSeverityPersisted
GRANT_ADDED_TO_PIPELINEaddToPipeline() — opportunity added to pipelineINFOYes
GRANT_PIPELINE_STAGE_CHANGEDupdatePipelineStage() — entry transitioned between stagesINFOYes
GRANT_APPLICATION_SUBMITTEDsubmitApplication() — application formally submittedINFOYes
GRANT_WONconvertToActiveGrant() — pipeline entry awarded and convertedINFOYes
Payload Examples:
  • GRANT_ADDED_TO_PIPELINE: pipelineId, opportunityId, grantTitle, grantorName, requestedAmount, currency, addedBy, addedAt
  • GRANT_WON: grantId, pipelineId, opportunityId, grantTitle, grantorName, awardedAmount, currency, startDate, endDate
All events are emitted via emitCanonicalSystemEvent() with non-critical execution (errors logged but do not fail the operation) to ensure notifications flow without blocking core workflows.

Consumed

The Grants feature does not consume system events; it is a producer of workflow events that other features (e.g., Projects, Notifications, Auditor) can subscribe to for downstream actions.

Dependencies

  • Depends on:
    • Grantors — Uses grantor/funder entities (stored as Contacts)
    • Projects — Links active grants to projects via projectId (one-to-one or one-to-many split mode)
    • Expenses — Reads expenses to calculate grant spending and budget utilization
    • AI — Uses Genkit (ProposalAIService) for proposal writing assistance
    • Documents — Stores proposal, budget, and supporting documents in Firebase Storage
  • Depended on by:
    • Projects — Consumes award details (budget, deadlines) when a GrantAward links to a project
    • Auditor — Subscribes to grant events for compliance tracking and audit logging
    • Reports — Includes grant KPIs and post-award financials in organization-wide reports
    • Notifications — Consumes grant events to notify stakeholders of submissions and awards

File Structure

src/features/grants/
├── README.md                        # This file
├── GrantContext.tsx                 # Legacy compatibility layer; delegates to query hooks
├── index.ts                         # Public API barrel export
├── services/
│   ├── GrantService.ts              # Core business logic (CRUD, validation, events)
│   ├── grantDataAccess.ts           # Firestore DAL (fetch/create/update/delete)
│   └── rvoTransform.ts              # RVO (Requested vs Offered) amount logic
├── hooks/
│   ├── useGrants.ts                 # Query + mutation hooks (React Query powered)
│   └── useGrantOperatingSnapshot.ts # Real-time grant operating metrics
├── discovery/
│   └── components/
│       ├── GrantDiscoveryPage.tsx   # Search, filter, match score display
│       └── GrantFiltersPanel.tsx    # Advanced filter UI
├── tracker/
│   ├── hooks/
│   │   ├── useGrantTracker.ts       # Pipeline state, filtering, stage transitions
│   │   ├── useGrantMetrics.ts       # Total/weighted value, win rate calculations
│   │   └── useGrantDragDrop.ts      # Drag-drop stage transitions
│   └── components/
│       ├── GrantTrackingPage.tsx    # Kanban board container
│       ├── GrantKanbanBoard.tsx     # Kanban implementation
│       └── GrantCard.tsx            # Pipeline entry card
├── application/
│   ├── services/
│   │   ├── ProposalAIService.ts     # AI writing assistance
│   │   ├── proposalDraftService.ts  # Draft persistence
│   │   └── proposalContextService.ts # Context aggregation for AI
│   ├── hooks/
│   │   ├── useProposalState.ts      # Proposal section CRUD
│   │   ├── useComplianceMetrics.ts  # Compliance check evaluation
│   │   └── useBudgetCalculations.ts # Budget calculations
│   └── components/
│       ├── GrantApplicationPage.tsx # Application editor container
│       ├── ProposalEditor.tsx       # Proposal section editor
│       ├── BudgetBuilder.tsx        # Budget editor
│       └── ComplianceCheck.tsx      # Compliance status display
└── post-award/
    ├── hooks/
    │   ├── usePostAwardData.ts      # Active grant query + mappers
    │   ├── usePostAwardMetrics.ts   # Budget utilization, disbursement stats
    │   └── usePostAwardSelection.ts # Grant selection state
    └── components/
        ├── PostAwardPage.tsx        # Active grants dashboard
        ├── PostAwardGrantList.tsx   # Grant list with inline editing
        └── PostAwardSummaryGrid.tsx # Metrics cards (spending, compliance, reports)

Last Updated: April 2026 Architecture: Modular; four sub-modules (Discovery, Tracker, Application, Post-Award) organized by concern with shared GrantService and hooks. Each module has URL-driven tabs with automatic legacy redirect mapping.