A high-performance Bitcoin transaction processing and serving API built with Bun and Elysia.js. This service processes Bitcoin SV transactions, providing social features, caching, and real-time updates.
- Transaction Processing: Ingest and store Bitcoin transactions with MongoDB and Redis caching
- Social Features: Friends, identities, and likes system
- Real-time Updates: Stream Bitcoin transactions via JungleBus
- Dynamic Charts: Generate transaction visualizations using Chart.js
- BAP Integration: Bitcoin Attestation Protocol identity management
- High Performance: Built with Bun runtime and Elysia.js framework
- API Documentation: Interactive Swagger/OpenAPI documentation
- Native TypeScript: Direct TypeScript execution with Bun
- Bun runtime
- MongoDB instance
- Redis instance
- Clone the repository:
git clone [repository-url]
cd bmap-api
- Install dependencies:
bun install
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
Required environment variables:
REDIS_PRIVATE_URL
: Redis connection stringBMAP_MONGO_URL
: MongoDB connection URL
Start the development server with hot reload:
bun run dev
The server will start at http://localhost:3000
. You can access:
- API at
http://localhost:3000/
- Swagger documentation at
http://localhost:3000/swagger
bun run dev
: Run development server with hot reloadbun run start
: Run production serverbun run typecheck
: Run TypeScript type checkingbun run lint
: Run Biome checksbun run lint:fix
: Auto-fix Biome issuesbun run test-redis
: Test Redis connectivitybun run prepare-hooks
: Set up Git hooks
The project uses several tools to maintain code quality:
- TypeScript: Native support via Bun
- Biome: For linting and formatting
- Git Hooks: Pre-commit and pre-push checks
- MongoDB Indexes: For query optimization
- Swagger/OpenAPI: API documentation and testing
-
Code Style
- Follow Biome formatting rules
- Use TypeScript types and interfaces
- Document complex logic
- Keep files focused and modular
- Document API endpoints using Swagger decorators
-
Error Handling
- Use typed error responses
- Implement proper error boundaries
- Log errors with context
- Handle edge cases explicitly
-
Performance
- Use Redis caching appropriately
- Implement proper indexes
- Consider batch processing
- Monitor memory usage
-
Security
- Validate input data
- Sanitize database queries
- Use proper error messages
- Consider rate limiting
The API is documented using Swagger/OpenAPI specification. You can access the interactive documentation at /swagger
when the server is running.
- Interactive UI: Available at
/swagger
- OpenAPI Spec: Available at
/swagger/json
- API Explorer: Test endpoints directly from the browser
- Query and retrieve transaction data
- Real-time transaction updates
- Transaction processing status
- Friends management
- Identity lookup
- Like system
- Message interactions
- Dynamic chart generation
- Time series visualizations
- Custom chart parameters
MongoDB Collections:
c
: Confirmed transactionsu
: Unconfirmed transactions
Redis Caching:
- Transaction data
- BAP identities
- Social graph information
- Transaction Processing: Handles ingestion and normalization
- Caching Layer: Manages Redis caching and invalidation
- Social Features: Handles friend relationships and likes
- Chart Generation: Creates dynamic visualizations
- BAP Integration: Manages Bitcoin identities
- API Documentation: Swagger/OpenAPI integration
- Fork the repository
- Create your feature branch
- Run tests and ensure code quality:
bun run lint bun run build
- Submit a pull request
[Add License Information]
[Add Support Information]