|
| 1 | +# Welcome to Mesimä |
| 2 | + |
| 3 | +This is the source of Mesimä (pronounced Mesi-mah). It is a RESTful HTTP application for task managment, written in Python. |
| 4 | + |
| 5 | +Mesimä was created with ❤️ using [Django Rest Framework](https://www.django-rest-framework.org/) and [PostgreSQL](https://www.postgresql.org/). |
| 6 | + |
1 | 7 | # Development Instructions |
2 | 8 |
|
3 | | -To create the cluster, deploy and watch files: |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +Running the app requires having tilt, k3d and their dependencies (Docker, kubectl...). |
| 12 | + |
| 13 | +This project was developed using tilt `v0.23.4` and k3d `v5.2.2`. |
| 14 | +Newer version *should* be fine. |
| 15 | + |
| 16 | +## Running the Application |
| 17 | + |
| 18 | +Create a k3d cluster: |
4 | 19 |
|
5 | 20 | ```s |
6 | 21 | $ k3d cluster create --config k3d.yaml |
7 | | -$ kubectl apply -f https://raw.githubusercontent.com/reactive-tech/kubegres/v1.15/kubegres.yaml |
8 | | -$ tilt up |
9 | 22 | ``` |
10 | 23 |
|
11 | | -To delete the cluster: |
| 24 | +Install Kubegres (a Kuberntes operator for delpoying PostgreSQL clustres): |
12 | 25 |
|
13 | 26 | ```s |
14 | | -$ k3d cluster delete amit-mini-project |
| 27 | +$ kubectl apply -f https://raw.githubusercontent.com/reactive-tech/kubegres/v1.15/kubegres.yaml |
15 | 28 | ``` |
16 | 29 |
|
17 | | -## Running the Tests |
18 | | - |
19 | | -Tests are easiest to run using sqlite. Use the following sequence of commands: |
| 30 | +Start the development setup: |
20 | 31 |
|
21 | 32 | ```s |
22 | | -$Env:DB="sqlite" |
23 | | -poetry shell |
24 | | -python manage.py test |
| 33 | +$ tilt up |
25 | 34 | ``` |
26 | 35 |
|
27 | | -# DRF Useful Links |
| 36 | +Open a web broswer and navigate to `https://localhost:3080/api`. You should see DRF's browseable api client. |
28 | 37 |
|
29 | | -- A solution to the wierd API endpoinds in the form of `user/id/tasks` ([link](https://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/#refactoring-to-use-viewsets)). |
30 | | - |
31 | | -- Writing 'raw' gin-like views in DRF ([link](https://www.django-rest-framework.org/tutorial/1-serialization/#writing-regular-django-views-using-our-serializer)). |
32 | | - |
33 | | -- Overwrite just the post in the viewset which is prob the best move ([link](https://www.django-rest-framework.org/tutorial/quickstart/)). |
| 38 | +To delete the cluster: |
34 | 39 |
|
| 40 | +```s |
| 41 | +$ k3d cluster delete amit-mini-project |
| 42 | +``` |
35 | 43 |
|
| 44 | +## Running the Tests |
36 | 45 |
|
37 | | -# Notes |
| 46 | +It is recommended to run the tests using sqlite, without k3d. |
| 47 | +This requires having `poetry` installed. |
38 | 48 |
|
39 | | -- `Post` returns data in headers. :( |
40 | | -- `People` email field should be unique. |
| 49 | +Use the following sequence of commands to run the unit-tests: |
41 | 50 |
|
| 51 | +```s |
| 52 | +$ cd backend |
| 53 | +$ poetry install # Install Python dependencies |
| 54 | +$ poetry shell # Spawn a shell inside the virtual environemnt |
| 55 | +$ cd manager |
| 56 | +$ DB="sqlite" python manage.py test # Run the test suite while using sqlite |
| 57 | +``` |
42 | 58 |
|
43 | | -# Questions to Lecturer |
| 59 | +## Documentation |
44 | 60 |
|
45 | | -1. Can we return error messages in `JSON`? (There is a fix though (link)[https://www.django-rest-framework.org/api-guide/settings/#miscellaneous-settings]). |
| 61 | +The Django app and project were generated using `django create project` and `django create app` commands. |
46 | 62 |
|
| 63 | +Consequentially, a basic understanding of Django's [getting started tutorial](https://docs.djangoproject.com/en/4.0/intro/tutorial01/) should be enough to understand the role of each source file. |
47 | 64 |
|
48 | | -# TODO |
| 65 | +To gain understanding of specific aspects of the app (e.g, routing), it is recommended to read the respective source files. |
| 66 | +DRF abstractions are heavily used, which allows most code to be self-documenting. |
49 | 67 |
|
50 | | -1. The weird nested endpoints (like `/tasks/id/owner`). |
51 | | -2. Complete `Person`'s `activeTaskCount`. |
| 68 | +Usage of less common Django/DRF funcitonality is documented inline in each source file, with comments linking to Django documentation. |
0 commit comments