Django REST API for the MediSure medicine track-and-trace system on Cardano.
- Create virtual environment and activate it:
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Mac/Linux- Install dependencies:
pip install -r requirements.txt- Create
.envfile in backend folder:
BLOCKFROST_PROJECT_ID=your_testnet_api_key_here
- Run migrations:
python manage.py migrate- Create superuser (optional):
python manage.py createsuperuser- Start server:
python manage.py runserverLive Base URL: https://medisure-backend-t5yr.onrender.com/api/
Local Base URL: http://127.0.0.1:8000/api/
POST /api/auth/signup/
{
"username": "user123",
"password": "password",
"email": "[email protected]",
"role": "patient"
}POST /api/auth/signin/
{
"username": "user123",
"password": "password"
}POST /api/mint/
- Mint a new batch NFT
POST /api/transfer/
- Transfer batch between supply chain entities
GET /api/verify/{qr_code}/
- Verify medicine authenticity via QR code
GET /api/journey/{batch_id}/
- Track batch journey through supply chain
GET /api/dashboard/?manufacturer_id={uuid}
- Get manufacturer dashboard statistics
GET /api/inventory/
- List all pharmacy inventory
POST /api/inventory/
- Add medicine to pharmacy inventory
GET /api/pharmacy/{pharmacy_id}/inventory/
- Get inventory for specific pharmacy
GET /api/cart/?user_id={id}
- Get user's cart
POST /api/cart/add/
{
"user_id": 1,
"inventory_id": "uuid",
"quantity": 2
}PUT /api/cart/update/{item_id}/
- Update cart item quantity
DELETE /api/cart/remove/{item_id}/
- Remove item from cart
DELETE /api/cart/clear/?user_id={id}
- Clear entire cart
POST /api/orders/create/
{
"user_id": 1,
"pharmacy_id": "uuid"
}GET /api/orders/?user_id={id}
- Get user's order history
GET /api/orders/{order_id}/
- Get specific order details
PUT /api/orders/{order_id}/status/
{
"status": "confirmed"
}GET /api/users/{user_id}/
- Get user details
GET /api/users/?role={role}
- List users by role (manufacturer, distributor, pharmacy, patient)
/api/manufacturers/- Manage manufacturers/api/distributors/- Manage distributors/api/pharmacies/- Manage pharmacies/api/batches/- Manage batches/api/transactions/- View transactions
- Django 5.2
- Django REST Framework
- Blockfrost API (Cardano)
- SQLite (development) / PostgreSQL (production)
- Python 3.11+