/fictional-demo-api

A API made in Django

Primary LanguagePython

Fictional Motor CO system

In this document we will explain how to setup the project and work with it.

  • Set up the Docker environment
  • Launch the backend
  • Make API calls using Postman
  • Launch tests per type (unitary and non=unitary)

Also, we will introduce the ___ documentation we've build for this project

For the implementation we will combine:

  • API Model View Controller (MVC) (or MVVM Model View ViewModel)
    • Where Views are the endpoints
  • HTTP REST, especially
    • We also consider HATEOAS, #TODO json:api hyperlink but we will not implement a Level 4 maturity REST API for this prototype
  • Domain Driven Design to some degree, it is not advisable to fight the framework architecture, but we will split some domain and infrastructure out of the framework artifacts that are bound to be separated in to transversal code - specifications, common constants and libraries

Structure

. ├── config: general configuration, Django settings and urls config ├── docs │ └── diagrams ├── fictional: Django project with each context | ├── core │ ├── domain │ ├── infra │ ├── sales │ ├── users │ └── vehicles ├── scripts: scripts to set up the system ├── staticfiles └── tests: Unitary and API test

Setup

  1. Create a virtualenv
  2. Install the dependencies
pip install -r requirements.txt
  1. Delete the DB if any
rm db.sqlite
  1. Apply migrations
make apply-migrations
  1. Repopulate the database
python manage.py populate

Launch test

pytest

It should prompt code coverage and test resulta

Launch server

Simply do:

make run

The server will be available at localhost:8000 in debug mode You can use the available Postman collection and environment at docs/postman/

Documentation

Further information will be in the folder docs including:

Future work

This being a prototype, it lacks a lot of features that are advisable, both on the architecture and microcode side. To list a few:

  • Add Authenticantion

  • Add Django-Admin, to have a nice backoffice

  • Use a Filter Backend for query_params

  • Add cache

  • Add a JSON:API renderer

More endpoints

With the given domain we could easily expand our API with the following endpoints:

References

Here are the reference I used the most

Diagrams