A NestJS application that tracks cryptocurrency prices and provides price alerts.
- Track Ethereum and Polygon prices every 5 minutes
- Email notifications for price changes
- Historical price data API
- Price alert system
- ETH to BTC swap rate calculator
- Swagger API documentation
- Docker and Docker Compose
- Node.js 18+ (for local development)
- PostgreSQL (handled by Docker)
- Moralis API key
- SMTP email service
Create a .env
file in the root directory with:
MORALIS_API_KEY=your_moralis_api_key
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_app_password
- Build and start the application:
docker-compose up --build
- The application will be available at:
- API: http://localhost:3000
- Swagger Documentation: http://localhost:3000/api
- Install dependencies:
npm install
- Start PostgreSQL:
docker-compose up postgres
- Run migrations:
# Generate a new migration
npm run migration:generate src/database/migrations/MigrationName
# Run all pending migrations
npm run migration:run
# Show migration status
npm run migration:show
# Revert last migration
npm run migration:revert
- Start the application:
npm run start:dev
The project uses TypeORM for database management. Available migration commands:
# Create a new blank migration
npm run migration:create src/database/migrations/MigrationName
# Generate a migration from entity changes
npm run migration:generate src/database/migrations/MigrationName
# Run pending migrations
npm run migration:run
# Show migration status
npm run migration:show
# Revert the last executed migration
npm run migration:revert
GET /prices/hourly?chain=ETH
- Get hourly prices for the last 24 hoursPOST /prices/alerts
- Create price alertGET /prices/swap-rate?ethAmount=1
- Get ETH to BTC swap rate
# unit tests
npm run test
# e2e tests
npm run test:e2e
# test coverage
npm run test:cov
├── src/
│ ├── main.ts # Application entry point
│ ├── app.module.ts # Main application module
│ ├── config/ # Configuration files
│ ├── database/ # Database entities and migrations
│ ├── price/ # Price tracking module
│ ├── email/ # Email notification module
│ └── blockchain/ # Blockchain service module
├── test/ # Test files
├── docker-compose.yml # Docker configuration
├── Dockerfile # Docker build file
├── .env # Environment variables
└── README.md # Project doc
609E
umentation
The application automatically:
- Tracks ETH and MATIC prices every 5 minutes
- Sends email alerts when price increases by >3% in an hour
- Sends email alerts when price reaches target values
- Stores all price data in PostgreSQL
- Fork the repository
- Create your feature branch:
git checkout -b feature/my-feature
- Commit your changes:
git commit -am 'Add new feature'
- Push to the branch:
git push origin feature/my-feature
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details