Skip to Content
ContributeBackendGetting Started

Getting Started with Rhesis Backend

Set up and run the backend locally for development.

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 <repository_url>
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:

run-tests.sh
pytest

Authentication Setup

For local development, Quick Start mode provides automatic authentication bypass. For production-like setup, configure the authentication system:

Authentication Configuration

Update the authentication settings in your .env file:

.env
# JWT Configuration (required)
JWT_SECRET_KEY=your-jwt-secret-key
JWT_ALGORITHM=HS256
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=15

# OAuth Providers (optional - enables social login)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GH_CLIENT_ID=your-github-client-id
GH_CLIENT_SECRET=your-github-client-secret

API Endpoints

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

Next Steps