Skip to main content

Installation Guide

This guide covers multiple installation methods for CryptoPulse, from local development to production-ready multi-instance deployments.

Prerequisites

Required Software

Node.js

Version 22 or higher required

pnpm

Package manager for local development

PostgreSQL

Version 16+ recommended

Redis

Version 7+ for coordination and throttling

Optional Software

  • Docker & Docker Compose: For containerized deployments
  • nginx: For load balancing multiple instances

External Services

You must have a CoinGecko API key. Sign up at coingecko.com/en/api. The free tier is sufficient for development.

Installation Methods

Local Development Setup

Perfect for development and testing without containers.
1

Install Dependencies

Ensure Node.js 22+ and pnpm are installed:
node --version  # Should be 22 or higher
pnpm --version
If pnpm isn’t installed:
npm install -g pnpm
2

Clone and Install

git clone <repository-url>
cd crypto-pulse
pnpm install
3

Set Up Local Services

You need PostgreSQL and Redis running locally. Using Docker:
# Start only PostgreSQL and Redis
docker compose -f docker-compose.local.yml up -d
Or install them natively:
brew install postgresql@16 redis
brew services start postgresql@16
brew services start redis

# Create database
createdb crypto_pulse
4

Configure Environment

Copy .env.example to .env and configure for localhost:
cp .env.example .env
Edit .env:
.env
PORT=3000

ADMIN_USER=admin
ADMIN_PASS=secret
JWT_SECRET=your-secure-secret-here
JWT_EXPIRES_IN=1h

# Use localhost for local development
DATABASE_URL=postgres://postgres:postgres@localhost:5432/crypto_pulse
REDIS_URL=redis://localhost:6379

THROTTLE_TTL_MS=60000
THROTTLE_GLOBAL_LIMIT=20
THROTTLE_LOGIN_LIMIT=5

COINGECKO_BASE_URL=https://api.coingecko.com
COINGECKO_API_KEY=your-api-key-here
COINGECKO_TIMEOUT_MS=3000

BATCH_WINDOW_MS=5000
BATCH_THRESHOLD=3
REQUEST_TIMEOUT_MS=8000

LOG_LEVEL=info
5

Run Development Server

pnpm run start:dev
The API will start with hot-reload enabled. Access:

Development Commands

# Run with hot-reload
pnpm run start:dev

# Build for production
pnpm run build

# Run production build
pnpm run start:prod

# Run tests
pnpm run test
pnpm run test:e2e
pnpm run test:cov  # with coverage

# Lint and format
pnpm run lint
pnpm run format
pnpm run check  # lint + format

Environment Variables Reference

Authentication

VariableRequiredDefaultDescription
ADMIN_USERYes-Username for /auth/login
ADMIN_PASSYes-Password for /auth/login
JWT_SECRETYes-Secret for signing JWT tokens
JWT_EXPIRES_INNo1hToken expiration (e.g., 1h, 30m, 7d)

Database & Cache

VariableRequiredDefaultDescription
DATABASE_URLYes-PostgreSQL connection string
REDIS_URLYes-Redis connection string

Rate Limiting

VariableRequiredDefaultDescription
THROTTLE_TTL_MSNo60000Throttle window duration in milliseconds
THROTTLE_GLOBAL_LIMITNo20Max requests per window (all endpoints)
THROTTLE_LOGIN_LIMITNo5Max login attempts per window

CoinGecko Integration

VariableRequiredDefaultDescription
COINGECKO_API_KEYYes-Your CoinGecko API key
COINGECKO_BASE_URLNohttps://api.coingecko.comCoinGecko API base URL
COINGECKO_TIMEOUT_MSNo3000Upstream request timeout

Batching Configuration

VariableRequiredDefaultDescription
BATCH_WINDOW_MSNo5000Max time to wait before flushing batch
BATCH_THRESHOLDNo3Number of requests to trigger early flush
REQUEST_TIMEOUT_MSNo8000Max wait time per client request

Application

VariableRequiredDefaultDescription
PORTNo3000HTTP server port
LOG_LEVELNoinfoWinston log level (error, warn, info, debug)

Database Setup

Automatic Migration

TypeORM automatically creates tables on first startup. No manual migration needed.

Manual Database Access

# Connect to PostgreSQL in Docker
docker compose exec postgres psql -U postgres -d crypto_pulse
Useful queries:
-- View all price records
SELECT * FROM price_snapshot ORDER BY fetched_at DESC LIMIT 10;

-- Count records per coin
SELECT coin_id, COUNT(*) as count 
FROM price_snapshot 
GROUP BY coin_id;

-- Clear all data
TRUNCATE TABLE price_snapshot;

Verification

After installation, verify everything works:
1

Check Service Health

curl http://localhost:3000/docs
Should return the Swagger HTML page.
2

Test Authentication

curl -X POST http://localhost:3000/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"secret"}'
Should return a JWT token.
3

Test Price Endpoint

TOKEN="your-token-here"
curl http://localhost:3000/v1/price/bitcoin \
  -H "Authorization: Bearer $TOKEN"
Should return Bitcoin’s current price.

Troubleshooting

Change the PORT in .env to something else like 3001, then restart.
Verify PostgreSQL is running:
# Docker
docker compose ps postgres

# Local
pg_isready -h localhost -p 5432
Check the DATABASE_URL format and credentials.
Verify Redis is running:
# Docker
docker compose ps redis

# Local
redis-cli ping  # Should return PONG
If tables don’t auto-create, check database permissions:
GRANT ALL PRIVILEGES ON DATABASE crypto_pulse TO postgres;
Verify your API key is valid and has not exceeded rate limits. Check CoinGecko API status.

Next Steps

Quickstart

Follow the quickstart guide to make your first API calls

Configuration

Learn how to customize batching, throttling, and more

API Reference

Explore all available endpoints and parameters

Deployment

Production deployment best practices and scaling

Build docs developers (and LLMs) love