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
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
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
x402 Payment Flow
The core monetization feature implementing the x402 protocol:Payment States
- pending: Payment challenge issued, awaiting settlement
- settled: Credits deducted, receipt issued, ready for consumption
- completed: Request fulfilled with payment proof
Flow Implementation
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
GET/POST /mcp- MCP JSON-RPC endpoint
Data Flow: x402 Payment
Here’s how data flows through the system for a complete x402 payment:Configuration
Environment Variables
API (.env):Constants
Key application constants defined inapi/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_ORIGINto 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_SECRETregularly
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
- API Key Hashing: Keys are hashed before storage, never stored in plain text
- HTTP-Only Cookies: Session tokens not accessible via JavaScript
- CORS Protection: Strict origin validation
- SQL Injection: Drizzle ORM prevents SQL injection via parameterized queries
- Private Key Storage: Agent private keys are base64-encoded (consider encryption for production)