REST API which allow adding, deleting, updating the car information, if it exists in external online catalogue. The car can be rated and all information can be viewed.
Serving static files is possible using NginX
and there is a /help
page with documented endpoints.
Database contain models of Cars and Ratings.
-
Car:
- make - make name, string field
- model - model name, string field
-
Rating:
- Car - car object foreign key relation, cascade delete
- value - rating value, integer field
New rating card will be created after each rate. This allows to easy remove or update posted rating.
- Catalogue:
- make - cached make
- available_models - cached models for a given make
My App can only add the car to database if it exists in API catalogue.
After the first successful check if model exist, for the specific make, it is saved to database.
That reduce time spending for requesting the same endpoint for the same data.
If later the same model will be added, instead of requesting car API, I check it in my database.
If the online car API would be changed, I would need to refresh the database status.
- django
- rest_framework
- django tests
- serializers
- SQLite
- requests
- random
- docker
- docker-compose
- AWS
- NginX
- UWSGI
App was deployed and maintained on AWS cloud services EC2:
ec2-54-246-230-82.eu-west-1.compute.amazonaws.com:8080
Pass this link without: https://
Page with all endpoints and documentation: help/
Variable | Description | Value |
---|---|---|
SECRET_KEY | Django secret key | sjdlkadsasndkjasdnkasdn |
ALLOWED_HOSTS | Host of this app | 0.0.0.0 |
git clone [email protected]:Filip-231/NG-CarApp.git
sudo docker-compose build
sudo docker-compose up
git clone [email protected]:Filip-231/NG-CarApp.git
sudo docker-compose -f docker-compose-deploy.yml build
sudo docker-compose -f docker-compose-deploy.yml up
download docker-compose-deploy-from-dockerhub.yml
sudo docker-compose -f docker-compose-deploy-from-dockerhub.yml pull
sudo docker-compose -f docker-compose-deploy-from-dockerhub.yml up
App is using NginX as proxy. Images are pushed to docker hub:
python -m venv env
source env/bin/activate
cd App
pip install -r requirements.txt
python manage.py test myapp/ #for tests
python manage.py runserver
When run with python manage.py runserver
, add to file: app/myapi/settings.py
option DEBUG=1
to turn on debugging mode.
Using local configuration from docker-compose.yml, DEBUG=1
is exported to environment values.
Adding car to database.
{{URL}}cars/
Content-Type | Value |
---|---|
Content-Type | application/json |
{
"make":"bmw",
"model":"m2"
}
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Deleting car from database.
{{URL}}cars/21/
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Adding rating to car with id.
{{URL}}rate/
Content-Type | Value |
---|---|
Content-Type | application/json |
{
"car_id":24,
"rating":1
}
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
List every car in database with their current average rate.
{{URL}}cars/
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Get most popular cars in database
{{URL}}popular/
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Hello page.
{{URL}}
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Listing already downloaded catalogue.
{{URL}}raw/catalogue/
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
List all ratings in database.
{{URL}}rate/
Content-Type | Value |
---|---|
Content-Type | application/json |
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Help page with all queries.
{{URL}}help/
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β