A working reference implementation of a complete developer API platform — every layer a developer-facing business needs, built end to end: OAuth 2.0, webhooks, rate limiting, SDKs, request logging, and a developer dashboard.
What this is: a demonstrative build, not a commercial product. The domain is DeFi yield (a unified REST API wrapping Morpho and Aave), but the point is the platform craft around it — the same architecture I ran at Square scale: API design and versioning, AuthN/Z with short-lived tokens, Svix-powered event delivery, per-endpoint rate limits, sandbox semantics, and self-serve developer onboarding. No real funds move.
Live sandbox: the API gateway runs at flow-platform-production.up.railway.app (/health, /v1/*) with Stripe-style structured errors.
The platform provides a single REST API that wraps multiple DeFi protocols (Morpho and Aave), enabling developers to integrate yield without managing protocol-specific integrations, smart contracts, or compliance requirements.
Key Features:
- Unified API - Single interface for multiple DeFi protocols
- OAuth 2.0 Authentication - Short-lived access tokens with automatic refresh
- Real-time Webhooks - Svix-powered event delivery with retries
- Rate Limiting - Configurable per-endpoint limits
- Real-time Rates - Current APY from Morpho and Aave
- Developer Dashboard - Application, API key, and webhook management
- Request Logging - 7-day API request/response logging
- JDK 17+
- PostgreSQL 12+
- Git
# Clone repository
git clone https://github.com/mikewards/flow-platform.git
cd flow-platform
# Set up database
createdb flow_api
# Configure environment
cd flow-api
cp .env.example .env
# Edit .env with your database credentials
# Start backend
./gradlew run
# Start frontend (in another terminal)
cd frontend && npx wrangler devVisit http://localhost:8787 for the frontend and http://localhost:8080 for the API.
For detailed setup instructions, see Development Setup
flow-platform/
├── flow-api/ # Kotlin backend (Ktor)
│ ├── src/main/kotlin/ # Source code
│ │ └── com/ground/
│ │ ├── api/routes/ # API endpoints
│ │ ├── dto/ # Data transfer objects
│ │ ├── middleware/ # Auth, rate limiting, logging
│ │ ├── model/ # Database models
│ │ ├── service/ # Business logic
│ │ └── integration/ # Morpho/Aave clients
│ └── build.gradle.kts # Build configuration
├── frontend/ # Frontend application
│ ├── pages/ # HTML pages
│ ├── styles/ # CSS files
│ ├── scripts/ # JavaScript files
│ │ └── token-manager.js # OAuth token management
│ ├── sdk-demos/ # SDK demo pages
│ ├── worker.js # Cloudflare Worker entry point
│ └── wrangler.jsonc # Cloudflare Worker config
├── docs/ # Documentation
│ ├── deployment/ # Deployment guides
│ ├── development/ # Development setup
│ ├── api/ # API documentation
│ └── architecture/ # System architecture
└── scripts/ # Build and deployment scripts
Backend:
- Kotlin 1.9.20
- Ktor 2.3.5
- PostgreSQL
- Exposed (SQL framework)
- Web3j (Ethereum integration)
- Svix (Webhooks)
Frontend:
- Vanilla HTML/CSS/JavaScript
- Cloudflare Workers (hosting)
- TokenManager.js (OAuth 2.0 token refresh)
Infrastructure:
- Railway.app (backend hosting)
- Cloudflare Workers (frontend hosting)
- PostgreSQL (database)
All documentation is organized in the docs/ directory:
- Development Setup - Local development guide
- API Specification - Complete API reference
- OpenAPI 3.1 spec - Machine-readable endpoint contract (served at
/openapi.yaml) - llms.txt - Docs index for coding agents (served at
/llms.txt) - Deployment Guide - Production deployment
- Architecture Overview - System design
- Environment Variables - Configuration reference
curl -X POST http://localhost:8080/v1/accounts \
-H "Content-Type: application/json" \
-d '{
"username": "developer",
"password": "secure_password",
"email": "dev@example.com"
}'curl -X POST http://localhost:8080/v1/auth/authenticate \
-H "Content-Type: application/json" \
-d '{
"username": "developer",
"password": "secure_password"
}'
# Response includes:
# - access_token (15 min)
# - refresh_token (30 days)curl -X POST http://localhost:8080/v1/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "ground_refresh_..."
}'curl -X GET http://localhost:8080/v1/yield/rates \
-H "Authorization: Bearer YOUR_API_KEY"See API Specification for complete API reference
- Push code to GitHub
- Connect repository to Railway
- Add PostgreSQL database
- Set environment variables (see below)
- Deploy!
See Railway Deployment Guide for detailed instructions
cd frontend
npx wrangler deploySee Cloudflare Deployment Guide for detailed instructions
Required variables:
DATABASE_URL- PostgreSQL connection stringJWT_SECRET- JWT signing secret (min 32 chars)MASTER_ENCRYPTION_KEY- Wallet encryption key (32 bytes hex)ENVIRONMENT-development,sandbox, orproductionSVIX_API_KEY- Svix webhook service API key
See Environment Variables Reference for complete list
# Run tests
cd flow-api
./gradlew test
# Build
./gradlew buildThis is a private project. For questions or contributions:
- Check the documentation
- Review API documentation
- See development setup
MIT License
Built for developers who want to integrate DeFi yield into their applications.