Skip to content

Latest commit

 

History

History
215 lines (144 loc) · 4.1 KB

File metadata and controls

215 lines (144 loc) · 4.1 KB

Contributing Guide

Prerequisites

  • Node.js 20 LTS or higher
  • npm or yarn
  • Git
  • Supabase account and project

Initial Setup

1. Clone the Repository

git clone <repository-url>
cd StepFi-API

2. Install Dependencies

npm install

3. Environment Configuration

Copy the example environment file:

cp .env.example .env

Edit .env and configure the following variables:

# ===========================================
# SUPABASE CONFIGURATION
# ===========================================

SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

# ===========================================
# PORT
# ===========================================

PORT=4000

4. Supabase Setup

This project uses Supabase remote instance only. You must have a Supabase project set up.

  1. Create or access your Supabase project at supabase.com

  2. Get your project credentials:

    • Go to your project → Settings → API
    • Copy the following:
      • Project URLSUPABASE_URL
      • anon public keySUPABASE_ANON_KEY
      • service_role secret keySUPABASE_SERVICE_ROLE_KEY
  3. Update your .env file with the credentials:

    SUPABASE_URL=https://your-project.supabase.co
    SUPABASE_ANON_KEY=your_anon_key_here
    SUPABASE_SERVICE_ROLE_KEY=your_service_role_key_here
  4. Access Supabase Dashboard: Go to your project dashboard on supabase.com

5. Database Migrations

Note: Migrations require Supabase CLI. Install it and login:

npm install -g supabase
supabase login

Link Your Project

supabase link --project-ref your-project-ref

You can find your project ref in your Supabase project settings.

Create a New Migration

supabase migration new migration_name

This creates a new file in supabase/migrations/ with timestamp format: YYYYMMDDHHMMSS_migration_name.sql

Apply Migrations to Remote

supabase db push

This applies migrations to your remote Supabase project.

Revert a Migration

supabase migration repair --status reverted migration_name

6. Redis Setup

If you need Redis for local development:

Using Docker

docker run -d -p 6379:6379 redis:7

Using Homebrew (macOS)

brew install redis
brew services start redis

7. Run the Application

Development Mode

npm run start:dev

The API will be available at http://localhost:4000

Production Build

npm run build
npm run start:prod

Development Workflow

Running Tests

# Unit tests
npm run test

# Watch mode
npm run test:watch

# E2E tests
npm run test:e2e

# Coverage
npm run test:cov

Code Quality

# Lint
npm run lint

# Format
npm run format

Project Structure

See Architecture Documentation for detailed information about the project structure.

Standards and Conventions

Please review the following documents before contributing:

Common Issues

Supabase Connection Error

  • Verify credentials in .env match your Supabase project settings
  • Check that your Supabase project is active
  • Ensure you're using the correct project URL and keys
  • Verify your project is linked: supabase link --project-ref your-project-ref

Redis Connection Error

  • Ensure Redis is running: redis-cli ping
  • Verify REDIS_HOST and REDIS_PORT in .env

Port Already in Use

  • Change PORT in .env to a different port
  • Or kill the process using port 4000

Getting Help

  • Check existing documentation in docs/
  • Review code examples in the codebase
  • Open an issue for questions or problems