Skip to main content

Overview

ActumX is built as a modern full-stack application with a clear separation between the API backend and the dashboard frontend. The system is designed around the x402 payment protocol, enabling standardized API monetization through HTTP 402 status codes.

Technology Stack

Backend (API)

The API is built on modern, high-performance technologies:

Bun Runtime

Fast JavaScript runtime that’s 4x faster than Node.js for HTTP servers

Elysia Framework

End-to-end type-safe HTTP framework built specifically for Bun

Drizzle ORM

TypeScript-first ORM with full type safety and zero-cost abstractions

PostgreSQL

Production-grade relational database for reliable data storage

Backend Structure

Frontend (Dashboard)

The dashboard provides a modern web interface for managing your ActumX account:

Next.js 16

React framework with App Router for optimal performance

shadcn/ui

Beautiful, accessible component library built on Radix UI

Tailwind CSS

Utility-first CSS framework for rapid UI development

TypeScript

End-to-end type safety from frontend to backend

Frontend Structure

Core Components

Authentication System

ActumX uses Better Auth for secure, session-based authentication:
  • Email/password authentication
  • HTTP-only cookies for session management
  • CORS-enabled for cross-origin requests
  • Session TTL: 30 days
  • Production: Secure cookies with cross-subdomain support

Agent Management

Agents are Solana-based wallets managed by the platform:
  • Each agent has a unique Solana key pair
  • Private keys are base64-encoded and stored securely
  • Public keys are used for blockchain transactions
  • Supports devnet funding for testing
  • Balance checking via Solana RPC
Database Schema:

API Key System

Secure API key generation and management:
  • Keys are hashed using cryptographic hashing before storage
  • Only key prefixes are visible after creation (first 14 characters)
  • Keys can be revoked but not deleted (soft delete)
  • Track last usage timestamp
  • Used for MCP and programmatic access
Database Schema:

Credit-Based Billing

Simple credit ledger system for tracking payments:
  • All amounts stored in cents (integer precision)
  • Double-entry ledger: credits (top-ups) and debits (usage)
  • Top-up via POST /v1/billing/top-up
  • Balance computed as sum of all ledger entries
  • Payment intents track top-up transactions
Database Schema:

x402 Payment Flow

The core monetization feature implementing the x402 protocol:

Payment States

  1. pending: Payment challenge issued, awaiting settlement
  2. settled: Credits deducted, receipt issued, ready for consumption
  3. completed: Request fulfilled with payment proof

Flow Implementation

1

Challenge Phase

When a protected endpoint is accessed without payment:
2

Settlement Phase

Client posts to /v1/x402/settle with payment ID:
3

Consumption Phase

Client retries with payment proof headers:
Database Schema:

MCP Integration

ActumX provides a Model Context Protocol (MCP) server for AI agent integration:
  • JSON-RPC 2.0 protocol
  • Tool: wallet_balance - Check Solana wallet balances
  • Authenticated via API keys
  • Supports both GET and POST methods
  • Returns structured content for AI consumption
Endpoints:
  • GET/POST /mcp - MCP JSON-RPC endpoint
Example Tool Call:

Data Flow: x402 Payment

Here’s how data flows through the system for a complete x402 payment:

Configuration

Environment Variables

API (.env):
Dashboard (.env.local):

Constants

Key application constants defined in api/src/config/constants.ts:1:

Deployment Architecture

ActumX is designed for modern cloud deployment:

API Server

Deploy on platforms supporting Bun runtime (Fly.io, Railway, self-hosted)

Dashboard

Deploy to Vercel, Netlify, or any Next.js hosting platform

Database

Managed PostgreSQL (Neon, Supabase, AWS RDS, etc.)

Blockchain

Connects to Solana mainnet/devnet via public RPC endpoints

Production Considerations

  • CORS: Configure DASHBOARD_ORIGIN to match your production domain
  • Cookies: Production enables secure, cross-subdomain cookies (.actumx.app)
  • Database: Use connection pooling for PostgreSQL
  • Solana RPC: Consider using a dedicated RPC provider for reliability
  • API Keys: Rotate BETTER_AUTH_SECRET regularly

Performance

  • Bun Runtime: 4x faster than Node.js for HTTP operations
  • Database Indexing: All foreign keys and user_id columns are indexed
  • Type Safety: Zero runtime overhead from TypeScript types
  • Connection Pooling: Drizzle handles PostgreSQL connections efficiently

Security Features

  1. API Key Hashing: Keys are hashed before storage, never stored in plain text
  2. HTTP-Only Cookies: Session tokens not accessible via JavaScript
  3. CORS Protection: Strict origin validation
  4. SQL Injection: Drizzle ORM prevents SQL injection via parameterized queries
  5. Private Key Storage: Agent private keys are base64-encoded (consider encryption for production)
For production deployments, consider adding encryption-at-rest for agent private keys in the database.

Next Steps

API Reference

Explore detailed API endpoint documentation

x402 Protocol

Learn the x402 payment protocol specification

Development Guide

Set up a local development environment

Deployment

Deploy ActumX to production