This project consists of a web application that allows users to set alerts for cryptocurrency prices. The application uses Streamlit for the frontend and Flask for the backend. It also integrates with the CoinGecko API to fetch real-time cryptocurrency prices and Redis for storing alerts.
-
Streamlit App: A user interface to set alerts for cryptocurrency prices and view price charts.
-
Flask API: A RESTful API to manage alerts and fetch cryptocurrency prices.
-
CoinGecko Integration: Fetch real-time cryptocurrency prices.
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/paritosh921/crypto-alert-app.git cd crypto-alert-app
-
Create the
requirements.txt
file:flask streamlit requests redis pandas numpy matplotlib
-
Create the Dockerfile:
# Use an official Python image as the base FROM python:3.9-slim # Set the working directory in the container WORKDIR /app # Copy the requirements file COPY requirements.txt . # Install the dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the app code COPY app.py . COPY api.py . # Make ports available to the world outside this container EXPOSE 8501 EXPOSE 5000 # Run the Flask API and Streamlit app when the container launches CMD ["sh", "-c", "python api.py & streamlit run app.py"]
-
Create the
docker-compose.yml
file:version: '3.7' services: redis: image: "redis:alpine" container_name: "redis" ports: - "6379:6379" app: build: . container_name: "crypto-alert-app" ports: - "8501:8501" - "5000:5000" depends_on: - redis environment: - REDIS_HOST=redis - REDIS_PORT=6379
-
Build and run the Docker containers:
docker-compose up --build
-
Access the Streamlit app:
Open your browser and go to
http://localhost:8501
. -
Access the Flask API:
The API will be running at
http://localhost:5000
.
- Select a cryptocurrency (Bitcoin, Ethereum, Ripple).
- View the current price fetched from the CoinGecko API.
- Enter the price at which you want to receive an alert.
- Enter your email address.
- Click on "Set Alert" to save the alert.
-
Create Alert:
curl -X POST http://localhost:5000/alerts/create/ -H "Content-Type: application/json" -d '{"coin": "bitcoin", "price": 30000, "email": "user@example.com", "status": "created"}'
-
Get Alerts:
curl -X GET http://localhost:5000/alerts/
-
Delete Alert:
curl -X DELETE http://localhost:5000/alerts/delete/ -H "Content-Type: application/json" -d '{"coin": "bitcoin", "price": 30000, "email": "user@example.com"}'
-
Get Price:
curl -X GET http://localhost:5000/price/bitcoin/
crypto-alert-app/
│
├── app.py # Streamlit app code
├── api.py # Flask API code
├── requirements.txt # Python dependencies
├── Dockerfile # Dockerfile for building the image
└── docker-compose.yml # Docker Compose configuration
If you would like to contribute, please open a pull request or issue on GitHub.