A prototype for L2-style streaming payments using Coinbase x402. This system enables real-time micro-payments while users consume content, with batched settlement to reduce gas/fee overhead.
This project implements a microservices architecture with the following components:
- API Gateway: Public-facing API layer with authentication and rate limiting
- Aggregator Service: Receives events, updates Redis counters, triggers batch flushes
- Worker Service: Processes batches and calls Coinbase x402 for settlement
- Reconciler Service: Periodic reconciliation and audit jobs
- Dashboard: Admin panel for monitoring and management
- SDK: Client library for developers to integrate streaming payments
- Runtime: Node.js with TypeScript
- Package Manager: pnpm workspaces
- Database: PostgreSQL with Prisma ORM
- Cache: Redis
- Queue: RabbitMQ
- Containerization: Docker & Docker Compose
- Monitoring: Prometheus & Grafana
-
Install dependencies:
pnpm install
-
Start infrastructure:
pnpm docker:up
-
Run database migrations:
pnpm run db:migrate
-
Start all services:
pnpm dev
Each service is located in the services/ directory and can be developed independently:
services/api-gateway/- Public API endpointsservices/aggregator/- Event aggregation and Redis managementservices/worker/- Batch processing and x402 integrationservices/reconciler/- Reconciliation jobsservices/dashboard/- Admin dashboard
The client SDK is located in the sdk/ directory and provides a simple interface for developers to integrate streaming payments.
Shared code and types are in the common/ directory and used across all services.
The project uses Docker Compose for local development. All infrastructure services (Redis, PostgreSQL, RabbitMQ) are defined in docker/docker-compose.yml.
Monitoring configuration is in the monitoring/ directory with Prometheus and Grafana dashboards for observability.
Copy .env.example to .env and configure your environment variables.
Private - All rights reserved