You can find the development documentation on the website.
Check out the Postman docs, Swagger or Redoc.
For Cursor IDE users, check the docs.md file which contains documentation links that can be accessed using the @docs
symbol.
The documentation is divided into several sections:
Choose one of the following methods to set up your development environment. Codespaces or a Local Dev Container are recommended for consistency.
This is the easiest way to get started, especially if you have a less powerful machine or want to avoid local setup complexities. GitHub Codespaces provides a fully configured cloud-based development environment, accessible directly through your browser or via VS Code/Cursor.
- Navigate to the main page of the repository on GitHub.
- Click the
Code
button. - Go to the
Codespaces
tab. - Click
Create codespace on main
(or your desired branch).
GitHub will set up the environment based on the .devcontainer
configuration in the repository. Once ready, you'll have VS Code/Cursor running in your browser (or connected locally) with all dependencies and tools installed.
Important Note: Due to potential timing issues with Codespaces setup (postStartCommand
), the background services (like the database) might not start automatically. After your Codespace has loaded, open a terminal and run docker compose up -d redis postgres
(or simply docker compose up -d
to ensure all services defined in the compose file are running) to ensure the necessary services are available before running the API.
If you find that the default Codespace machine type is too slow or you need more resources (CPU, RAM, Storage), you can change it:
- When creating a new Codespace: Before clicking "Create codespace", click on the three dots (...) next to the button or the "Advanced options" link (the UI may vary slightly). This will allow you to select a more powerful machine type.
- For an existing Codespace: You can change the machine type for an existing Codespace. Go to your list of Codespaces on GitHub (github.com/codespaces). Click the three dots (...) next to the Codespace you want to change, select "Change machine type", and choose a new one. The Codespace will then need to be reopened or rebuilt to apply the changes.
Using a more powerful machine type may incur higher costs if you are outside of the free tier for GitHub Codespaces.
If you prefer to work locally, have a reasonably powerful machine, and want the same consistent environment as Codespaces, you can use VS Code/Cursor Dev Containers.
Prerequisites:
- Docker Desktop: Install Docker Desktop for your operating system.
- VS Code or Cursor: Install Visual Studio Code or Cursor.
- Install the Dev Containers Extension: You must install the official Dev Containers extension from the marketplace in VS Code/Cursor.
Windows Users (Important):
- You MUST use WSL 2 (Windows Subsystem for Linux). Dev Containers rely on a Linux environment.
- Install WSL: Follow the official Microsoft guide to install WSL. We recommend installing the Ubuntu distribution when prompted.
- Configure Docker Desktop: Ensure Docker Desktop is configured to use the WSL 2 backend. Go to Docker Desktop settings -> Resources -> WSL Integration and enable it for your chosen distribution (e.g., Ubuntu).
- Clone Project in WSL: Clone this repository inside your WSL environment (e.g., in
/home/<your-username>/dev/apiv2
within Ubuntu), not on your Windows C: drive. You can access the WSL terminal by typingwsl
orubuntu
in your Windows Terminal or Command Prompt.
Steps to Launch:
- Clone this repository to your local machine (inside WSL if on Windows).
- Open the cloned repository folder in VS Code or Cursor (
code .
orcursor .
from the terminal inside the project directory). - Your editor should automatically detect the
.devcontainer
configuration and prompt you to "Reopen in Container". Click it. - If it doesn't prompt, open the command palette (
Ctrl+Shift+P
orCmd+Shift+P
) and runDev Containers: Reopen in Container
.
VS Code or Cursor will build the Docker image (if not already built) and start the container. Your VS Code or Cursor window will then be connected to the containerized environment, complete with all dependencies.
The following custom commands are defined in pyproject.toml
under [tool.poetry.scripts]
and can be run using poetry run <command>
:
dev
: (Legacy or specific development task - checkscripts/cmd.py
for details)start
: Starts the Django development server.createsuperuser
: Runs Django'screatesuperuser
management command.test
: Runspytest
for the specified path/module.test:ci
: Runs tests with coverage specifically for CI environments (likely includes parallel execution).test:coverage
/test:c
: Runs tests with coverage reporting for the specified module.test:parallel
/test:p
: Runs tests in parallel usingpytest-xdist
for the specified path/module.startapp
: Runs Django'sstartapp
management command to create a new app structure.migrate
: Runs Django'smigrate
management command to apply database migrations.makemigrations
: Runs Django'smakemigrations
management command to create new migration files based on model changes.format
: Formats the code using tools likeblack
andisort
.celery
: Starts a Celery worker.docs
: Serves the documentation locally usingmkdocs serve
.docs:build
: Builds the static documentation site usingmkdocs build
.docs:deploy
: Deploys the documentation (likely to GitHub Pages) usingmkdocs gh-deploy
.lint
: Runs linters (likeflake8
) over the codebase.update-sql-keywords
: Updates a JSON file containing SQL keywords (utility script).precommit:install
: Installs pre-commit hooks.docker:build
: Builds the Docker image for the application.