This is a simple restaurant manager project.
- Install docker and docker-compose.
- Run
cp .env.sample .env
and fill.env
file. - Run
docker-compose -f docker-compose.dev.yml up --build
. It may take some time (because seeding initial data). - The service is run under
0.0.0.0:8000
and update after each file changes.
- Install docker and docker-compose.
- Run
cp .env.sample .env
and fill.env
file. - Run
docker-compose -f docker-compose.prod.yml up --build
. It may take some time (because seeding initial data). - The service is run under
yourserverip
ordomain
.
- You can see api documentations under
/swagger
or/redoc
urls. - Also, the pdf file
rest_apis_doc.pdf
is in the root of project.
As you see in the above picture, We have three primary models for our database: User, Restaurant and Review. Also, I developed two other models for better design: Category and BusinessHour. The main idea of the model's fields came from seed data, but I added some additional fields. For example, we needed the number of reviews each user has to update the average_stars value quickly.
I chose Postgres as a relational database because there is a connection between different entities we have. Also, the number of data isn't too much for a relational database. But maybe after scaling up the service, it's better to think about NoSQL databases.
We have twelve APIs in this project (You can see the details in swagger)
Two of them are for login and logout users:
- I assumed the user list was fixed and used a TokenAuthentication method.
- The username for all users sat as their user_id, and the password is initial_password.
Three of them need the user to be logged in:
- Get user reviews.
- Create a new review.
- Delete a review.
Other APIs are:
- Get the restaurants list.
- Search restaurants by category (adding query param ?category=food).
- Get all reviews of one specific restaurant.
- Get details of one specific restaurant.
- Get all reviews.
- Search reviews by keyword (adding query param ?keyword=good).
- Get details of one specific review.
The API flow is:
- API <-> View <-> Serializer <-> Model <-> Database
- We have 90% test coverage at the project.
- Add Statsd or Prometheus for monitoring APIs.
- Connect project logger to Sentry for seeing logs on the sentry dashboard.
- Switch to any CI/CD to have better deploying process (for example, Gitlab CI/CD).
- Deploy on a cloud platform and switch to Kubernetes for better scaling and maintaining features.
- Think of NoSQL for scaling up the database.