Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ForeChain

Self-hosted supplier intelligence — AI research, continuous monitoring, evidence-backed risk signals.

ForeChain helps procurement, supply-chain, and resilience teams onboard critical suppliers, monitor them continuously with background AI research, detect meaningful risk changes, and review evidence-backed results through a durable product workflow.


ForeChain dashboard overview showing supplier risk register, intelligence feed, and portfolio risk breakdown


What Is ForeChain?

Most teams don't struggle because they have zero supplier data — they struggle because their supplier-risk workflow is fragmented across spreadsheets, inbox alerts, and one-off reviews. ForeChain turns that into a structured operating loop:

  1. Onboard suppliers with structured intake (country, what you procure, dependency, criticality, locations, monitoring interests)
  2. Bootstrap each supplier with a baseline profile, monitoring plan, and memory seed
  3. Monitor continuously in the background — daily or weekly, evidence-grounded
  4. Surface signals as structured risk events backed by cited sources
  5. Review through a dashboard of portfolio risk, signals, and reports

Core objects

Object Description
Supplier The supplier being monitored, with structured intake
Harness Job A durable background task (bootstrap, monitor, research, digest)
Signal An individual evidence-backed risk event
Risk Snapshot The current risk assessment for a supplier run
Report / Artifact The persisted evidence-cited output of a completed run
Memory Snapshot Durable supplier memory carried across runs

Features

  • Zero-external-account quickstart — SQLite by default; no auth provider, no billing provider, no object storage required
  • Single-workspace, no-auth deployment — everyone who opens the app uses the same local workspace
  • Durable async jobs — research and monitoring run in the background, survived by a database-backed queue with recovery
  • Six risk dimensions — supplier disruption, logistics & trade, geopolitical & regulatory, compliance & ESG, financial distress, climate & physical
  • Evidence-grounded output — every signal must cite fetched sources; high-severity signals require independent corroboration
  • Persistent supplier memory — profiles, lifecycle state, and reports survive across runs
  • Replayable task packets — every run's inputs, reasoning trace, evidence, and outputs are preserved on disk
  • Interactive setup wizard — uv run forechain-setup configures everything

Repository Layout

├── backend/     # FastAPI + SQLAlchemy product API, durable job orchestration, persistence
├── harness/     # AI agent runtime: supervisor, workers, tools, evidence, validation
├── frontend/    # React 19 + Vite dashboard
├── scripts/     # setup wizard + maintenance commands
├── tests/       # backend and harness verification (uses test-only fakes)
├── docs/        # product, architecture, and interface documentation
├── pyproject.toml
└── LICENSE.md   # MIT

Quickstart

Prerequisites:

  • Python 3.11+ and uv
  • Node.js 18+ and npm

1. Install dependencies

uv sync --extra dev
cd frontend && npm install && cd ..

2. Run the interactive setup wizard

uv run forechain-setup

The wizard walks you through:

  • Database location — SQLite by default, no external database required
  • Backend / frontend URLs
  • An internal harness token — generated for you automatically
  • Optional AI provider keys — LLM, Brave search, Firecrawl (all optional; the wizard explains each)

It writes the .env files and initializes the database for you.

3. Start the backend

uv run uvicorn backend.app.main:app --reload --port 8001

4. Start the frontend

cd frontend && npm run dev

Open http://localhost:3000/dashboard and you're in. On first visit you'll be guided through workspace onboarding.


How To Use It

1. Complete workspace onboarding

On your first visit you're asked for your company name, profile, supply-base size, and risk focuses. This context shapes how the harness interprets supplier materiality. Saving it triggers a background company_research job that resolves and seeds your buyer-company profile.

2. Add a supplier

Create a supplier with structured intake:

  • name, country, supplier type
  • what you procure, dependency level, criticality
  • key locations, shipping lanes / ports
  • known upstream suppliers
  • monitoring interests and cadence (daily / weekly)

Creating a supplier triggers an automatic bootstrap job in the background, and once bootstrap completes, an initial monitor run is queued automatically.

3. Review monitoring results

The dashboard shows:

  • Overview — portfolio risk: active suppliers, elevated risk, critical alerts, watchlist
  • Global Risk — macro supply-chain intelligence from the scheduled global digest
  • Suppliers — list with current risk score, trend, and top factor
  • Supplier Detail — profile, latest run, evidence-backed signals, recommendations, risk dimensions, and the full report
  • Signals — the portfolio signal feed with filters and LLM-powered summarization
  • Reports — the persisted evidence-cited monitoring reports

4. Monitor continuously

