Sequencer Service
Overview
The Sequencer is a NodeJs-based service, it processes all internal and external transactions performs risk checks, and updates account state.
Quick Start
Prerequisites
- Node.js LTS
- Docker and Docker Compose
- NX CLI (
yarn nx
)
Setup & Running
-
Create and populate
.env
file using the template in .env.example -
Build the service:
- Start with Docker Compose:
- Stop and cleanup:
Development
Run tests:
# Unit tests
nx run sequencer:test
# Integration tests (requires .env file in tests/it/)
nx run sequencer:it
Technical Specifications
Core Technology Stack
- Runtime: Node.js LTS
- Language: TypeScript 4.x
- Build System: NX with ESBuild
- Service Type: Application Service
- Version: 0.0.1
Key Dependencies
-
Core:
-
ESBuild for TypeScript compilation
- FastAPI for API endpoints
- Redis for order storage and pub/sub
-
BigQuery for trade history
-
Testing:
-
Jest
- Supertest
-
Redis Mock
-
Development:
- ESLint
- NX Monorepo Tools
- TypeScript with strict mode
Service Architecture
Core Components
-
API Layer (app.ts)
-
RESTful endpoints
- Request validation
- Response handling
-
Error management
-
Order Management
-
Limit order handling
- Market order processing
- RFQ system
-
Order cancellation
-
Matching Engine
-
Order book maintenance
- Price-time priority matching
- Fill or Kill (FOK) orders
-
Immediate or Cancel (IOC) orders
-
Database Layer (db/)
-
Redis integration for order books
- BigQuery for trade history
- Data persistence strategies
-
Caching mechanisms
-
Types & Validation (types/, validators/)
-
Type definitions
- Input validation
- Schema enforcement
-
Signature verification
-
Utilities (utils/)
- Order processing helpers
- Signature validation
- Mathematical calculations
- Shared functionality
API Endpoints (TODO)
Infrastructure
Deployment
- Containerized deployment (Dockerfile provided)
- Redis requirement for funding data
- BigQuery integration for transaction snapshots
- Environment-based configuration
Build Configuration
- Development and production builds
- Source map support
- TypeScript strict mode
- ESLint integration
Testing Infrastructure
Unit Testing
- Jest framework
- Mocked dependencies
- Comprehensive test coverage
- Automated via CI/CD
Integration Testing
- End-to-end API testing
- Redis integration tests
- Sequenced test execution
- Environment-specific configurations
Development Tools
- ESLint configuration
- TypeScript strict mode
- Automated testing
- Hot reloading
Configuration
Environment Variables
Required variables:
ORDERBOOK_PORT=4000
REDIS_HOST=localhost
REDIS_PORT=6379
ORDERBOOK_SALT=your_salt
PROJECT_ID=your_gcp_project
SEQUENCER_API_URL=http://localhost:3000
PREMIA_API_KEY=your_api_key
ENV=local|dev|prod
Monitoring & Health
Endpoints
/healthcheck
- Service health check- Metrics endpoint (TODO)
Logging
- Structured JSON logging
- Error tracking
- Request tracing
- Performance monitoring
Contributing
- Fork the repository
- Create your feature branch
- Run tests before committing
- Submit pull request
License
Proprietary - All rights reserved
This documentation is generated from the service README. For the most up-to-date information, refer to the original README