A full-stack web application for cryptocurrency price forecasting using machine learning. The application provides real-time cryptocurrency data, historical price analysis, and price predictions using linear regression models.
- Real-time cryptocurrency price tracking via Coinbase API
- Machine learning-based price predictions
- User authentication with JWT tokens
- Multi-language support (English, French, Arabic, Chinese)
- Responsive Material-UI design
- Dark/Light theme support
- Portfolio management
- Interactive price charts and visualizations
- React 18.2.0 with TypeScript
- Material-UI (MUI) v5
- Redux Toolkit for state management
- ApexCharts for data visualization
- Axios for API communication
- React Router for navigation
- Flask 3.0.0 (Python)
- MongoDB for data storage
- Flask-JWT-Extended for authentication
- Scikit-learn for ML predictions
- Flask-CORS for cross-origin requests
- Flask-Limiter for rate limiting
- Docker and Docker Compose
- Nginx for production frontend serving
- Health checks and monitoring
- Python 3.11 or higher
- Node.js 18 or higher
- MongoDB 7.0 or higher
- Docker and Docker Compose (optional)
- Clone the repository:
git clone https://github.com/dtoyoda10/crypto-forcast.git
cd crypto-forcast- Create environment file:
cp server/.env.example server/.env- Generate secure secret keys:
python -c "import os; print('SECRET_KEY=' + os.urandom(32).hex())" >> server/.env
python -c "import os; print('JWT_SECRET_KEY=' + os.urandom(32).hex())" >> server/.env- Start all services:
docker-compose up -d- Access the application:
- Frontend: http://localhost
- Backend API: http://localhost:5000
- MongoDB: localhost:27017
- Navigate to server directory:
cd server- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure environment:
cp .env.example .env- Edit
.envfile with your configuration:
FLASK_ENV=development
SECRET_KEY=your-secret-key-here
JWT_SECRET_KEY=your-jwt-secret-key-here
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB_NAME=crypto_forcast- Start MongoDB:
mongod- Run the Flask application:
python app.py- Navigate to client directory:
cd client- Install dependencies:
npm install- Configure environment:
cp .env.example .env- Edit
.envfile:
REACT_APP_API_URL=http://localhost:5000- Start development server:
npm start- Build for production:
npm run buildPOST /register
Content-Type: application/json
{
"email": "user@example.com",
"password": "SecurePass123"
}
Response:
{
"message": "User registered successfully",
"email": "user@example.com"
}
POST /login
Content-Type: application/json
{
"email": "user@example.com",
"password": "SecurePass123"
}
Response:
{
"message": "Login successful",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbG...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbG...",
"email": "user@example.com"
}
POST /api/prediction
Content-Type: application/json
{
"coin": "BTC",
"period": "day"
}
Response:
{
"coin": "BTC",
"period": "day",
"predictions": [
["2025-01-15 10:00:00", 45234.56],
["2025-01-15 11:00:00", 45345.67]
]
}
GET /api/get_coins_summary
Response:
{
"data": [...]
}
POST /api/get_coins_histories
Content-Type: application/json
{
"coin": "ETH",
"period": "week"
}
Response:
{
"coin": "ETH",
"period": "week",
"data": {...}
}
GET /health
Response:
{
"status": "healthy",
"service": "crypto-forecast-api"
}
| Variable | Description | Default | Required |
|---|---|---|---|
| FLASK_ENV | Environment mode | development | No |
| SECRET_KEY | Flask secret key | - | Yes (Production) |
| JWT_SECRET_KEY | JWT signing key | - | Yes (Production) |
| MONGODB_URI | MongoDB connection string | mongodb://localhost:27017 | Yes |
| MONGODB_DB_NAME | Database name | crypto_forcast | No |
| COINBASE_API_TIMEOUT | API request timeout (seconds) | 10 | No |
| CORS_ORIGINS | Allowed CORS origins (comma-separated) | http://localhost:3000 | No |
| RATELIMIT_ENABLED | Enable rate limiting | True | No |
| RATELIMIT_DEFAULT | Default rate limit | 100 per hour | No |
| LOG_LEVEL | Logging level | INFO | No |
| PORT | Server port | 5000 | No |
| Variable | Description | Default | Required |
|---|---|---|---|
| REACT_APP_API_URL | Backend API URL | http://localhost:5000 | Yes |
- Bcrypt password hashing
- JWT-based authentication with token expiration
- Rate limiting to prevent abuse
- CORS protection with whitelisted origins
- Input validation and sanitization
- SQL/NoSQL injection prevention
- Secure HTTP headers (X-Frame-Options, X-Content-Type-Options, X-XSS-Protection)
- Environment-based configuration
- Database connection pooling with timeouts
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one digit
Backend:
cd server
pytestFrontend:
cd client
npm testFrontend:
cd client
npm run lintFrontend:
cd client
npm run buildcrypto-forcast/
├── client/ # React frontend application
│ ├── public/
│ ├── src/
│ │ ├── assets/ # Images and static files
│ │ ├── components/ # Reusable React components
│ │ ├── layouts/ # Layout components
│ │ ├── routes/ # Route configuration
│ │ ├── store/ # Redux store
│ │ ├── theme/ # Material-UI theme
│ │ ├── utils/ # Utility functions
│ │ └── views/ # Page components
│ ├── Dockerfile
│ ├── nginx.conf
│ └── package.json
├── server/ # Flask backend application
│ ├── app.py # Application entry point
│ ├── auth.py # Authentication logic
│ ├── coinbase.py # Coinbase API integration
│ ├── config.py # Configuration management
│ ├── models.py # Database models
│ ├── routes.py # API routes
│ ├── services.py # ML prediction service
│ ├── Dockerfile
│ └── requirements.txt
├── docker-compose.yml # Docker orchestration
└── README.md
If you encounter MongoDB connection errors:
- Ensure MongoDB is running:
systemctl status mongod-
Check connection string in .env file
-
Verify network connectivity:
mongosh mongodb://localhost:27017If you see CORS errors in the browser console:
- Check that the backend CORS_ORIGINS includes your frontend URL
- Verify the frontend is using the correct API URL
- Ensure both frontend and backend are running
If containers fail to start:
- Check logs:
docker-compose logs- Rebuild containers:
docker-compose down
docker-compose build --no-cache
docker-compose up- Generate strong secret keys
- Set FLASK_ENV=production
- Configure proper MONGODB_URI
- Set appropriate CORS_ORIGINS
- Review and adjust rate limiting settings
- Set up SSL/TLS certificates
- Configure proper logging and monitoring
- Set up database backups
- Use a managed MongoDB service (MongoDB Atlas, etc.)
- Deploy backend on a platform like AWS, GCP, or Heroku
- Deploy frontend on Netlify, Vercel, or similar
- Use environment variables for all secrets
- Enable HTTPS only
- Set up monitoring and alerting
- Implement database backups
- Use a reverse proxy (Nginx, Caddy)
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/improvement) - Create a Pull Request
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
For issues and questions:
- Create an issue on GitHub
- Check existing documentation
- Review troubleshooting section
- Coinbase API for cryptocurrency data
- Material-UI for the component library
- Scikit-learn for machine learning capabilities