End-to-end cryptocurrency price tracking system: API → SQL Server → Streamlit UI + Docker
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ CoinGecko ────▶ SQL Server ────▶ Streamlit │
│ API │ │ Database │ │ Web UI │
└──────────────┘ └──────────────┘ └──────────────┘
Data Flow:
- CoinGecko API → datacollector → SQL Server (write: inserts BTC price every 30s)
- SQL Server → Streamlit Web UI (read: queries Bitcoin table on button click)
| Service | Description | Port |
|---|---|---|
sqlServer |
Microsoft SQL Server 2019 | 1434 (host) → 1433 (container) |
datacollector |
Fetches BTC price from CoinGecko, stores in SQL Server | — |
webinterface |
Streamlit dashboard for visualization | 8501 |
- Docker & Docker Compose
# Copy example env file and set your password
cp .env.example .env
# Edit .env and set SA_PASSWORD
docker-compose up --build -dOpen your browser at: http://localhost:8501
Click "Fetch Bitcoin Prices" to load and visualize the data.
You can connect directly to the database using any SQL client (Azure Data Studio, SSMS, DBeaver, etc.):
| Parameter | Value |
|---|---|
| Server name | localhost,1434 |
| Login | sa |
| Password | Value of SA_PASSWORD from your .env file |
| Database | Cryptocurrency |
The datacollector service automatically creates:
CREATE DATABASE Cryptocurrency;
CREATE TABLE Bitcoin (
DateTime datetime NOT NULL DEFAULT GETUTCDATE(),
Price decimal(18, 8) NOT NULL
);- DateTime: Stored in Pacific Time (converted from UTC)
- Price: BTC price in USD
- Insert frequency: Every 30 seconds
BTC_Price_Tracker/
├── docker-compose.yaml # Orchestrates all services
├── .dockerignore # Excludes unnecessary files from Docker builds
├── .gitignore # Excludes cache, env, IDE files from git
├── datacollector/
│ ├── Dockerfile # Python + ODBC driver for SQL Server
│ ├── requirements.txt # requests, pyodbc
│ └── dataCollector.py # Fetches BTC price, writes to SQL Server
└── webinterface/
├── Dockerfile # Python + ODBC driver + Streamlit
├── requirements.txt # pyodbc, streamlit, pandas, altair
└── sqlToWeb.py # Streamlit app: reads DB, shows charts
docker-compose downTo remove volumes (database data):
docker-compose down -vView service logs:
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f datacollector
docker-compose logs -f webinterface
docker-compose logs -f sqlServerCreate a .env file from the example:
cp .env.example .envEdit .env and set a strong password:
SA_PASSWORD=your_strong_password_hereThis single variable is used by:
- SQL Server (
MSSQL_SA_PASSWORD) - sets thesaaccount password - datacollector (
SQL_PASSWORD) - connects to write price data - webinterface (
SQL_PASSWORD) - connects to read price data
The docker-compose.yaml references ${SA_PASSWORD} and passes it to all three services.
- The
datacollectorwaits ~19 seconds on startup for SQL Server to be ready - CoinGecko API has rate limits (429 responses are handled with 60s backoff)
- Data persists in the
sql-volumeDocker volume across restarts - The web UI uses Altair for interactive charts with proper y-axis scaling
If you like this project, please give it a ⭐️!