This project is built as a final project task for Software Engineering Academy Compfest XIII. I'm Arsa and Ahmadhi as a BackEnd division using Python and Django tech stack. Galih and Novel as a FrontEnd division using React JS tech stack.
Donation Platform with CRUD operations to make a request. In order to retrieve/get/create/update/delete JWT is required. (Authorization: Bearer {token} attached to the headers). API provides endpoints for registration and token retrieval (access token and refresh token). With this access token, the user can access data related to the database through the API because the user is authenticated.
- Django + Django REST Framework + rest_framework_simplejwt
Json Web Token Authentication is possible thanks to 'rest_framework_simplejwt' package, which provides JWT implementation including DRF views for obtaining and refreshing tokens.
- Visual Studio Code, Postman
Production database is Heroku Postgres. Locally we used default SQLite database.
ERD diagram entities and manually created Users, Campaign, and Wallet entity.
Users has its own role field which can be admin, fundraiser, or donatur.
When registered as Fundraiser, he/she can retrieve/get/create/delete
a verified campaign and need to make a proposal that should notify admin.
When registered as Donatur he/she can make a donate to particular campaign and also topup using e-wallet.
When registered as Admin, he/she can see list and accept/reject of fundraiser registration, a new of new donation program, a new withdrawal from donation program, and topup request from donatur.
All models are saved and updated using modified ModelSerializer. From serializers, Django REST can pass the data from models.py
to the FrontEnd which is ReactJS via urls.py
.
Django in general has 2 architectures. The first one is MVC (Model-View-Template) and then other one is MVC (Model-View-Controller). Due to the FrontEnd is using library React JS instead of templates in "django-templates", we decide to choose MVC as a BackEnd Architecture.
The Models is logical data structure behind the entire application and is represented by a database.
The View is the user interface to see in the browser when visit a website. Because we don't use HTML/CSS/Vanilla JavaScript files, therefore the view represented by ReactJS files in FrontEnd.
The Controller is the middleman that connects the view and model together. We use serializers.py
to passing data from model to the view (FrontEnd React JS).
All of API endpoints have their own unit tests. Every app in django application have their own test.py
file.
- Register and login as Admin, Fundraiser, and Donatur.
- Admin workflow.
- handle bug and error.
- Get all campaign.
- Get verified campaign by donor.
- Get pending campaign by admin.
- Fundraiser create new donation program.
- Donor donation workflow.
- Donor e-wallet topup workflow.
- handle bug and error.
- Fundraiser withdrawal workflow.
- TopUpHistory by Donatur.
- DonationHistory by Donatur.
- handle bug and error.
After Arsa and Ahmadhi made a unit test on every test.py
file, finally we get 98% coverage test.
This repository has been deployed to Heroku. You can visit here
- Create staticfiles folder. (Make sure you made an exception in .gitignore for this file.)
- Make sure there is Procfile is root directory with these 2 lines:
release: python manage.py migrate
web: gunicorn app.wsgi
- Set
DEBUG = False
, adddjango_heroku.settings(locals())
on the bottom of settings.py. Make sure your requirements.txt contains every needed package. You may want to update it withpip freeze > requirements.txt
. - Go to Heroku and add new app.
- Go to Resources tab and install Heroku Postgres add-on.
- Go to Settings tab and set SECRET_KEY in config vars. Add heroku/python buildpack.
- Go to Deploy tab, connect your Github repository, select branch to deploy. You can Enable Automatic Deploys or Deploy Branch manually.
- App should be up and running at
https://<name_of_app>.herokuapp.com
.
git clone https://github.com/arsaizdihar/donatur-backend.git
Create new virtual environment, activate it and install dependencies.
pip3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
Set SECRET_KEY in your environmental variables.
You can also install python-dotenv
, put .env
file with secrets in root directory
and add those lines in settings.py. (Make sure .env is not being commited to git repository if you want to use this method)
from dotenv import load_dotenv
load_dotenv()
Run migrations and create super user. (Making migrations might not be necessary)
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
Run server and open your browser at http://127.0.0.1:8000/
.
python manage.py runserver
Run tests with coverage (unit tests + report)
coverage run --include="./*" --omit="venv/*,manage.py,project_name/*" manage.py test
coverage report -m
You can make report from html coverage by default
coverage run --include="./*" --omit="venv/*,manage.py,project_name/*" manage.py test
coverage html
Find index.html in htmlcov folder and open it to browser to see the tests and report