Access Portal Backend build with Django Rest Framework and Celery
![](./assets/logo.jpg)
Access Portal is an Access Key Manager web application developed for Micro-Focus Inc. to manage access keys for their multi-tenant school management platform. Schools can use this application to purchase access keys to activate their accounts. This project involves building a key manager that includes user authentication, key management, and integration capabilities.
Micro-Focus Inc., a software company, has built a school management platform that is multi-tenant. Various schools can set up on the platform as if it was built specifically for them. They have chosen to use an access key-based approach for monetization rather than integrating payment features directly into the software. This project aims to develop a web application that schools can use to purchase and manage access keys to activate their accounts.
Signup & Login
: School IT personnel is able to sign up and log in with an email and password. Account verification and a reset password feature to recover lost passwords is included.Access Key Management
: Users is able to see a list of all access keys granted: active, expired, or revoked.Key Details
: For each access key, users is able to see the status, date of procurement, and expiry date.Key Constraints
: Users should not be able to obtain a new key if an active key is already assigned. Only one key can be active at a time.
Admin Login
: Admins is able to log in with an email and password.Manual Key Revocation
: Admins is able to manually revoke an access key.Key Overview
: Admins is able to see all keys generated on the platform, including their status, date of procurement, and expiry date.Active Key LookUp Endpoint
: Admins is able to access an endpoint that, given a school email, returns the status and details of the active key if any, or a 404 status if no active key is found. This allows integration with the school management software.
- School IT Personnel's key created must be activated by admin. Admins are
notified
viaemail
if a key is created. - When status of a key changes, School IT Personnels are
alerted
viaemail
by a custome mail template. - When creating a key, in addition to a
key-tag
, a user must input thenumber of days
the key should be active whichstarts at the time of activation
(procurement date). - A School IT Personnel can
delete
a key while the status is stillinactive
and also cannot create
a key while the status isinactive
.
Admin
- Email -
[email protected]
- Password -
admin
School IT Personnel(s)
- Email -
[email protected]
- Password -
guest@123
- Email -
[email protected]
- Password -
guest@123
- Email -
[email protected]
- Password -
guest@123
The project was inspired by the need for a robust and efficient way to manage access keys for a multi-tenant school management platform. Every aspect of this project required extensive research and careful planning to ensure seamless integration and functionality. The activities involved in this project are as follows:
- Database model (table) development and configurations
- Writing the various API views for all the neccessary methods of each view
- Admin panel management configurations.
- Adding all the neccesary URL endpoints to for all the various views and thier methods. Not forgetting the admin panel too.
- Writing tests for all the views and thier methods. I also used Postman for testing as well.
- Including a documentation for the project API through a library called drf-spectacular by OpenAPI Initiative.
- Deployment of the REST API to heroku
![](./assets/image of api.png)
- Django rest Framework for handling API views, and routes.
- Celery was utilized for managing and executing asynchronous background tasks, ensuring that long-running processes do not block the main application.
- Celery Beat was employed as a scheduler to automate the execution of periodic tasks, enabling tasks to run at defined intervals without manual intervention.
- Redis as a message broker for Celery to manage and schedule background tasks.
- Postgres Database as the primary database for storing application data securely and efficiently.
- DRF Spectacular for generating and maintaining OpenAPI documentation for the Django REST Framework API.
- Next.js for building the frontend, providing server-side rendering and static site generation for a seamless user experience.
- Vercel was used host the frontend application, ensuring fast and reliable hosting with seamless integration for continuous deployment.
![](.//assets/admin panel.png)
![](.//assets/school IT personnel page.png)
- Frontend repository can be found
here
python -> 3.10
django -> 5.0.4
djanforestframework -> 3.15.1
celery -> 5.4.0
redis -> 5.0.4
git clone https://github.com/juliusmarkwei/access-portal.git
cd access-portal/
pip install -r requirements.txt
- Create a
.env
preferrably inside the root directory access-portal/. Inside the .env add a SECRET_KEY and your database configurations of the database of your choice. You can generate aSECRET_KEY
using the following code snippet:
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
- Check the complete list of the
.env
file content here. It should look like the variables below:
SECRET_KEY=your_secret_key_here
DB_HOST=your_db_host
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_db_name
DB_PORT=your_db_port
DB_ENGINE=your_db_engine
- In the root directory of the project, create a superuser to manage all the users of the application. be sure python is installed before you proceed with this stage.
python3 manage createsuperuser
python3 manage runserver
celery -A core worker --loglevel=info
celery -A core beat --loglevel=info
- Make sure your redis server is up and running before you run the comand above.
I welcome contributions and participation from the community to help make this backend API even better! Whether you're looking to fix bugs, add new features, or improve documentation, your help is greatly appreciated. Here's how you can get involved:
If you encounter any bugs or issues, please report them using the Issues section of my GitHub repository. When reporting issues, please include:
- A clear and descriptive title.
- A detailed description of the problem, including steps to reproduce it.
- Any relevant logs or error messages. Your environment details (e.g., Django version, DRF version, database, etc.).
I love receiving pull requests from the community! If you have an improvement or a new feature you'd like to add, please feel free to do so ๐