Skip to main content

Prerequisites

Before you begin, ensure you have the following installed:

Node.js

v18.x or higher

Python

v3.11 or higher

PostgreSQL

v15+ (via Supabase)

Step 1: Clone the Repository

git clone https://github.com/risklegion/RL_BRA.git
cd RL_BRA

Step 2: Set Up Supabase

Create a Supabase Project

  1. Visit supabase.com and create a free account
  2. Create a new project
  3. Note your project URL and anon key

Run Database Migrations

# Install Supabase CLI
npm install -g supabase

# Link to your project
supabase link --project-ref your-project-ref

# Run migrations
supabase db push
The migrations will create all necessary tables, views, functions, and RLS policies.

Step 3: Configure Environment Variables

Frontend Environment

Create risk-legion-frontend/.env:
# Supabase Configuration
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key

# API Configuration
VITE_API_BASE_URL=http://localhost:8000

# Optional: Environment
VITE_ENV=development

Backend Environment

Create backend/.env:
# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
CORS_ORIGINS=http://localhost:8080,http://localhost:5173

# JWT Configuration (from Supabase project settings)
JWT_SECRET=your-jwt-secret

# Optional: Logging
LOG_LEVEL=INFO
Never commit .env files to version control. The service role key has admin privileges.

Step 4: Install Dependencies

Frontend

cd risk-legion-frontend
npm install

Backend

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Step 5: Start Development Servers

Terminal 1: Backend

cd backend
source venv/bin/activate
uvicorn app.main:app --reload --port 8000
You should see:
INFO:     Uvicorn running on http://127.0.0.1:8000
INFO:     Application startup complete.

Terminal 2: Frontend

cd risk-legion-frontend
npm run dev
You should see:
  VITE ready in XXX ms
  ➜  Local:   http://localhost:8080/

Step 6: Create Your First User

Option A: Using Supabase Dashboard

  1. Go to your Supabase project → Authentication → Users
  2. Click “Add user”
  3. Enter email and password
  4. Enable “Auto Confirm User”

Option B: Using Signup Flow

  1. Navigate to http://localhost:8080/auth
  2. Click “Sign Up”
  3. Enter your details
  4. Confirm email (if email confirmation enabled)

Step 7: Create an Enterprise

After signing in, you’ll need an enterprise to start using the platform.

Using SQL Editor

-- Create your first enterprise
INSERT INTO enterprises (name, country, status)
VALUES ('My Company', 'US', 'active')
RETURNING id;

-- Assign yourself to the enterprise as Client Admin
INSERT INTO enterprise_users (enterprise_id, user_id, role)
VALUES (
  'your-enterprise-id',
  auth.uid(),
  'admin'
);

Step 8: Verify Installation

Check API Health

curl http://localhost:8000/health
Expected response:
{
  "status": "healthy",
  "version": "1.0.0"
}

Check Frontend

Navigate to http://localhost:8080 and verify:
  • ✅ Login page loads
  • ✅ Can sign in
  • ✅ Dashboard appears
  • ✅ No console errors

Common Issues

Problem: Cannot connect to Supabase databaseSolution:
  • Verify SUPABASE_URL and SUPABASE_ANON_KEY are correct
  • Check your internet connection
  • Ensure Supabase project is not paused
Problem: Authentication errors when calling APISolution:
  • Ensure JWT_SECRET matches your Supabase project JWT secret
  • Check that JWT token hasn’t expired
  • Verify token format in Authorization header
Problem: Frontend cannot call backend APISolution:
  • Verify CORS_ORIGINS includes frontend URL
  • Check VITE_API_BASE_URL points to correct backend
  • Clear browser cache

Next Steps

1

Review Architecture

Understand how Risk Legion is built
2

Explore User Roles

Learn about different permission levels
3

Read API Documentation

Integrate with Risk Legion API
4

Deploy to Production

Set up production environment

Getting Help