For the easiest and most consistent development experience, use Docker Compose. This will start all required services (database, redis, Django web server in debug mode, Celery worker/beat, websocket, nginx) with live code reload and all dependencies preconfigured.
Quick Start:
- Ensure Docker and Docker Compose are installed.
- Copy
example.envto.envin the arkad folder. - From the project root, run:
docker compose -f compose.yaml up --build
- Migrate with:
docker compose -f compose.yaml exec web python manage.py migrate - Your code changes in the arkad folder will be reflected immediately (thanks to volume mounting).
- Access the API docs at http://127.0.0.1:8000/api/docs.
For advanced usage or troubleshooting, the manual setup instructions are provided below.
You must use Python 3.13 to run this project as we are using some very new typing features.
- Install Python 3.13
- Create a virtual environment (venv)
python3.13 -m venv venv - Activate the virtual environment
- On Windows:
venv\Scripts\activate(If using windows please use WSL, otherwise make commands will not work) - On Linux/Mac:
source venv/bin/activate
- On Windows:
- cd to the arkad folder
cd arkad.- This is where the django project is located.
- Install the required packages:
pip install -r requirements.txt - Create a public/private keypair for JWT signing
- With the names public.pem, private.pem, they should be in arkad/private folder
- This can be done with:
mkdir private openssl genpkey -algorithm RSA -out private/private.pem -pkeyopt rsa_keygen_bits:2048 openssl rsa -in private/private.pem -pubout -out private/public.pem
- Copy
example.envto.env(Both are in arkad folder)- This contains the default environment variables.
- Start the Postgres database if not running it locally.
- Start services (database, redis, web, celery worker, celery beat) using docker: from the
arkadfolder run:docker compose up
- Create migrations:
python manage.py makemigrations - Migrate the database:
python manage.py migrate - Create the cache database
python manage.py createcachetable - Run the server:
python manage.py runserveror if testing ws functionality use daphne: Start daphne withdaphne -p 8000 arkad.asgi:application - Open your browser and go to
http://127.0.0.1:8000/api/docsto see the API documentation.
- Celery beat scheduler (celery-beat)
- Start celery using
celery -A arkad worker -l infoif not using docker compose.
The API is documented at /api/docs
Required environment variables are:
- SECRET_KEY (Set this to a long secret value)
- DEBUG (Must be set to "False" in production)
- POSTGRES_PASSWORD (The postgres database password for the user arkad_db_user)
- Celery beat is used to schedule periodic tasks which can be created from the admin interface at /admin under "Periodic tasks".
- The tasks which are to be created must be defined in a tasks.py file in any app.
- The tasks must be decorated with
@shared_taskfrom celery. - There is an example task in arkad/arkad/celery.py.
- Uses Redis for broker and result backend.
- Two services run via compose:
celery-workerandcelery-beat. - Worker processes tasks; beat schedules periodic tasks.
- Run manually (outside compose):
Ran with:
docker compose up
- Define tasks in any app
tasks.py: When deploying you must set DEBUG environment value to False. Also make sure to set a secure secret key as it is otherwise possible to high-jack sessions. You should also set a good postgres password.
To create a superuser, first enter the running web container:
docker compose -f arkad/compose.yaml exec web bashThen, run the createsuperuser command and follow the prompts:
python manage.py createsuperuserTo create or apply database migrations, you first need to get a shell inside the running web container.
-
Enter the container:
docker compose -f arkad/compose.yaml exec web bash -
Create migrations: If you have made changes to your models, create new migration files. Because the
arkaddirectory is mounted as a volume, these new migration files will appear in your local project directory.python manage.py makemigrations
-
Apply migrations: To apply pending migrations to the database, run:
python manage.py migrate
It is possible to automatically update the database with new information about all companies.
For example jobs, if they have studentsessions etc.
This is done by running python manage.py jexpo_sync --file /path/to/jexpo.json
Jexpo information can also be uploaded via the admin page (this is useful primarily in production/staging).
Migrations files are excluded from ruff formatting and are only checked to be legal by mypy.
- app/migrations/*.py
Test files are excluded from typing rules but are required to be valid code and formatting is applied.
- tests/*
- */tests.py
api files are not required to have typed return values.
- */api.py
Run the linting by standing in arkad and writing make lint
Run tests using python manage.py test
When pushing linting and tests will be run automatically. And when a new commit is added to master it is auto deployed.
- To create a new app:
python manage.py startapp app_name - To create migrations:
python manage.py makemigrations: This will create migration files for any changes in models. - To migrate the database:
python manage.py migrate: This will apply the migrations to the database.
When creating new fields in models it is important to set a default value or allow null values. Otherwise, the migration will fail if there are existing rows in the database.
Adding fields to existing models is very simple in django, simply go to the model, for example class User(AbstractBaseUser)
And add the new field, for example:
push_token = models.CharField(max_length=255, blank=True, null=True)Django comes with an admin interface from where data can be edited, created or deleted. It is also possible to create new users and assign them to groups with different permissions.
An additional feature of the admin interface is that it is possible to create actions for each table. For example, it is possible to create an action to email all selected users.
Actions are created by defining a function and adding it to the actions list in the admin class.
For more information see the Django documentation.
It is also possible to create actions which take input, they can be seen here: Stack Overflow.
Student sessions have a release time and a close time. Student session applications have a closing time after which it is not possible to apply anymore.
The same applies for cancelling an application (as they will be sent to companies).
There is then an opening for applying to timeslots for student session, this also has a closing time after which you can not unbook.
Events have an time when they are made visible, a time when they are open for registration and a time when they are closed for registration.
They are possible to unbook until one week before the event.