Build a Real-Time Crypto Tracker with TimescaleDB
Build a Real-Time Crypto Tracker with TimescaleDB
Prerequisites
- Go 1.18+
- Node.js 18+ and npm/yarn
- Docker and Docker Compose
Getting Started
1. Start the Database
This starts TimescaleDB which is required for both the backend and frontend.
To stop the database:
2. Environment Variables
Both the backend and frontend use .env files. Configure them before running:
Backend (.env in root):
PGPASSWORD=password
PGUSER=postgres
PGDATABASE=timescale_db
PGHOST=127.0.0.1
PGPORT=5432
PGSSLMODE=disable
COIN_GECKO_API_KEY=<your-coingecko-api-key>
Frontend (.env in tiger-tracker-frontend/):
PGPASSWORD=password
PGUSER=postgres
PGDATABASE=timescale_db
PGHOST=127.0.0.1
PGPORT=5432
PGSSLMODE=disable
COIN_GECKO_API_KEY=<your-coingecko-api-key>
3. Run the Go Backend
The Go backend ingests crypto prices from the CoinGecko API and stores them in TimescaleDB every 30 seconds.
You should see output like:
Calling Coin Gecko API...
API Response as struct {...}
The backend will continue running in the foreground, periodically fetching and storing price data.
4. Run the Next.js Frontend
In a new terminal, navigate to the frontend directory and start the development server:
npm install # if you haven't already
npm run dev
The frontend will be available at http://localhost:3000
Architecture
- Backend (Go): Runs a continuous price ingestion process that fetches BTC, ETH, and SOL prices from CoinGecko and stores them in TimescaleDB
- Frontend (Next.js): Web UI that displays crypto price data stored in the database
- Database (TimescaleDB): Time-series database for storing historical price data