Skip to content

Architecture

System overview

┌──────────────────────────────────────────────────────────────┐
│ Docker Network │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ Portal (port 3000) │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────────┐ │ │
│ │ │ Astro SSR │ │ Hono API │ │ │
│ │ │ (frontend) │ │ (backend) │ │ │
│ │ │ port 4321 │ │ port 3001 │ │ │
│ │ └──────────────┘ └────────┬─────────┘ │ │
│ └──────────────────────────────┼───────────┘ │
│ │ │
│ ┌────────────────────────────┼──────────────────┐ │
│ │ ▼ │ │
│ │ ┌─────────────┐ ┌──────────────┐ ┌──────┐ │ │
│ │ │ MCP Server │ │ MinIO (S3) │ │Convoy│ │ │
│ │ │ port 4000 │ │ port 9000 │ │:5005 │ │ │
│ │ └─────────────┘ └──────────────┘ └──────┘ │ │
│ │ │ │
│ │ ┌─────────────┐ ┌──────────────┐ │ │
│ │ │ S3 Adapter │ │ Docs Site │ │ │
│ │ │ port 8080 │ │ port 4001 │ │ │
│ │ └─────────────┘ └──────────────┘ │ │
│ └───────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘

Apps

Portal (apps/portal + apps/api)

The portal is built as a single Docker image that runs two processes:

  • Hono API on port 3001 — all /api/* routes, data persistence, AI agent runs
  • Astro SSR on port 4321 — all portal UI pages

A reverse proxy in the Hono server forwards non-API requests to Astro. Externally, everything is served on port 3000.

Tech stack:

  • Runtime: Bun 1.1+
  • API framework: Hono 4
  • Frontend: Astro 5 + React 19
  • AI: Anthropic Claude API (@anthropic-ai/sdk)
  • MCP: @modelcontextprotocol/sdk

MCP Server (apps/mcp-server)

A stateless HTTP MCP server that exposes 16 tools for AI agents. Each request is independent — no session state. Tools cover products, subscriptions, storage, webhooks, and ConnectWise integrations.

Transport: StreamableHTTPServerTransport (stateless, one transport per request)

S3 Adapter (packages/adapter-s3-api)

A Python FastAPI service that wraps the MinIO Python SDK. The Hono API proxies S3 management requests here rather than calling MinIO directly, keeping the API layer language-agnostic.

Docs (apps/docs)

This Astro Starlight documentation site. Statically built and served by nginx.

Data persistence

All portal data uses a simple JsonStore pattern — each resource type has its own JSON file on the container’s filesystem:

File Contents
products.json API products
subscriptions.json Subscriptions + API keys
packages.json Endpoint permission bundles
credentials.json Integration credentials (secrets stored as-is — use a secrets manager in production)
mcp-servers.json Registered MCP server configs
agents.json Agent configurations
jobs.json Scheduled job definitions
webhook-listeners.json Built-in test listener configs
portal.json Portal branding and theme config

JSON files are stored in a Docker volume (portal-data) so they survive container restarts.

Specs (OpenAPI files) live in a separate portal-specs volume.

Request flow

Standard API request

Client → POST /api/gateway/validate (with apiKey + method + path)
→ Hono API validates key from subscriptions.json
→ Checks scope, rate limit (in-memory sliding window), daily quota
→ Checks package permissions if packages assigned
→ Returns { valid, headers } or { valid: false, error }

Agent run

Client → POST /api/agents/:id/run (with { message })
→ Loads agent config from agents.json
→ For each linked MCP server: calls POST /mcp to discover tools
→ Sends message + tools to Claude API
→ Claude calls tools → MCP server executes → results back to Claude
→ Repeat until no tool calls or 10 iterations
→ Returns { result, toolCalls, iterations }

Webhook delivery

Portal calls POST /api/webhooks/dispatch (or Convoy directly)
→ Convoy queues event
→ Convoy agent delivers to registered endpoints with retries
→ Delivery status available in portal Webhooks page

Design system

All frontend styling uses a layered atomic design:

ui-tokens → CSS custom properties (colors, spacing, fonts)
ui-atoms → Button, Badge, MethodBadge, Spinner, Logo
ui-molecules → SearchBar, ThemePresetCard, ColorPickerField
ui-organisms → ThemeSettings, PortalHeader, DataTable
ui-templates → Layout wrappers, re-exports
openapi-renderer → Scalar API reference with LTG theme injection

The portal pages themselves are Astro MPA pages that import from these packages where needed. Most UI is inline in the .astro files using the shared CSS variables (--navy, --gold, --green, etc.) defined by ui-tokens.