Once a supplier is ready, the harness schedules daily or weekly monitor runs automatically. You can also trigger a manual run from the API (POST /api/suppliers/{id}/runs). Each run gathers fresh evidence, assesses risk, updates memory, and writes a new report.


Configuring AI Providers

The harness runs research and monitoring through three optional providers. Without them the product runs, but research/monitoring jobs are gated on a configured provider. Add keys to .env (or re-run uv run forechain-setup) and restart the backend.

Purpose Environment variable Required for
LLM provider (openai, gemini, openrouter) HARNESS_LLM_PROVIDER all research/synthesis
LLM model HARNESS_LLM_MODEL all research/synthesis
OpenAI / OpenRouter key HARNESS_OPENAI_API_KEY LLM calls
Gemini key HARNESS_GEMINI_API_KEY LLM calls
Synthesis output tokens HARNESS_SYNTHESIS_MAX_OUTPUT_TOKENS report/memory JSON size (default 4096)
Brave web/news search HARNESS_BRAVE_SEARCH_API_KEY source discovery
Firecrawl page scraping HARNESS_FIRECRAWL_API_KEY page extraction (HTTP fallback exists)

Configuration Reference

All backend settings are read from the environment with a BACKEND_ prefix (plus HARNESS_* for the harness package). See backend/.env.example for the full annotated list. Key options:

Variable Default Description
BACKEND_DATABASE_URL sqlite+aiosqlite:///./data/product.db Database (SQLite by default)
BACKEND_FRONTEND_URL http://localhost:3000 CORS origin for the dashboard
BACKEND_API_BASE_URL http://localhost:8001 API base URL written into the frontend env
BACKEND_MONITOR_INTERNAL_TOKEN (empty) Shared secret for internal harness endpoints — set via setup wizard
BACKEND_LOCAL_STORAGE_ROOT data/uploads Local directory for uploaded artifacts
HARNESS_* — LLM/search/crawl providers, budgets, concurrency, schedules

Frontend: copy frontend/.env.example to frontend/.env.local and set VITE_PRODUCT_API_BASE_URL (default http://localhost:8001/api). The setup wizard writes this for you.


Common Commands

uv sync --extra dev                # install Python deps (+ dev/test extras)
uv run forechain-setup             # interactive setup wizard
uv run pytest -q                   # run the test suite
uv run alembic upgrade head        # apply DB migrations (optional; setup inits schema)
cd frontend && npm run dev         # run the dashboard
cd frontend && npm run lint        # TypeScript typecheck
cd frontend && npm run build       # production build of the dashboard

Release gates (require real provider credentials):

uv run harness-production-check --live
uv run harness-benchmark --output benchmark-report.json

Architecture

At a high level:

Frontend (React)  →  Product Backend (FastAPI)  →  Durable Harness Job
                                                          │
                                                          ▼
                                                  Agent Runtime
                                                          │
                                          Evidence + Validated Result
                                                          │
                                                          ▼
                                                   Product Database
  1. frontend collects onboarding and supplier data
  2. backend validates the request, stores records, and creates durable jobs
  3. the harness runs the job using task-specific lead agents and shared specialist workers
  4. results are validated and written back into the product database
  5. frontend reads status, signals, reports, and supplier detail through APIs

The harness is a model-driven supervisor with a deterministic shell: models plan, delegate, critique, and synthesize; code enforces budgets, worker whitelists, ordering invariants, security boundaries, and machine-checkable evidence rules.

Read more:


Development

Project structure

  • backend/ — FastAPI + SQLAlchemy (async), durable job orchestration, persistence. Key modules: harness/ (job manager, task builders), suppliers/, dashboard/, monitor_sync/ (result ingestion).
  • harness/ — the agent runtime. orchestrator.py (supervisor), workers.py (specialists), agent.py (model + bounded research loop), tools/ (providers, evidence, validation), skill_library/ (per-worker scoped skills), persistence.py (replayable packets), telemetry.py (budgets + cost).
  • frontend/ — React 19 + Vite + Tailwind dashboard, single-workspace no-auth.

Running the tests

Tests use explicit test-only fakes for model/search/fetch providers — no network or credentials required. Production has no stub or synthetic fallback.

uv run pytest -q

Contributing

  • Open issues and pull requests on the repository.
  • Keep the no-synthetic-fallback principle: deterministic code is reserved for security, budgets, schema validation, and evidence rules — never for generating supplier intelligence.
  • When adding a provider or worker, add coverage under tests/ using the existing fakes.

License

ForeChain is released under the MIT License. See LICENSE.md for the full license text.

About

AI agents for Supply Chain Risk Monitoring

Resources

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages