A Django + Django REST Framework backend that powers a multi-step processing pipeline for scans, risk assessment, and recommendations.
This project was developed as part of coursework at Esprit School of Engineering. It provides a structured API for managing users and products, running scans, assessing risks, and returning recommendations through a clear pipeline.
- User management with custom user and allergy mapping
- Product catalog with categories and extraction methods
- Scan API that orchestrates the pipeline and stores scan data
- Risk assessment API with persisted results
- Recommendation API tied to scans and risks
- Simple dashboard view and summary endpoint
- Python 3.13
- Django 6
- Django REST Framework
- SQLite
Description: Backend Django API for scan, risk, and recommendation pipeline built for a university project.
Topics: python, django, django-rest-framework, api, backend, sqlite, web-development
App_Django/
config/ # Project config (settings, urls)
users/ # Custom user model + allergies
products/ # Product catalog model
scan/ # Scan model + scan API endpoint
risk/ # Risk API endpoint + persisted risk results
recommendation/ # Recommendation API endpoint + persisted recommendations
dashboard/ # Simple UI + dashboard API summary
templates/dashboard/ # Dashboard HTML template
requirements.txt
manage.py
Usercustom model (AUTH_USER_MODEL)Allergylist modelUserAllergymapping table (many-to-many through model)- API endpoints to list/create users, allergies, and user-allergy mappings
Productmodel with category (food,cosmetic)- Extraction method (
lens,barcode) - Ingredients as JSON
- API endpoint to list/create products
Scanmodel with optional user and imagePOST /api/scan/endpoint:- creates scan
- builds ingredient list
- triggers risk assessment
- triggers recommendation generation
- returns a combined response
POST /api/risk/endpoint- Input:
scan_id,ingredients - Output: risk list with levels (
low,medium,high) - Persisted models:
RiskAssessment,RiskItem
POST /api/recommend/endpoint- Input:
scan_id,risks - Output: recommendations (
product,reason) - Persisted models:
RecommendationBatch,RecommendationItem
- Browser dashboard at
/ - Summary API at
/api/dashboard/summary/
users.User1--*scan.Scanusers.User--users.Allergythroughusers.UserAllergyscan.Scan1--1risk.RiskAssessmentrisk.RiskAssessment1--*risk.RiskItemscan.Scan1--1recommendation.RecommendationBatchrecommendation.RecommendationBatch1--*recommendation.RecommendationItem
- Install dependencies:
python -m pip install -r requirements.txt- Create and apply migrations:
python manage.py makemigrations
python manage.py migrate- Optional: create admin user:
python manage.py createsuperuser- Start server:
python manage.py runserver- Open:
- Dashboard:
http://127.0.0.1:8000/ - Admin:
http://127.0.0.1:8000/admin/
GET/POST /api/users/GET/POST /api/users/allergies/GET/POST /api/users/user-allergies/GET/POST /api/products/POST /api/scan/POST /api/risk/POST /api/recommend/GET /api/dashboard/summary/
- Collection file:
postman_collection.json - Includes all API endpoints with ready-to-run sample payloads
Import steps:
- Open Postman and click Import.
- Select
postman_collection.json. - Ensure
baseUrlis set tohttp://127.0.0.1:8000. - Run requests in this order for quick demo: create user -> create allergy -> create user allergy -> scan pipeline.
Request body (optional fields):
{
"user": 1
}Response:
{
"scan_id": 1,
"ingredients": ["ingredient_1", "ingredient_2", "ingredient_3"],
"risks": [
{"ingredient": "ingredient_1", "level": "low"},
{"ingredient": "ingredient_2", "level": "medium"},
{"ingredient": "ingredient_3", "level": "high"}
],
"recommendations": [
{
"product": "Alternative for ingredient_1",
"reason": "Recommendation based on the assessed risk level."
}
]
}Completed under academic guidance for coursework at Esprit School of Engineering.