MerchantPilot AI is a production-looking full-stack hackathon project for Qwen Cloud Global AI Hackathon — Track 4: Autopilot Agent.
It simulates an autonomous merchant operations workflow for fintech teams: merchant onboarding, document intake, AI-assisted document review, risk assessment, compliance recommendation, human approval, and audit logging.
The project is intentionally built as a realistic scaffold: clean API boundaries, database models, storage adapter pattern, agent service abstraction, seed data, and a polished frontend dashboard.
Track 4: Autopilot Agent
MerchantPilot AI demonstrates an agentic system where multiple specialized agents collaborate to complete merchant onboarding operations:
- Intake Agent — validates submitted merchant data and document completeness.
- Verification Agent — reviews document availability and simulated identity/business checks.
- Risk Agent — generates merchant risk score, reasons, confidence, and recommendation.
- Compliance Agent — maps risk findings to compliance actions and review requirements.
- Memory Agent — stores reusable operational context and previous review signals.
The current implementation requires QWEN_API_KEY for AI reviews and calls Qwen through DashScope's OpenAI-compatible chat completions API.
- Create merchant applications
- Upload merchant documents
- Store files through a storage adapter
- Local filesystem storage during development
- Alibaba OSS placeholder storage service for future deployment
- Run autonomous AI agent review
- Generate agent timeline events
- Persist risk assessments
- Persist compliance reviews
- Persist memory records
- Human approval actions:
- Approve merchant
- Reject merchant
- Request more information
- Audit logging for major system events
- Dashboard metrics API
- Seed data with realistic demo merchants
- Alembic-ready PostgreSQL setup
- Modern fintech compliance dashboard
- Merchant application form
- Merchant detail/review page with tabs:
- Overview
- Documents
- Agent Analysis
- Risk
- Compliance
- History
- Audit Trail
- Human review center
- Agent investigation timeline
- Polished neutral UI with dark/light-friendly styling
- TanStack Query-powered API state
merchantpilot-ai/
├── backend/
│ ├── alembic/
│ ├── app/
│ │ ├── api/
│ │ │ └── routes/
│ │ ├── core/
│ │ ├── db/
│ │ ├── models/
│ │ ├── schemas/
│ │ └── services/
│ │ ├── agents/
│ │ ├── cac/
│ │ ├── documents/
│ │ └── storage/
│ ├── requirements.txt
│ ├── seed.py
│ └── alembic.ini
├── frontend/
│ ├── app/
│ ├── components/
│ ├── lib/
│ ├── package.json
│ └── tailwind.config.ts
├── docker-compose.yml
├── .env.example
└── README.md
- Next.js 15
- TypeScript
- Tailwind CSS
- shadcn/ui-style components
- TanStack Query
- FastAPI
- Python
- Pydantic
- SQLAlchemy
- Alembic
- PostgreSQL
- Local filesystem storage for development
- Storage adapter abstraction
- Alibaba OSS placeholder service for future implementation
- Qwen agent service abstraction
- Qwen OpenAI-compatible chat completion integration when
QWEN_API_KEYis configured - Mock CAC verification provider for hackathon/demo mode
- Agent timeline persistence
git clone <your-repo-url>
cd merchantpilot-ai
cp .env.example .envdocker compose up -dPostgreSQL will run on port 5432.
cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtRun migrations:
alembic upgrade headSeed demo data:
python seed.pyStart API server:
uvicorn app.main:app --reload --port 8000API docs:
http://localhost:8000/docs
Open a second terminal:
cd frontend
npm install
npm run devFrontend:
http://localhost:3000
Use a single .env file in the project root. See .env.example.
DATABASE_URL=postgresql+psycopg2://merchantpilot:merchantpilot@localhost:5432/merchantpilot
APP_ENV=development
API_CORS_ORIGINS=http://localhost:3000
STORAGE_TYPE=local
LOCAL_UPLOAD_ROOT=uploads
QWEN_API_KEY=
QWEN_MODEL=qwen-plus
QWEN_BASE_URL=https://dashscope-intl.aliyuncs.com/compatible-mode/v1
QWEN_TIMEOUT_SECONDS=30
QWEN_MAX_RETRIES=2
CAC_PROVIDER=mock
CAC_API_KEY=
CAC_API_BASE_URL=
NEXT_PUBLIC_API_URL=http://localhost:8000/apiBase URL:
http://localhost:8000/api
| Method | Route | Description |
|---|---|---|
POST |
/merchants |
Create merchant application |
POST |
/merchants/{merchant_id}/documents |
Upload merchant document |
GET |
/merchants |
Get all merchants |
GET |
/merchants/{merchant_id} |
Get merchant details |
POST |
/merchants/{merchant_id}/run-review |
Run AI agent review |
GET |
/merchants/{merchant_id}/agent-timeline |
Get agent timeline |
POST |
/merchants/{merchant_id}/approve |
Approve merchant |
POST |
/merchants/{merchant_id}/reject |
Reject merchant |
POST |
/merchants/{merchant_id}/request-info |
Request more information |
GET |
/audit-logs |
View audit logs |
GET |
/dashboard/metrics |
View dashboard metrics |
Create database using Docker Compose:
docker compose up -dRun Alembic migrations:
cd backend
alembic upgrade headSeed realistic fake merchants:
python seed.pySeeded statuses include:
- Pending
- Approved
- Flagged
- Needs information
- Rejected
Local files are stored using this structure:
uploads/merchants/{merchant_id}/{document_type}/{filename}
Storage logic is not hardcoded inside routes. Routes call the storage abstraction:
app/services/storage/base.py
app/services/storage/local.py
app/services/storage/oss.py
app/services/storage/factory.py
Set storage backend using:
STORAGE_TYPE=localor:
STORAGE_TYPE=ossoss currently uses a placeholder AlibabaOSSStorageService with TODO comments showing where Alibaba OSS SDK logic should be added.
MerchantPilot AI includes a demo-safe CAC verification mode for hackathon usage.
- The app does not call paid CAC APIs in demo mode.
CAC_PROVIDER=mockenables the local mock CAC verification adapter.- Uploaded CAC PDFs are parsed locally with
pypdf. - The verifier extracts readable PDF text, RC/BN numbers, and labeled business names when available.
- The submitted business name is compared against extracted text using
rapidfuzz. - The system generates a confidence score, risk flags, recommendation, audit log entry, memory record, and Verification Agent timeline events.
- Official CAC registry verification is not performed in demo mode; it is abstracted behind
CACVerificationServicefor future provider integration.
CAC files should be uploaded with:
document_type=cac
For backward compatibility, existing cac_document uploads are also accepted.
Alibaba OSS is not implemented yet by design. The project includes a clean placeholder service:
backend/app/services/storage/oss.py
To implement OSS later:
- Install Alibaba Cloud OSS SDK.
- Add OSS environment variables:
ALIBABA_OSS_ENDPOINTALIBABA_OSS_BUCKETALIBABA_ACCESS_KEY_IDALIBABA_ACCESS_KEY_SECRET
- Implement
save()inAlibabaOSSStorageService. - Keep API routes unchanged because they depend only on
StorageService.
The Qwen integration is intentionally abstracted behind:
backend/app/services/agents/qwen_service.py
Current behavior:
- If
QWEN_API_KEYis missing, the backend returns a clear503error and the frontend displays the configuration problem. - If
QWEN_API_KEYis present, the backend calls the configured Qwen OpenAI-compatible chat completions endpoint. - Qwen output is requested as strict JSON and validated with Pydantic before persistence.
- The service includes timeout and retry handling through
QWEN_TIMEOUT_SECONDSandQWEN_MAX_RETRIES.
The default QWEN_BASE_URL is:
https://dashscope-intl.aliyuncs.com/compatible-mode/v1
- Open dashboard.
- Review metrics and recent merchant applications.
- Create a new merchant application.
- Upload CAC and means of identification documents.
- Open merchant detail page.
- Click Run AI Review.
- Watch the agent timeline populate:
- Intake Agent started
- CAC parsed
- Verification completed
- Risk score generated
- Compliance recommendation ready
- Waiting for human review
- Go to Human Review Center.
- Review AI recommendation, risk score, confidence, and supporting reasons.
- Approve, reject, or request more information.
- Check audit logs.
MerchantPilot AI is strong for a demo because it solves a real fintech operations problem:
- Merchant onboarding is repetitive.
- Compliance review is document-heavy.
- Risk teams need explainable recommendations.
- Human reviewers need audit trails.
- Regulators require traceability.
The project does not pretend AI fully replaces compliance teams. The stronger story is AI autopilot with human approval and auditability.
# Start DB
docker compose up -d
# Backend
cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
alembic upgrade head
python seed.py
uvicorn app.main:app --reload --port 8000
# Frontend
cd frontend
npm install
npm run devMIT