Django, Docker, Heroku, Djangorestframwork, Postgresql
- Django
- djangorestframework
- psycopg2-binary
- djangorestframework-simplejwt
- drf-yasg
Django is the one of the most popular web framework for python, Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. As for Postgresql it works well with Django and also preferable for the assignment as mentioned here.
No need to worry about installation, if docker and docker-compose is not installed in your system please install and follow along the step(s).
-
Git Clone this repo and enter into the TaxManagementSystem directory.
-
Create
-
Run the command
docker-compose up --build
. And it should be up and running. Checkout the endpoints mentioned below. Note test case and will be run and created. -
To run test case,
docker-compose exec backend python manage.py test
. Note test case automatically run during execution of previous commanddocker-compose up --build
. -
To create admin user,
docker-compose exec backend python manage.py createsuperuser
. -
Testcase is added to in docker
entrypoint.sh
. You can manually rundocker-compose exec backend python manage.py test
Application is deployed on heroku, link of the url is https://agile-savannah-29634.herokuapp.com/ it will work similar to docker container. And admin config are email:[email protected] and password: admin required for accessing admin panel <BASE_URL>/admin/
.
- Django provide built-in admin panel can be access from
localhost:8000/admin
url. - If you used
docker-compose up --build
then admin user will be created bydocker-compose exec backend python manage.py createsuperuser
. Otherwise create usingpython manage.py createsuperuser
- Use django admin panel to manipulate user and tax models.
You can access swagger api docs from <BASE_URL>/swagger/
. I have added custom swagger ui material.
POST <BASE_URL>/login/
Body: {'email': '[email protected]', 'password':'passwd123'}
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYyODY5ODMyNywianRpIjoiN2Y2YmNiZWIwMzY4NDQ5OWIzZDE3NjNkYTVmNThkZTQiLCJ1c2VyX2lkIjoiNjIyNThlM2YtMGVmYy00N2JkLTk4ZTEtODUyNTBjMWVlZmI5In0.1zK-oOrRXTv2DnarY8ax9mldrnaQg9G67QqHTnTjJv0",
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjMxMjAzOTI3LCJqdGkiOiJmMWVhMmMzNzQ5ZWE0ODQ1OWIxY2ZkNzJiMjIxMDQ4NCIsInVzZXJfaWQiOiI2MjI1OGUzZi0wZWZjLTQ3YmQtOThlMS04NTI1MGMxZWVmYjkifQ.hxuesV0-Y_aq6xVWZRYLj1Dz1xnRGuAvpO5QzOyNYj4",
"id": "62258e3f-0efc-47bd-98e1-85250c1eefb9",
"email": "[email protected]",
"username": "admin",
"user_type": "admin",
"state": "",
"date_joined": "2021-08-08T21:10:46.700375+05:30",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjMxMjAzOTI3LCJqdGkiOiI4MGViZjZjOTIwNzY0NmNlYTQzNDUyMzI2NWViMmYxOSIsInVzZXJfaWQiOiI2MjI1OGUzZi0wZWZjLTQ3YmQtOThlMS04NTI1MGMxZWVmYjkifQ.OGOqm1PZPCWDBM_ykwyjHicwrT4ksPN5O0BgGWKXulE"
}
POST <BASE_URL>/register/tax-accountant/
Body: { "username":"tax_accountant_1", "email":"[email protected]", "password":"tax_accountant_1" }
{
"id": "fca6b3b4-2645-4852-948a-7f51efd1dc87",
"email": "[email protected]",
"username": "tax_accountant_1",
"user_type": "tax-accountant",
"state": "",
"date_joined": "2021-06-29T17:21:48.585464Z",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjI3NTc5MzA5LCJqdGkiOiI5ZGY4NDkzMGE3ZGI0YzZhYjg2MTVlZGM3MmY3ZmQ3YyIsInVzZXJfaWQiOiJmY2E2YjNiNC0yNjQ1LTQ4NTItOTQ4YS03ZjUxZWZkMWRjODcifQ.7cee-lCqquKTHDl0MXK0i9tFjG0FQp6oFVl8l1e5QeU"
}
POST <BASE_URL>/register/tax-payer/
Body: { "username":"tax_payer_1", "email":"[email protected]", "password":"tax_payer_1" }
{
"id": "0d1739ea-ba36-4d1b-add5-e34045a76be5",
"email": "[email protected]",
"username": "tax_payer_1",
"user_type": "tax_payer_1",
"state": "",
"date_joined": "2021-06-29T17:24:43.532383Z",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjI3NTc5NDgzLCJqdGkiOiI1MTBhMzRlNjIwNTc0ZTg5YTZkYmIzOWFkYjY2MjliNCIsInVzZXJfaWQiOiIwZDE3MzllYS1iYTM2LTRkMWItYWRkNS1lMzQwNDVhNzZiZTUifQ.OwrAsVp9CuMzGOG0GMNejlYI6I-WEj5FQkjGSuhGEF4"
}
GET <BASE_URL>/list/
Header: { 'Authorization':'Bearer <TOKEN>' }
Response will be different for different user base on token.
[
{
"id": "b2bc4f19-42c2-4169-873e-9d8fe8282cda",
"email": "[email protected]",
"username": "sample",
"first_name": null,
"last_name": null,
"user_type": "tax-payer",
"state": "Bihar",
"date_joined": "2021-08-10T19:35:42.024118+05:30"
},
{
"id": "8d5bcc5c-f050-412b-9d79-41f62784bd84",
"email": "[email protected]",
"username": "tax-payer-3",
"first_name": null,
"last_name": null,
"user_type": "tax-payer",
"state": "",
"date_joined": "2021-08-08T21:43:00.899768+05:30"
},
{
"id": "e91bad56-c4b9-42ce-ae68-c645e6b166a9",
"email": "[email protected]",
"username": "tax-accountant-1",
"first_name": null,
"last_name": null,
"user_type": "tax-accountant",
"state": "",
"date_joined": "2021-08-08T21:31:03.586683+05:30"
},
{
"id": "6af0da57-5806-46ed-b5f1-4089861d328e",
"email": "[email protected]",
"username": "tax-accountant-2",
"first_name": null,
"last_name": null,
"user_type": "tax-accountant",
"state": "",
"date_joined": "2021-08-10T22:04:58.542297+05:30"
},
{
"id": "566a1d36-f6f9-4382-b4a5-61b01dd16ea8",
"email": "[email protected]",
"username": "tax-payer-2",
"first_name": null,
"last_name": null,
"user_type": "tax-payer",
"state": "Goa",
"date_joined": "2021-08-08T21:28:16.223335+05:30"
},
{
"id": "2a370b8e-2c92-4519-ad55-14ef070b12cf",
"email": "tax-payer-1",
"username": "tax-payer-1",
"first_name": "first",
"last_name": "last",
"user_type": "tax-payer",
"state": "Jharkhand",
"date_joined": "2021-08-08T21:31:11.228430+05:30"
}
]
GET <BASE_URL>/<uuid:id>/
Header: { 'Authorization':'Bearer <TOKEN>' }
{
"id": "b2bc4f19-42c2-4169-873e-9d8fe8282cda",
"email": "[email protected]",
"username": "sample",
"first_name": null,
"last_name": null,
"user_type": "tax-payer",
"state": "Bihar",
"date_joined": "2021-08-10T19:35:42.024118+05:30"
}
PUT <BASE_URL>/<uuid:id>/
Body: { "username":"tax_payer_1", "email":"[email protected]", "password":"tax_payer_1", "first_name":"tax_payer_1 update", "last_name":"tax_payer_1 last", "state": "Goa" }
Header: { 'Authorization':'Bearer <TOKEN>' }
Note add state in user otherwire tax will not work.
{
"id": "2f837973-6f08-4ff0-8d18-12f791d30504",
"email": "[email protected]",
"username": "tax_payer_1",
"first_name": "tax_payer_1 update",
"last_name": "tax_payer_1 last",
"user_type": "tax_payer_1",
"date_joined": "2021-06-27T15:26:04.635540Z"
}
GET <BASE_URL>/state_list/
Header: { 'Authorization':'Bearer <TOKEN>' }
[
"Andhra Pradesh",
"Arunachal Pradesh",
"Assam",
"Bihar",
"Chhattisgarh",
"Goa",
"Gujarat",
"Haryana",
"Himachal Pradesh",
"Jharkhand",
"Karnataka",
"Kerala",
"Madhya Pradesh",
"Maharashtra",
"Manipur",
"Meghalaya",
"Mizora",
"Nagaland",
"Odisha",
"Punjab",
"Rajasthan",
"Sikkim",
"Tamil Nadu",
"Telangana",
"Tripura",
"Uttar Pradesh",
"Uttarakhand",
"West Bengal",
"Andaman and Nicobar Island",
"Chandigarh",
"Dadra and Nagar Haveli and Daman and Diu",
"Delhi",
"Ladakh",
"Lakshadweep",
"Jammu and Kashmir",
"Puducherry"
]
POST <BASE_URL>/create/
Header: { 'Authorization':'Bearer <TOKEN>' }
Body: { 'income': 100000, 'deadline':'2021/08/20', 'tax_accountant': 'tax_accountant_1', 'tax_payer': 'tax_payer_1'}
Only tax-accountant type user is allowed
{
"id": 17,
"income": 150000,
"status": "NEW",
"tax_amount": 0,
"tax_accountant": "tax_accountant_1",
"tax_payer": "tax_payer_1",
"created_at": "2021-08-10T22:40:10.879332+05:30",
"updated_at": "2021-08-10T22:40:11.043337+05:30",
"deadline": "2021-08-20T00:00:00+05:30",
"fines": 0,
"total_amount": 0,
"payment_status": false,
"payment_date": null
}
GET <BASE_URL>/list/?status=<new|paid|delayed>&created_at='yyyy/mm/dd'&updated_at='yyyy/mm/dd'
Header: { 'Authorization':'Bearer <TOKEN>' }
Response result different for different user.
[
{
"id": 15,
"income": 250001,
"status": "NEW",
"tax_amount": 30000.12,
"tax_accountant": "tax-accountant-2",
"tax_payer": "tax-payer-1",
"created_at": "2021-08-10T20:57:24.662578+05:30",
"updated_at": "2021-08-10T23:00:05.529047+05:30",
"deadline": "2021-07-21T21:03:39+05:30",
"fines": 0,
"total_amount": 30000,
"payment_status": false,
"payment_date": null
},
{
"id": 14,
"income": 56000,
"status": "NEW",
"tax_amount": 0,
"tax_accountant": "tax-accountant-1",
"tax_payer": "",
"created_at": "2021-08-09T23:04:51.759259+05:30",
"updated_at": "2021-08-10T23:00:52.665686+05:30",
"deadline": null,
"fines": 0,
"total_amount": 0,
"payment_status": false,
"payment_date": null
}
]
PUT <BASE_URL>/edit/<int:id>
Header: { 'Authorization':'Bearer <TOKEN>' }
Body: { "income": 60000, "deadline": "2022/10/12", "status":"delayed", "tax_payer": "tax_payer_1" }
Only tax-accountant type use can edit
{
"id": 17,
"income": 60000,
"status": "DELAYED",
"tax_amount": 0,
"tax_accountant": "tax_accountant_1",
"tax_payer": "tax_payer_1",
"created_at": "2021-08-10T22:40:10.879332+05:30",
"updated_at": "2021-08-10T22:40:11.043337+05:30",
"deadline": "2021-08-20T00:00:00+05:30",
"fines": 0,
"total_amount": 0,
"payment_status": false,
"payment_date": null
}
GET <BASE_URL>/list/<int:id>/history/
Header: { 'Authorization':'Bearer <TOKEN>' }
admin and tax-accountant type use can edit
{
"history": [
{
"id": 14,
"income": 56000,
"status": "NEW",
"tax_amount": 0,
"created_at": "2021-08-09T17:34:51.759259Z",
"updated_at": "2021-08-10T17:30:52.665686Z",
"deadline": null,
"fines": 0,
"total_amount": 0,
"payment_status": false,
"payment_date": null,
"tax_accountant_id": "e91bad56-c4b9-42ce-ae68-c645e6b166a9",
"tax_payer_id": null,
"history_id": 82,
"history_date": "2021-08-10T17:30:52.666224Z",
"history_change_reason": null,
"history_type": "~",
"history_user_id": "62258e3f-0efc-47bd-98e1-85250c1eefb9"
},
{
"id": 14,
"income": 56000,
"status": "NEW",
"tax_amount": 0,
"created_at": "2021-08-09T17:34:51.759259Z",
"updated_at": "2021-08-10T17:03:49.481736Z",
"deadline": null,
"fines": 0,
"total_amount": 0,
"payment_status": false,
"payment_date": null,
"tax_accountant_id": "e91bad56-c4b9-42ce-ae68-c645e6b166a9",
"tax_payer_id": "2a370b8e-2c92-4519-ad55-14ef070b12cf",
"history_id": 75,
"history_date": "2021-08-10T17:03:49.482729Z",
"history_change_reason": null,
"history_type": "~",
"history_user_id": "62258e3f-0efc-47bd-98e1-85250c1eefb9"
}
]
}
GET <BASE_URL>/payment/<int:id>/
Header: { 'Authorization':'Bearer <TOKEN>' }
Body: {'payment':'1000'}
Only tax-payer user type allowed