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.
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:
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 .env file 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 .env file:
REACT_APP_API_URL=http://localhost:5000
Start development server:
npm start
Build for production:
npm run build
POST /register
Content-Type: application/json
{
"email": "[email protected]",
"password": "SecurePass123"
}
Response:
{
"message": "User registered successfully",
"email": "[email protected]"
}
POST /login
Content-Type: application/json
{
"email": "[email protected]",
"password": "SecurePass123"
}
Response:
{
"message": "Login successful",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbG...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbG...",
"email": "[email protected]"
}
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 |
Backend:
cd server
pytest
Frontend:
cd client
npm test
Frontend:
cd client
npm run lint
Frontend:
cd client
npm run build
crypto-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:27017
If you see CORS errors in the browser console:
If containers fail to start:
Check logs:
docker-compose logs
Rebuild containers:
docker-compose down
docker-compose build --no-cache
docker-compose up
git checkout -b feature/improvement)git commit -am 'Add new feature')git push origin feature/improvement)This project is licensed under the Apache License 2.0. See the LICENSE file for details.
For issues and questions: