A real-time price alert system for stocks and cryptocurrencies. Get notified when your favorite assets hit target prices through email and WebSocket notifications.
- User Authentication: Secure JWT-based authentication with refresh tokens
- Price Alerts: Create, manage, and monitor price alerts for stocks and cryptocurrencies
- Real-time Updates: WebSocket connections for live price updates and alert triggers
- Multi-Asset Support: Support for both stocks (via Yahoo Finance) and cryptocurrencies (via Binance API)
- Email Notifications: Email alerts when price targets are reached
- Market Data API: Fetch current prices, validate symbols, and get bulk price data
- Redis Caching: Optimized performance with Redis caching for market data
- Background Monitoring: Automated scheduler for checking and triggering alerts
- Modern UI: Beautiful, responsive React frontend with Tailwind CSS
- FastAPI - Modern Python web framework
- PostgreSQL - Relational database with asyncpg
- Redis - Caching and session management
- SQLAlchemy - ORM with async support
- Alembic - Database migrations
- WebSockets - Real-time communication
- JWT - Authentication tokens
- Python Binance & yfinance - Market data providers
- React 19 - UI library
- Vite - Build tool and dev server
- React Router - Client-side routing
- Axios - HTTP client
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Icon library
- Docker & Docker Compose - Containerization
- Nginx - Web server for frontend
- Uvicorn - ASGI server
- Docker and Docker Compose installed
- Git
- (Optional) Node.js 20+ and Python 3.10+ for local development
-
Clone the repository
git clone <your-repo-url> cd crypto-alert
-
Create environment file (optional)
# Create .env file in project root POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=crypto_alerts SECRET_KEY=your-secret-key-here JWT_SECRET_KEY=your-jwt-secret-key-here # Optional: API Keys BINANCE_API_KEY=your-binance-api-key BINANCE_API_SECRET=your-binance-api-secret # Optional: Email configuration SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USERNAME=your-email@gmail.com SMTP_PASSWORD=your-app-password SMTP_FROM_EMAIL=your-email@gmail.com
-
Start all services
docker-compose up -d
-
Access the application
- Frontend: http://localhost (or http://localhost:3000)
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
-
View logs
# All services docker-compose logs -f # Specific service docker-compose logs -f backend docker-compose logs -f frontend
docker-compose downdocker-compose down -v
docker-compose up -dThe application uses environment variables for configuration. You can set them in a .env file or as environment variables in docker-compose.yml.
DATABASE_URL- PostgreSQL connection string (auto-generated in docker-compose)SECRET_KEY- Secret key for encryptionREDIS_URL- Redis connection string (auto-generated in docker-compose)
POSTGRES_USER- PostgreSQL username (default:postgres)POSTGRES_PASSWORD- PostgreSQL password (default:postgres)POSTGRES_DB- Database name (default:crypto_alerts)CORS_ORIGINS- Comma-separated list of allowed originsSMTP_*- Email configuration for notifications
All API endpoints are prefixed with /api/v1/.
POST /register- Register a new userPOST /login- Login and get JWT tokensPOST /refresh- Refresh access tokenGET /me- Get current user infoPOST /logout- Logout user
POST /- Create a new alertGET /- Get all user alertsGET /{alert_id}- Get specific alertPUT /{alert_id}- Update alertDELETE /{alert_id}- Delete alert
GET /price/{symbol}- Get current pricePOST /prices- Get multiple pricesGET /validate/{symbol}- Validate symbol exists
WS /connect- Connect for real-time updates
POST /test-email- Send test email
cd backend
# Install dependencies using uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
# Or using pip
pip install -r requirements.txt
# Set up environment variables
export DATABASE_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/crypto_alerts"
export REDIS_URL="redis://localhost:6379/0"
export SECRET_KEY="your-secret-key"
# Run migrations
alembic upgrade head
# Start development server
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000cd frontend
# Install dependencies
npm install
# Start development server
npm run devThe frontend will run on http://localhost:5173 (or another port if 5173 is busy).
crypto-alert/
βββ backend/
β βββ src/
β β βββ auth/ # Authentication logic
β β βββ alerts/ # Alert management
β β βββ market_data/ # Market data fetching
β β βββ notifications/ # Email notifications
β β βββ websocket/ # WebSocket handlers
β β βββ cache/ # Redis client
β β βββ database.py # Database setup
β β βββ config.py # Configuration
β β βββ main.py # FastAPI app
β βββ alembic/ # Database migrations
β βββ Dockerfile
β βββ pyproject.toml
βββ frontend/
β βββ src/
β β βββ api/ # API client
β β βββ contexts/ # React contexts
β β βββ pages/ # Page components
β β βββ App.jsx
β βββ Dockerfile
β βββ package.json
βββ docker-compose.yml
- Check that PostgreSQL container is running:
docker-compose ps - Verify database credentials in environment variables
- Check logs:
docker-compose logs postgres
- Ensure your frontend URL is in
CORS_ORIGINS - Check backend logs for CORS-related errors
- Verify frontend is accessing from allowed origin
- Check Redis container is running:
docker-compose logs redis - Application will work without Redis (caching disabled)
- Verify backend is running and accessible
- Check browser console for detailed error messages
- Ensure API base URL is correct in
src/api/client.js
API documentation and testing interface available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
# Create a new migration
docker exec -it crypto-alert-backend alembic revision --autogenerate -m "description"
# Apply migrations
docker exec -it crypto-alert-backend alembic upgrade head
# Rollback migration
docker exec -it crypto-alert-backend alembic downgrade -1- Change default passwords and secrets in production
- Use strong
SECRET_KEYvalues - Enable HTTPS in production
- Configure proper CORS origins
- Keep dependencies updated
Contributions are welcome! Please feel free to submit a Pull Request.
Boluwatife Leke-Oduoye
- Binance API for cryptocurrency data
- Yahoo Finance for stock market data