---
# Agent Marketplace Backend – Project Report
## 🎯 Goal
The objective was to design, build, test, and deploy a **full backend for an AI Agents Marketplace**.
Key goals included:
* Support for agent catalog, licensing, installation, configuration, permissions, connectors.
* Invocation flows (sync/async), runs, schedules, policy management, analytics, billing, MCP integration.
* Policy enforcement & watchdog features.
* Deployment in a **cloud-accessible environment** (Ngrok for local tunneling, Railway for production).
---Google Colab Link:- https://colab.research.google.com/drive/1kch-P9dBOBpNRyMMdP_jV-pBMsVLX3fS
-
Initial Specification
- Defined a large set of REST API endpoints across multiple domains (hygiene, catalog, licensing, install, config, permissions, connectors, invoke, runs, schedules, policy enforcement, watchdog, etc.).
- Chose Flask as the framework.
- Targeted Google Colab for rapid prototyping, with Ngrok to expose the local service.
-
Backend Implementation
-
Wrote a complete Flask server (
main.py) with stubbed in-memory stores for agents, installs, runs, schedules, policies, watchdog detections. -
Added hygiene features:
- Idempotency headers
- Rate limit headers
- Request IDs
- RFC7807 error responses
-
-
Testing Suite
-
Created a Colab notebook and a Python script to:
- Systematically test every API endpoint.
- Log request/response.
- Save reports in JSON + Markdown.
-
Automated flows for install → config → invoke → runs → schedules → policy → webhooks → billing.
-
-
Deployment
- Used Ngrok (with token:
32aauBZgG3BuoZFAT3B8VNMLPFp_hYNbMn3ubwewMaS1KkYH) to expose Colab. - Later deployed to Railway using the repo Agent-marketplace.
- Deployment successful, service live under Railway.
- Used Ngrok (with token:
| Issue | Cause | Fix |
|---|---|---|
| Duplicate Flask routes | Decorators without functools.wraps caused “View function mapping is overwriting an existing endpoint.” |
Added @wraps(func) in idempotency decorator. |
| f-string syntax errors | Improperly closed f-strings in policy enforcement test calls. | Corrected f-string format and ensured proper braces. |
datetime.utcnow() warnings |
Deprecated in Python 3.12. | Replaced with datetime.now(UTC). |
| Watchdog endpoints 404 | Not implemented in the backend stub. | Added stub endpoints (sources, detections, disclosures, sweep). |
| TypeError: unhashable type 'dict' | Accidentally used a set for test results. |
Replaced with a list, wrapped data with JSON-safe serializer. |
| FileNotFoundError for reports | /mnt/data not always available. |
Created the directory with os.makedirs(exist_ok=True). |
- Hygiene: Ping, rate-limit headers, error model.
- Catalog: List agents, get details, versions, artifacts.
- Licensing: Plans, subscriptions, entitlements.
- Installations: Create, list, enable/disable.
- Config: Schema fetch, set, get.
- Permissions: Get, grant/revoke.
- Connectors: Add, list, status.
- Invoke: Sync, async, validate input.
- Runs: Get status, logs, artifacts, cancel, feedback.
- Schedules: Create, list, update, delete.
- Policy: Get, update.
- Webhooks: Register, test, delete.
- Analytics: Runs search, metrics.
- Billing: Usage, invoices.
- MCP: Manifest, invoke tools, send events.
- Policy Enforcement: Upload, simulate, enforce, findings (list, accept, remediate), attest.
- Watchdog: Stubs available (sources, detections, sweep, disclosures).
-
Ngrok (Colab): Temporary live link (used for testing):
https://d62e3ad6a8db.ngrok-free.app -
Railway (Production): Repo: Agent-marketplace on GitHub Status: ✅ Deployment successful (via GitHub CI → Railway) Region:
asia-southeast1
-
Built a production-ready API skeleton for an Agent Marketplace.
-
Cut down development cost & time drastically:
- Traditional devs: 3–4 weeks, ~$7k–$15k.
- With Colab + AI assistance: ~1 day of iterative building & debugging.
-
Achieved end-to-end functionality with 50+ endpoints, tested automatically.
- Add authentication & RBAC.
- Replace in-memory stores with persistent DB (Postgres/Redis).
- Harden watchdog agent integrations.
- Publish OpenAPI/Swagger docs for external developers.