-
Notifications
You must be signed in to change notification settings - Fork 0
Project Setup
Warning
This page is legacy / archived and may be outdated. It is preserved for historical context only and is not the source of truth for current operations.
Use current documentation instead:
You can also start from Archive / Legacy Index.
Recommended Python Version: Python >= 3.12
It is highly recommended to use Python 3.12 or newer for this project.
Follow these steps to set up your development infrastructure:
-
Install Docker:
- It is recommended to use Docker natively within the WSL (Ubuntu(. To install Docker this way, follow this Gist. Alternatively, follow the official installation guide for your operating system: Install Docker Desktop (Windows link provided, adapt for macOS/Linux if necessary).
-
Install uv (Python Package Installer):
- Install
uvusing the Standalone Installer method: uv Installation Guide.
- Install
-
Install Yarn (JavaScript Package Manager):
- Download Yarn: Yarn v1.22.4 MSI (Windows)
- For installation guidance, especially on Windows: Yarn Installation Guide (Windows).
-
Python Backend Environment Setup:
-
Navigate to your project's backend directory and use
uvto sync dependencies (and optional dependencies if required):cd /your/project/root/backend uv sync uv sync --extra dev -
Important: Do not create the
.venvusing your IDE's automatic virtual environment creation tools.uv syncwill handle this and create a.venvdirectory inside/your/project/root/backend. -
IDE Configuration (after
uv sync):-
PyCharm:
- Open your project settings to configure the Python interpreter.
- Set a new interpreter (or modify an existing one) and select
existing environment. - Point to the Python executable within the
.venvdirectory created byuv(e.g.,/your/project/root/backend/.venv/bin/pythonon Linux/macOS or/your/project/root/backend/.venv/Scripts/python.exeon Windows). Typically, PyCharm selects and existing.venvautomatically. - Choose "Select Existing Interpreter" or the equivalent option.
-
Alternative (Symbolic Link):
To make the backend's virtual environment more accessible to tools or IDEs that expect a
.venvin the project root, you can create a symbolic link.-
Linux/macOS:
Example for a project named
# Ensure you are in your project root: /your/project/root/ # Replace /your/project/root/ with the actual absolute path to your project ln -s ./backend/.venv ./.venv
off-keyin your home directory:# cd ~/off-key # ln -s ./backend/.venv ./.venv
-
Windows (Command Prompt as Administrator):
Navigate to your project root (
/your/project/root/) in an Administrator Command Prompt, then run:mklink /D .venv backend\.venv
-
Linux/macOS:
-
PyCharm:
-
-
Navigate to the Frontend Directory:
cd /your/project/root/frontend # Or, if you are in the project root: # cd frontend
-
Install Dependencies: Use Yarn to install the dependencies defined in
package.json:yarn install
(Alternatively, you can often just run
yarn)
The different components of the application can be accessed after docker-compose up --build.
Keep in mind that Docker Desktop needs to be running for interacting with Docker.
- Access the
backend(APIs) underhttp://localhost:8000/- Access the API documentation under
http://localhost:8000/docs
- Access the API documentation under
- Access the
frontend(UI) underhttp://localhost:5173/
This guide outlines the steps to set up pre-commit hooks for this project in a new local development environment. Pre-commit hooks help ensure code quality and consistency by running checks before you commit your changes.
We use uv for managing Python environments and dependencies, and pre-commit for managing git hooks.
- Git: Ensure Git is installed on your system.
-
uv: Ensure
uvis installed. If not, you can find installation instructions at https://github.com/astral-sh/uv. - Project Code: You should have the project code cloned to your local machine.
Follow these steps to install the necessary dependencies and activate the pre-commit hooks:
-
Navigate into the
./backend/directory. This is where the project's Python package and its mainpyproject.tomlare located.cd backend -
Install project dependencies and development dependencies. This command installs the main project dependencies and the development tools (like linters, formatters, and
pre-commititself) defined inpyproject.toml.uv pip install . uv pip install .[dev]-
uv pip install .installs the core dependencies of theoff-keyproject. -
uv pip install .[dev]installs the optional dependencies specified under the[project.optional-dependencies.dev]section in thepyproject.tomlfile located in./backend/. This typically includespre-commit,black,ruff, etc.
-
-
Install the pre-commit hooks. This command installs the git hooks defined in the
.pre-commit-config.ymlfile located in the project's root directory. It configures your local git repository to run the defined checks automatically before each commit.uv run pre-commit install --config ../.pre-commit-config.yml
-
uv run pre-commitexecutes thepre-committool within the environment managed byuv. -
installis thepre-commitcommand to set up the hooks. -
--config ../.pre-commit-config.ymlspecifies the path to the pre-commit configuration file, which is in the parent directory (the project root) relative to the./backend/directory.
-
Once installed, the pre-commit hooks will run automatically whenever you attempt to make a new commit using git commit.
- If any of the pre-commit checks fail (e.g., a linter finds an issue or a formatter needs to change a file), the commit will be aborted.
- You'll see output from the failing hook indicating what went wrong.
- Some hooks (like code formatters) might automatically fix the issues. If they do, you'll need to
git addthe modified files again and then re-attempt the commit. - For other issues, you'll need to manually fix them before you can successfully commit.
Occasionally, the pre-commit hook definitions or the tools they use might be updated. To update your local hooks to the latest versions defined in .pre-commit-config.yml, you can run:
# Navigate to the ./backend/ directory if you are not already there
cd path/to/your/project/backend/
# Then run the pre-commit update command
uv run pre-commit autoupdate --config ../.pre-commit-config.yml