Skip to Content
DevelopmentBackendGetting Started

Getting Started with Rhesis Backend

This guide will help you set up and run the Rhesis backend on your local machine for development purposes.

Prerequisites

Before you begin, make sure you have the following installed:

  • Python 3.10 or higher
  • PostgreSQL 13 or higher
  • UV  package installer
  • Git

Clone the Repository

clone-repo.sh
git clone 
cd rhesis

Environment Setup

  1. Navigate to the backend directory:
navigate.sh
cd apps/backend
  1. Create a Python virtual environment:
create-venv.sh
python -m venv .venv
  1. Activate the virtual environment:

On Linux/macOS:

activate-venv-unix.sh
source .venv/bin/activate

On Windows:

activate-venv-windows.sh
.venvScriptsactivate
  1. Install dependencies using UV:
install-deps.sh
uv pip install -e .

Database Setup

  1. Create a PostgreSQL database:
create-db.sh
createdb rhesis
  1. Create a .env file based on the provided template:
setup-env.sh
cp .env.example .env
  1. Update the database connection string in .env:
.env
SQLALCHEMY_DATABASE_URL=postgresql://username:password@localhost:5432/rhesis
  1. Run database migrations:
migrate-db.sh
alembic upgrade head

Running the Application

  1. Start the FastAPI server:
start-server.sh
uvicorn rhesis.backend.app.main:app --reload

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

  1. Open the API documentation:

Running Background Tasks

  1. Start a Celery worker:
start-celery.sh
celery -A rhesis.backend.worker worker --loglevel=info

Development Workflow

Code Formatting

Format code using ruff:

format-code.sh
uv run --all-groups ruff format .

Linting

Run the linter:

lint-check.sh
uv run --all-groups ruff check .

Fix linting issues automatically:

lint-fix.sh
uv run --all-groups ruff check --fix .

Running Tests

Run the test suite:

pytest

Authentication Setup

For local development, you can use Auth0 or set up a mock authentication system.

Auth0 Configuration

  1. Create an Auth0 application at https://auth0.com/ 
  2. Update the Auth0 configuration in your .env file:
AUTH0_DOMAIN=your-domain.auth0.com AUTH0_AUDIENCE=your-audience AUTH0_CLIENT_ID=your-client-id AUTH0_CLIENT_SECRET=your-client-secret AUTH0_SECRET_KEY=your-secret-key

API Endpoints

Once the application is running, you can explore the available endpoints through the Swagger UI at http://localhost:8000/docs .

Next Steps

Now that you have the backend running, you can:

  1. Create your first organization and user
  2. Explore the API endpoints
  3. Set up the frontend application to interact with the backend
  4. Start developing new features

For more detailed information about the backend architecture and components, refer to the other documentation files in this directory.