This project is created to manage warehouse of medical equipment. It is built using Django 5.0.2. It is made especially for Medical Rescue Group of Polish Red Cross. User can go by all containers in warehouse, create new containers and add equipment into containers. Project includes also pre-created list of equipment of different types of bags used in Group. 3rd part of app is staff management. All Create, Read, Update, Delete operations on models are available via API.
Project is available on AWS cloud service EB EC2 supported by S3 bucket for static and media files; RDS for PostgeSQL database:
- Login: "DemoAccount"
- Password: "43cPVy6CLZbKUjv"
The most important technologies used in the project:
- Python 3.11
- Django 4.2.7
- DjangoRestFramework 3.14.0
- Poetry 1.7.1
- AWS: EB, EC2, S3, RDS
- PostgreSQL 16
- Docker 24.0.5
- Nginx 1.25
- Pre-commit 3.6.2
- Xhtml2pdf 0.2.15
- Crispy-bootstrap4 2022.1
To enter into service you need to have user account. It's for safety reasons - information about some equipment and calendar access may be sensitive. In main page you have menu and information about Group calendar, links into social media (FB, Instagram).
Main page - only users logged into Google account with permissions to calendar can see it.
Containers
Container list. From this page user can create new container, add equipment or downlnoad pdf list of containers.
Creating new container. User can choose name form list and add own description.
Equipment
Depends on name of equipment, creates different model - with specific fields.
List of equipment from container. User can manage equipment and download equipment list of container.
It's possible to get all equipment of all containers together.
API
![Api_1](readme_images/api_1.jpg) Example of API response of at "/api/containers/"- [Feature 1]: Containers - can manage different types of containers of list, ex. bags, trunks.
- [Feature 2]: Equipment - containers contain equipment. There is list of medical equipment to add sorted by types, ex. airways, drugs.
- [Feature 3]: Models - ready set of equipment. User can check what should be in, to make it in real.
- [Feature 4]: Staff - Different groups of Staff - to manage containers and equipment or for staff management.
- [Feature 5]: Save into pdf - every list (staff, containers, equipment, equipment in container) can be downloaded in pdf version.
- [Feature 6]: API - CRUD operations on models are available via API.
Follow these steps to get your project up and running locally.
-
Clone the repository:
git clone https://github.com/SzymKam/warehouse
-
Create a virtual environment and install poetry (optional but recommended):
pip install poetry poetry env use python3.11
-
Install project dependencies:
poetry install
Configure your project by setting up environment variables:
- SECRET_KEY - default is randomly generated
Create local server of PostgreSQL, and set variables to connect:
- DB_USER - database user
- DB_PASSWORD - database user password
- DB_HOST - database host
- DB_NAME - database name
For reset user password via email, connect to email service:
- EMAIL_HOST_USER - user of email host
- EMAIL_HOST_PASSWORD - password to email host
- DEFAULT_FROM_EMAIL - email address to send mails
If you want to connect project with your AWS S3 bucket or RDS database project is prepared.
S3 bucket settings:
- USE_RDS - set 'True' if you want to use RDS in project
- RDS_DB_NAME - your RDS name
- RDS_USERNAME - your RDS username
- RDS_PASSWORD - your RDS password
- RDS_HOSTNAME - your RDS host
AWS S3 configuration
- USE_S3 - set 'True' if you want to use S3 for static and media files in project
- AWS_ACCESS_KEY_ID - your AWS access key id
- AWS_SECRET_ACCESS_KEY - your AWS secret access key
- AWS_STORAGE_BUCKET_NAME - your S3 bucket name
To help set local variables correctly, you can use ".env.dist" file. Copy this file as ".env" and set you variables values.
-
Run database migrations:
cd src poetry run python manage.py migrate
-
Create a superuser (admin):
poetry run python manage.py createsuperuser
-
Start the development server:
poetry run python manage.py runserver
Your Django project should now be accessible at [http://localhost:8000/].
Project includes pre-made files to run 3 docker containers: web app, database (PostgreSQL) and Nginx for staticfiles. Make sure you have installed and running Docker engine. To run project:
docker compose up --build
Your Django project should now be accessible at [http://localhost/]. Don't forget to make migrations, collect static files and createsuperuser.
docker-compose exec web python manage.py migrate (migrations are also included, when docker-compose run)
docker-compose exec web python manage.py collectstatic
docker-compose exec web python manage.py createsuperuser
Overview of the database structure and models:
- [Model 1]: Container - with fields: name and description. Default container is "Main warehouse" - auto-created when database migrate. Also, when delete other container, equipment is transferred into "Main warehouse".
- [Model 2]: StaffUser - inherits from Django AbstractUser. Add additional fields (position, medical_qualifications, qualifications_expiration_date, image). This model is used as default AuthUserModel.
- [Model 3]: BaseMedicalEquipment - base for medical equipment. It's not used separately. Other models inherit from it: Drug, MedicalEquipment, Fluid, Cannula, Needle, Syringe, BIG, LtTube, Gloves, SterileGloves, Gauze, NasopharyngealTube, OropharyngealTube, EndotrachealTube, LaryngoscopeBlade, OxygenMask, VentilationMask - each of them with specific fields.
To run the tests for this project, use the following command:
poetry run python manage.py test
For testing is used included in Django - Unit Test. Total test coverage is 99%, with 6466 Stmts and 45 Miss.
SzymKam