Make sure to change into the client
directory before executing commands.
- Installing the dependencies
npm i
- Run the project as a development server
npm run dev
- Build the project
npm run build
- Deploy the
dist
folder to a web server or container.
This is recommended to avoid issues with differing versions of packages in project and local environment. In addition, this avoids bloat not necessary for the project being added when freezing requirements.
- If you don't have python3.10-venv already, install it
- On Ubuntu:
sudo apt install python3-venv
- On Ubuntu:
- Create a venv
- On Ubuntu:
python3 -m venv venv
(or whatever else you want to name your venv)
- On Ubuntu:
- Enter your venv
- On Ubuntu:
source venv/bin/activate
- On Ubuntu:
-
Download PostgreSQL
-
Create a database
-
Create a .env file in the root folder using this format:
DJANGO_SECRET_KEY="your_django_secret_key"
DJANGO_DEBUG="True"
DB_NAME="your_database_name"
DB_USER="postgres"
DB_PASSWORD="your_database_password"
DB_HOST="localhost"
DB_PORT="5432""
VITE_API_BASE_URL="http://localhost:8000"
Insert database name, password and django secret key.
- Open the folder where you have this project
- Open the
server
folder - Install the requirements by running
pip install -r requirements.txt
- Open the
server
folder - Run
python3 -m server
- Verify that websocket is running
- Open the
server/server_comm
- Run
python3 manage.py migrate
- Run
python3 manage.py runserver
Same step as for running backend without docker
-
Download PostgreSQL
-
Create a database
-
Create a .env in root of project and insert the following:
DATABASE_URL=postgres://admin:admin@db:5432/kundestyrt_db
DJANGO_SECRET_KEY=[add key]
DJANGO_DEBUG='True'
DB_NAME='kundestyrt_db'
DB_USER='admin'
DB_PASSWORD='admin'
DB_HOST='db'
DB_PORT='5432'
VITE_API_BASE_URL='http://localhost:8000'
Download and open Docker
In root folder of project run docker-compose up --build
If you have added new pip packages to the project and want to save them for everyone to use, when in your venv (ensure that you are in the venv so you don't freeze unnecessary packages), run the following command in the server folder: pip freeze > requirements.txt
The application has implemented swagger. View the API documentation at http://localhost:8000/swagger/
after running the server.
pytest automatically looks for files that match the pattern test_*.py
or *_test.py
and within those files finds functions that begin with test
. To create new tests, follow this pattern and create your file in the server/tests
folder.
By default, all test functions run the start_server()
fixture found in the conftest.py
file to set up the server at the beginning of each test function. If you want to add more setup to your tests, you can do so by using @pytest.fixture
decorator.
You can also add a scope
argument to your fixture, like this @pytest.fixture(scope="function")
, to define when you want to run this setup function (e.g. for each function (function
)), for each test file (module
), etc.).
To run all tests, run pytest server/tests
. To run a specific test, run pytest server/tests/test.py
.