This project is a REST API that provides endpoints for Collabforecast market sessions and user management / authentication. It is built using Django Rest Framework.
The following directory structure should be considered:
. # Current directory
├── api # main configs
├── authentication # authentication endpoints
├── files # system files (logging, db backups)
├── data # data ops endpoints
├── market # market participation endpoints
├── users # users endpoints
pip install poetry
oetry install
poetry shell
NOTE: If you're already working in a virtual environment (e.g., conda or pyenv), you can skip the
poetry shell
command.
In the same directory, create a .dev.env
file with environment variables used to debug and update default environment variables to your specifics.
cp dotenv .dev.env
Important: Ensure you force develop mode by using the following environment variable DJANGO_APPLICATION_ENVIRONMENT=develop
and POSTGRES_HOST=localhost
Then, initialize the service Postgres DB:
# Execute on the project root:
docker compose -f docker-compose.dev.yml up -d
Once your DB is up, you can debug locally by just by uncommenting the following lines in the manage.py
file:
from dotenv import load_dotenv
load_dotenv(".dev.env")
After this, you can easily run your application without docker container, in either an IDE or straight from the command line.
python manage.py migrate
python manage.py createadmin
# This will start the Django development server (do not use this in production):
python manage.py runserver
By default the API will be available at http://127.0.0.1:8000
. If you want to change either HOST or PORT references, please update the SWAGGER_BASE_URL
environment variable in the .dev.env
file.
You can test if the API is running with a simple HTTP GET request (e.g., using CURL)
curl http://127.0.0.1:8000/api/v1/health/
Default URLs:
Swagger http://127.0.0.1:8000/swagger