This repository contains both the backend and frontend for the daelibs interview project.
This project uses an sqlite3 database which is included in the repo (so you don't have to run migrate).
The code is in two main parts:
- The
daelibs_interview
project, which configures and runs the Django server. - The
main
app, which contains the traffic API.
Getting it running:
- Ensure Python 3.10 or higher
- Create Python virtualenv and install requirements from
requirements.txt
- Start your local server
Latest version can be downloaded from:
https://www.python.org/downloads/
Ensure it is added to your path.
To create a virtualenv,
python -m venv daelibs-interview
This will create a folder call 'daelibs-interview', then you will need to activate the environment.
On Windows, run:
daelibs-interview\Scripts\activate.bat
On Unix or MacOS, run:
source daelibs-interview/bin/activate
The virtual environment will be activated and you’ll see "daelibs-interview" next to the command prompt to designate that
Once done, you should cd to the dummy project root directory and run:
pip install -r requirements.txt
The main
app contains a test suite that can be run using the Django test runner.
There is a script that sets up the test environment and runs the tests:
./run_tests.sh
You may need to make the script executable by running:
chmod +x run_tests.sh
If you prefer to run the tests via the Django test runner, you can do so by running:
export DJANGO_SETTINGS_MODULE=daelibs_interview.settings.test; python manage.py test
You should now be able to run the local server:
python manage.py runserver
Once the server is running, you can query the API by visiting:
http://localhost:8000/traffic/dayOfWeekAverageCount?start_date=2023-07-07&end_date=2023-07-14
If you enter an invalid date, you will receive a 400 response with a message indicating the error. For example, if your end date is prior to the start date:
http://localhost:8000/traffic/dayOfWeekAverageCount?start_date=2023-07-07&end_date=2023-07-06
The frontend is built with Vue 3. It is a single page that displays the ScoreList component. This component is a table that displays the scores of the users, based on the design from the Figma project. The scores are fetched from the backend, which is just hard-coded in this example.
Install Node
and npm
if you haven't already. You can download them from:
https://nodejs.org/en/download/
Then, move into the frontend directory and install the dependencies:
cd daelibs-frontend
npm install
npm run serve
Once the server is running, you can access the frontend at http://localhost:8080/
.