Liquid Terminal Backend is a comprehensive API and data processing platform dedicated to the HyperLiquid ecosystem. Our goal is to provide robust, scalable services that power the Liquid Terminal frontend and enable developers to build on top of HyperLiquid data.
- Real-time Market Data - Live spot and perpetual market feeds from HyperLiquid
- Market Analytics - Volume, market cap, and trading statistics
- Auction System - Real-time auction data and timing information
- User Management - Secure authentication with Privy integration
- Wallet Management - Multi-wallet support with limits and validation
- Wallet Lists - Curated lists for portfolio management
- Educational Resources - Comprehensive learning materials
- Project Database - Ecosystem project tracking and categorization
- Staking Data - Validator information and staking statistics
- Rate Limiting - Multi-tier protection against abuse
- Caching - Redis-based high-performance caching
- Runtime: Node.js 18+
- Framework: Express.js with TypeScript
- Database: PostgreSQL with Prisma ORM
- Cache: Redis for high-performance data caching
- Authentication: Privy JWT validation
- Validation: Zod schema validation
- Rate Limiting: Redis-based multi-tier rate limiting
- File Upload: Multer with validation
- Logging: Custom log deduplication system
- Circuit Breaker: Fault tolerance for external APIs
- Deployment: Railway-ready
src/
βββ app.ts # Express app configuration
βββ server.ts # Server entry point
βββ core/ # Core services and utilities
β βββ base.api.service.ts # Base API service class
β βββ cache.service.ts # Redis caching service
β βββ circuit.breaker.ts # Circuit breaker implementation
β βββ client.initializer.ts # API clients initialization
β βββ crudBase.service.ts # Base CRUD service
β βββ prisma.service.ts # Prisma database client
β βββ redis.service.ts # Redis client
β βββ transaction.service.ts # Database transactions
βββ clients/ # External API clients
β βββ hyperliquid/ # HyperLiquid API clients
β β βββ spot/ # Spot market clients
β β βββ perp/ # Perpetual market clients
β β βββ vault/ # Vault clients
β βββ hypurrscan/ # Hypurrscan API clients
βββ services/ # Business logic services
β βββ auth/ # Authentication services
β βββ spot/ # Spot market services
β βββ perp/ # Perpetual market services
β βββ wallet/ # Wallet management
β βββ walletlist/ # Wallet list management
β βββ educational/ # Educational content
β βββ project/ # Project management
β βββ staking/ # Staking services
βββ routes/ # API route handlers
β βββ auth/ # Authentication routes
β βββ spot/ # Spot market routes
β βββ perp/ # Perpetual market routes
β βββ wallet/ # Wallet routes
β βββ walletlist/ # Wallet list routes
β βββ educational/ # Educational routes
β βββ project/ # Project routes
β βββ staking/ # Staking routes
βββ repositories/ # Data access layer
β βββ interfaces/ # Repository interfaces
β βββ prisma/ # Prisma implementations
βββ middleware/ # Express middleware
β βββ authMiddleware.ts # Privy authentication
β βββ apiRateLimiter.ts # Rate limiting
β βββ roleMiddleware.ts # Role-based access
β βββ security.middleware.ts # Security headers
β βββ validation/ # Request validation
βββ schemas/ # Zod validation schemas
βββ types/ # TypeScript type definitions
βββ errors/ # Custom error classes
βββ constants/ # Application constants
βββ utils/ # Utility functions
βββ prisma/ # Database schema and migrations
- Node.js 18+
- PostgreSQL 14+
- Redis 6+
- npm, yarn, pnpm, or bun
-
Clone the repository
git clone https://github.com/Liquid-Terminal/LiquidTerminal_Back.git cd LiquidTerminal_Back -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Update
.envwith your configuration:# Database DATABASE_URL="postgresql://username:password@localhost:5432/liquidterminal" # Redis REDIS_URL="redis://localhost:6379" # Authentication PRIVY_APP_ID="your_privy_app_id" PRIVY_APP_SECRET="your_privy_app_secret" # Security ALLOWED_ORIGINS="http://localhost:3000,https://liquidterminal.xyz" # Server PORT=3002 NODE_ENV=development
-
Set up the database
# Generate Prisma client npx prisma generate # Run migrations npx prisma migrate dev # (Optional) Seed the database npx prisma db seed
-
Start Redis
# Using Docker docker run -d -p 6379:6379 redis:alpine # Or using local Redis installation redis-server
-
Run the development server
npm run dev
-
Verify the setup Navigate to http://localhost:3002/health
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run test- Run tests (when implemented)npm run db:migrate- Run database migrationsnpm run db:seed- Seed the databasenpm run db:studio- Open Prisma Studio
The API follows RESTful principles with comprehensive error handling and rate limiting.
- Development:
http://localhost:3002 - Production:
https://liquidterminal.up.railway.app
- Burst: 20 requests per second
- Minute: 1,200 requests per minute
- Hour: 72,000 requests per hour
Protected routes require a Privy JWT token:
Authorization: Bearer <privy_jwt_token>
Market Data
# Get spot market data
GET /market/spot?sortBy=volume&limit=20&page=1
# Get perpetual market data
GET /market/perp?sortBy=openInterest&limit=20&page=1
# Get global spot statistics
GET /market/spot/globalstats
# Get auction data
GET /market/spot/auctionUser Management
# Login/register user
POST /auth/login
Authorization: Bearer <privy_token>
# Get user profile
GET /auth/user
Authorization: Bearer <privy_token>Wallet Management
# Add wallet to user
POST /wallet
Authorization: Bearer <privy_token>
Content-Type: application/json
{
"address": "0x123...",
"name": "My Wallet"
}
# Get user wallets
GET /wallet/user
Authorization: Bearer <privy_token>The application uses Prisma ORM with PostgreSQL. Key entities:
- User - User accounts with Privy integration
- Wallet - Ethereum wallet addresses
- UserWallet - User-wallet associations
- WalletList - Curated wallet collections
- Project - Ecosystem projects
- EducationalContent - Learning resources
Redis is used extensively for caching:
- Market Data: 10-second cache with real-time updates
- User Data: 5-minute cache
- Static Content: 1-hour cache
- Rate Limiting: Real-time counters
Standardized error responses:
{
"success": false,
"error": "Error message",
"code": "ERROR_CODE"
}- TypeScript - Strict type checking
- ESLint - Code quality enforcement
- Prettier - Code formatting (when configured)
- Conventional Commits - Structured commit messages
- Rate Limiting - Multi-tier protection
- Input Validation - Zod schema validation
- Authentication - Privy JWT verification
- Authorization - Role-based access control
- CORS - Configurable origin restrictions
- Security Headers - Helmet.js integration
- SQL Injection - Prisma ORM protection
- Circuit Breaker - External API fault tolerance
- Logging - Comprehensive logging with deduplication
- Health Checks -
/healthendpoint - Performance - Redis caching metrics
- Error Tracking - Structured error logging
-
Connect Repository
- Link your GitHub repository to Railway
- Set up automatic deployments
-
Environment Variables
DATABASE_URL=<railway_postgres_url> REDIS_URL=<railway_redis_url> PRIVY_APP_ID=<your_privy_app_id> PRIVY_APP_SECRET=<your_privy_app_secret> ALLOWED_ORIGINS=<your_frontend_domains> NODE_ENV=production
-
Build Configuration
{ "build": { "commands": [ "npm run build", "npx prisma migrate deploy" ] }, "start": { "command": "npm start" } }
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npx prisma generate
RUN npm run build
EXPOSE 3002
CMD ["npm", "start"]- Client Architecture - System architecture overview
- Environment Setup - Development environment guide
- API Implementation Guide - Adding new endpoints
- Frontend: LiquidTerminal_Front
- Website: liquidterminal.xyz
- X: @LiquidTerminal
- API Documentation: liquid-terminal.gitbook.io
This project is licensed under the MIT License - see the LICENSE file for details.
- HyperLiquid - For providing the foundational trading and defi infrastructure
- Privy - For secure authentication services
- Railway - For reliable hosting infrastructure
- Hypurrscan - For providing HyperLiquid endpoints.
Built with β€οΈ by the Liquid Terminal team