35 - Development & Testing Guide

Overview

This guide covers running OpenAlgo in development and production modes using the uv package manager, along with comprehensive testing strategies including unit tests, E2E tests, accessibility tests, and linting.

Running the Application

Development Mode

# Navigate to project directory
cd /path/to/openalgo

# Copy environment file (first time only)
cp .sample.env .env

# Generate secure keys
uv run python -c "import secrets; print(secrets.token_hex(32))"
# Copy output to APP_KEY and API_KEY_PEPPER in .env

# Run in development mode
uv run app.py

Development Features:

  • Auto-reload on code changes

  • Debug mode enabled (if FLASK_DEBUG=True)

  • Detailed error messages

  • SocketIO development server

Production Mode (Linux with Gunicorn)

Production Configuration:

Docker Mode

Frontend Development (React)

Setup

Development Server

Build for Production

Testing Architecture

Unit Testing (Vitest)

Running Tests

Test File Structure

Example Test

E2E Testing (Playwright)

Running E2E Tests

E2E Test Structure

Example E2E Test

Accessibility Testing (axe-core)

Running A11y Tests

A11y Test Libraries

Library
Purpose

@axe-core/react

Runtime a11y checking in dev

@axe-core/playwright

E2E a11y testing

jest-axe

Unit test a11y assertions

vitest-axe

Vitest a11y matchers

Example A11y Test

Playwright A11y Test

Linting & Formatting (Biome)

Running Biome

Biome Configuration

Location: frontend/biome.json

Biome vs ESLint/Prettier

Feature
Biome
ESLint + Prettier

Speed

10-100x faster

Slower

Config

Single file

Multiple configs

Memory

Low

Higher

Setup

Zero config

Complex setup

Backend Testing (Python)

Running Backend Tests

Test Structure

CI/CD Pipeline Example

Command Reference

Backend Commands

Command
Description

uv run app.py

Start development server

uv run pytest test/ -v

Run all tests

uv add package_name

Add new dependency

uv sync

Sync dependencies

Frontend Commands

Command
Description

npm run dev

Start dev server

npm run build

Production build

npm test

Run unit tests

npm run e2e

Run E2E tests

npm run test:a11y

Run accessibility tests

npm run lint

Lint code

npm run format

Format code

npm run check

Lint + format

Key Files Reference

File
Purpose

frontend/package.json

Frontend scripts and dependencies

frontend/vitest.config.ts

Unit test configuration

frontend/playwright.config.ts

E2E test configuration

frontend/biome.json

Linting/formatting rules

pyproject.toml

Python dependencies

test/

Backend test files

Last updated