SeedTrust Docs
SeedTrust handles case management, payment workflows, ACH disbursements, document signing, and communication between Intended Parents, Surrogates, Case Managers, and Agencies.
The Platform
Three services run in production today, but the strategic target is one application:
| Service | Purpose | Status |
|---|---|---|
| seedtrust_flask | Primary Flask application — admin UI, NACHA batches, reports, case management, and the destination for consolidated product work | Strategic home |
| seedtrustapi | FastAPI backend — mobile API and Huntington payments | Maintain while backfilling into Flask |
| app | Mobile PWA (Next.js) — interface for IPs, Surrogates, CMs, and Agencies | Maintain only as needed during Flask consolidation |
| new-st | Go/SvelteKit shell/experiment around admin flows | Not the strategic target |
Both Python backends share a single MySQL database today. New product work should move SeedTrust toward seedtrust_flask as the only application. The architectural goal is simplicity: fewer codebases, fewer auth systems, and a simpler Flask-centered stack using server-rendered pages, Alpine/HTMX interactions, and JSON APIs that feed partials where dynamic data is needed. See ADR 003.
Where to Start
New to the codebase? Follow the Recommended Reading Order below.
Looking for something specific?
| I want to… | Go here |
|---|---|
| Understand the domain language | Business Glossary |
| Set up my dev environment | Getting Started |
| Understand user roles and permissions | User Roles · Auth & Permissions |
| Add a new API endpoint | Migration Guide |
| Understand how payments work | Disbursement Requests · ACH & Banking |
| Generate an ACH batch | ACH Batch Generation Runbook |
| Add a new admin permission | Adding Permissions Runbook |
| Understand why something was built this way | Architecture Decisions |
Recommended Reading Order
These docs are written to be read in sequence. Each one builds on the one before it.
Foundation (start here)
- Business Glossary — The domain vocabulary. Learn what “DR”, “SPC”, “IP”, “GSA”, and “escrow agreement” mean before reading anything else.
- User Roles — The six user types and the 122-permission admin RBAC system.
- Getting Started — Run the full stack locally with one command.
- Architecture Review — The system map. Shows how all three services connect and what each owns.
Core Business Logic
- Authentication & Permissions — Three auth systems (Flask session, FastAPI JWT, NextAuth). Required context before touching any route.
- Case Lifecycle — The central business object. Cases are the glue between all parties, all payments, and all documents.
- Disbursement Requests — The most complex workflow. Payment requests with a 7-step state machine, multi-party approval, and auto-approval rules.
- Ledger & Transactions — How money is recorded. Append-only ledger, running account balance, transaction types and statuses.
- ACH & Banking — How money moves out. Two parallel payment paths: NACHA/M&T (non-CA) and Huntington API (CA/TX).
- Scheduled Payments — Contract-based payment calendar (SPC). How recurring payments are generated, modified, and paid.
Supporting Systems
- Document Management — S3 file storage, signed URLs, escrow agreement signing, access control.
- Messaging & Notifications — In-platform inbox, push, email (SendGrid), and SMS (Twilio).
- Background Jobs — Flask cron jobs and the Huey worker. What runs without a user and what breaks if they stop.
- Reporting — Flask report endpoints, async report generation, PostHog analytics.
Frontend
- Next.js App Overview — Route structure, component organization, global state, PWA config.
- API Integration — When to use
fetchWrappervsaxiosClient, React Query patterns, S3 direct upload flow.
Context & Decisions
- Migration Guide — Which service to build in, decision tree for Flask consolidation, step-by-step migration pattern.
- ADR 001: FastAPI Alongside Flask — Why a second backend was built instead of extending Flask.
- ADR 002: Huntington for CA/TX — Why California and Texas cases use a different payment path.
- ADR 003: Consolidate on Flask — Why the plan changed from the Go/SvelteKit rewrite to one simpler Flask application.
Runbooks (reference as needed)
- ACH Batch Generation — Step-by-step: approve ACH forms, generate a batch, deliver to M&T or Huntington, handle failures.
- Adding a Permission — Step-by-step: add to the
Permissionclass, sync the DB, assign to roles, protect a route.
Key Concepts at a Glance
| Term | Meaning |
|---|---|
Case (ip_case) | A surrogacy or egg donation journey, linking IP, surrogate, and agency |
| DR | Disbursement Request — a payment request requiring multi-party approval |
| SPC | Scheduled Payment Calendar — contract-defined recurring payments |
| GSA | Gestational Surrogacy Agreement — the signed legal contract |
| Escrow Agreement | Financial management contract, signed in-app before payments begin |
| NACHA | File-based ACH format used for M&T Bank (non-CA/TX cases) |
| Huntington | Direct API payment integration for CA and TX IPs |
| Huey | FastAPI background task queue (Redis in production, SQLite locally) |
See the full Business Glossary for all terms.