This backend is a serverless application that uses AWS Lambda, API Gateway, DynamoDB, Mongoose, and Node.js to create a RESTful API and a function that can be invoked by a client application/cloudwatch event.
- Node.js v14.x or later
- Serverless Framework v2.4.0 or later
- AWS CLI v2.0.0 or later
Install the dependencies
npm installcurl https://<api-id>.execute-api.<region>.amazonaws.com/dev/poolscurl https://<api-id>.execute-api.<region>.amazonaws.com/dev/pools/<pool-id>curl -X POST https://<api-id>.execute-api.<region>.amazonaws.com/dev/pools/search -d '{"search": "search term"}'/src- Main source code directory/contracts- Smart contract ABIs and interfaces/schemas- Zod schemas and Mongoose models for data validation/utils- Utility functions for APR calculations, data syncing, etc.
src/handler.ts- Main Lambda function handlers for API endpointssrc/config.ts- Environment configuration managementsrc/connection.ts- Database connection managementsrc/viemClient.ts- Ethereum client configuration
- GET
/pools- Retrieve all pools - GET
/pools/{poolAddress}- Get specific pool by address - POST
/search- Search pools by name - GET
/health- Health check endpoint - (Scheduled)
/sync- Sync data from external sources
serverless-*.yml- Serverless Framework configurations for different environments.env- Environment variables (gitignored)tsconfig.json- TypeScript configuration.eslintrc.js&.prettierrc.js- Code style configuration
.github/workflows/- GitHub Actions for CI/CDdevelop.yml- Development deployment pipelinemain.yml- Production deployment pipeline
- Serverless Architecture using AWS Lambda
- MongoDB for data persistence
- TypeScript with strict type checking
- Zod for runtime type validation
- Automated deployments via GitHub Actions
- Regular data synchronization with blockchain
- APR calculations for DeFi pools