cs2investments

CS2 Investments - Item Tracker

A web application for tracking Counter Strike 2 items built with NextJS and Supabase.

Features

Schema

CS Items

Each item includes:

Investments

Each investment tracks:

Getting Started

Prerequisites

Setup

  1. Clone the repository
  2. Install dependencies
    bun install
    
  3. Create a .env.local file in the project root with your Supabase credentials:
    NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
    # Optional: CSFloat API key for fetching item prices
    NEXT_PUBLIC_CSFLOAT_API_KEY=your-csfloat-api-key
    
  4. Set up Supabase:

Option 1: Using the Supabase Dashboard

Option 2: Using Migrations

# Or using homebrew on macOS brew install supabase/tap/supabase

   
   - Link your local project to your Supabase project:
   ```bash
   supabase login
   supabase link --project-ref your-project-ref

Or, if you want to include the seed data:

   supabase db push --include-seed
  1. Run the development server:
    bun dev
    
  2. Open http://localhost:3000 in your browser

Database Migrations

This project uses Supabase migrations to manage the database schema. The migrations are located in the supabase/migrations directory.

Migration Files

Seed Data

The project includes a seed file (supabase/seed.sql) with example CS2 items to get you started.

Applying Migrations

To apply the migrations to your Supabase project, run:

supabase db push

To apply the migrations and seed data:

supabase db push --include-seed

Local Development with Supabase

For local development with Supabase, you can use the Supabase CLI:

# Start a local Supabase instance
supabase start

# Apply migrations to the local instance
supabase db reset

# Stop the local instance when done
supabase stop

Built With

CSFloat API Integration

This application integrates with the CSFloat API to fetch current market prices for CS2 items. The integration:

  1. Fetches listing data based on item parameters (def_index, paint_index, float values)
  2. Calculates average prices from multiple listings
  3. Displays pricing information in the item table

To use the CSFloat API features:

  1. Sign up at CSFloat and get an API key from your profile’s developer tab
  2. Add your API key to the .env.local file:
    NEXT_PUBLIC_CSFLOAT_API_KEY=your-csfloat-api-key
    

Note: Without an API key, price data will not be available or may be rate-limited.