Resilient AI merchant operations for productized digital services.
MarginPilot AI evaluates incoming service orders, accepts only margin-safe demand, runs fallback-safe Gemini fulfillment, delivers a buyer-ready Prospect Pack, and leaves a receipt with revenue, cost, model, resilience, and margin visible.
| Item | Detail |
|---|---|
| Live app | https://marginpilot-ai.vercel.app |
| Repository | https://github.com/luzzwaix/marginpilot-ai |
| Canonical service | Pipeline Packs prospect-intelligence Growth Pack |
| AI proof | Gemini Fulfillment Agent with model fallback |
| Commercial proof | ACCEPT / REPRICE / REJECT profitability gate |
| Delivery proof | Prospect Pack preview, CSV export, and receipt JSON |
| Ledger proof | $42.00 + $99.00 - $6.70 = $134.30 |
Most AI service tools generate text and leave business judgment to the operator. MarginPilot focuses on the missing operating layer: before an AI agent manufactures a digital service, it checks whether the order should be accepted at all.
The result is a compact merchant loop:
- capture buyer request
- assess price, spend, and margin floor
- accept, reprice, or reject
- simulate settlement
- run resilient AI fulfillment
- deliver the asset
- issue an audit receipt
- keep the ledger positive
- The operator forms a productized service merchant.
- The Growth Pack SKU is priced at
$99. - MarginPilot estimates automated production spend at
$6.70. - The profit gate accepts the order because projected margin clears the
70%floor. - Simulated settlement credits the merchant ledger.
- Fulfillment runs discovery, signal extraction, qualification, inference, and outreach-angle generation.
- Gemini Fulfillment Agent produces structured shipment rationale.
- Delivery Receipt records buyer request, decision, quality gate, provider/model, resilience status, selected accounts, order value, spend, and ending ledger.
The fulfillment stage makes one live Gemini call per order when configured:
- primary model:
gemini-2.5-flash-lite - fallback model:
gemini-2.5-flash - deterministic local fallback when live AI is unavailable or intentionally disabled
The server route accepts:
- buyer request
- business/service name
- SKU name
- representative lead signals
- order economics context
- resilience test mode
It returns structured JSON:
{
"agent_decision": "SHIP_PACK",
"selected_accounts": [
{
"company": "...",
"why_selected": "...",
"risk": "...",
"outreach_opener": "..."
}
],
"pack_summary": "...",
"quality_gate": "...",
"fit_score_rationale": "...",
"operator_note": "..."
}The client uses this output to enrich the Prospect Pack, selected-account rationale, outreach opener, and Delivery Receipt.
MarginPilot includes a Resilience Lab for the next fulfillment run:
- Simulate primary model failure: skips Flash Lite and verifies the fallback model path.
- Simulate malformed JSON: forces schema recovery and routes to fallback.
- Simulate no API key: uses deterministic local fulfillment.
Statuses shown in the app:
Primary model succeededFallback model usedDeterministic fallback preserved delivery
The deterministic path returns stable SHIP_PACK output so the canonical demo never collapses because of quota, malformed JSON, or missing credentials.
The order gate evaluates:
- quoted price
- estimated production spend
- required gross margin floor
- projected gross margin
- recommended reprice when demand is underpriced
Canonical economics:
| Metric | Value |
|---|---|
| Starting ledger | $42.00 |
| Simulated order value | $99.00 |
| Automated production-layer spend | $6.70 |
| Ending ledger | $134.30 |
| Gross margin | about 93% |
The UI also includes a compact stress-test scenario where an underpriced custom order triggers REPRICE, making clear that the agent does not accept every request.
- Open the app.
- Confirm the first screen is MarginPilot AI, not a Locus-first proof deck.
- Form the merchant.
- Start the Growth Pack order.
- Edit the buyer request if desired.
- Inspect the ACCEPT / REPRICE / REJECT profit gate.
- Complete simulated settlement.
- Watch fulfillment complete.
- Verify Gemini Fulfillment Agent and resilience status.
- Review the Prospect Pack and Delivery Receipt.
- Confirm ending ledger remains
$134.30.
- Next.js App Router
- TypeScript
- React
- Tailwind CSS
- Three.js operating-loop visual
- Server route for Gemini Fulfillment Agent
- Local persistent demo state
- Adapter-shaped simulated settlement and ledger clients
Key files:
| File | Purpose |
|---|---|
src/components/promptcart-app.tsx |
Main operating UI and canonical flow |
src/components/merchant-loop-scene.tsx |
Three.js merchant operating loop |
src/app/api/locus/synthesize/route.ts |
Gemini Fulfillment Agent route |
src/lib/business-engine.ts |
SKU, profitability, fulfillment, ledger, and deliverable logic |
src/lib/locus-adapters.ts |
Simulated settlement and ledger adapters |
src/lib/types.ts |
Domain types |
- The deployed Next.js app.
- The server-side Gemini Fulfillment Agent when
GEMINI_API_KEYandENABLE_LIVE_GEMINI_SYNTHESIS=trueare configured. - The fallback-chain behavior and deterministic continuity path.
- The full browser-based canonical Growth Pack flow.
- Checkout/settlement callback.
- Merchant ledger settlement.
- Customer payment.
- Revenue collection.
These are simulated intentionally so the project can demonstrate commercial operating logic without claiming live payment processing.
MarginPilot AI does not claim:
- real payment processing
- real customer revenue
- live bank/wallet settlement
- production financial compliance
- fully autonomous operation with no human review ever needed
This is an operating-loop prototype designed to prove AI/ML resilience, profitability logic, and deliverable quality.
This project began as a Locus Week 4 experiment around an agent-operated storefront. The current submission reframes the useful core as a standalone DevNetwork AI + ML Hackathon project: resilient AI merchant operations for productized digital services.
npm install
npm run devLive Gemini fulfillment requires:
GEMINI_API_KEY=...
ENABLE_LIVE_GEMINI_SYNTHESIS=trueVerification:
npm run lint
npm run build