https://github.com/devbaraus/kuehne-server
https://github.com/devbaraus/kuehne-server
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/devbaraus/kuehne-server
- Owner: devbaraus
- Created: 2025-12-22T22:49:08.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-22T23:20:15.000Z (7 months ago)
- Last Synced: 2025-12-24T12:27:33.072Z (7 months ago)
- Language: Python
- Size: 47.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kuehne + Nagel Logistics API
Backend API for managing locations and shipments with token-based auth, soft-delete, audit trails and generated OpenAPI docs.
## Features
- Python 3.14+ and Django 6 with Django REST Framework.
- Token-based authentication with `django-rest-knox`.
- Role-based access control: `admin`, `moderator`, `viewer`.
- CRUD endpoints for `Location` and `Shipment` models with filtering and search.
- Soft-delete functionality using `django-soft-delete`.
- Audit logging of create/update/delete actions via `django-auditlog`.
- Auto-generated OpenAPI schema and interactive docs with `drf-spectacular` and `django-scalar`.
- PostgreSQL database backend with Docker Compose setup for local development.
## Models
- `Location`: warehouses/ports/airports with geographic metadata (latitude, longitude, city, country).
- `Shipment`: origin/destination locations, tracking and order numbers, status lifecycle, and date checks.
- `User`: email-as-username auth model; groups managed by `setup_roles` command to provision `admin`, `moderator`, `viewer` roles.
## Getting started
Prereqs: Python 3.14+, Poetry, Docker (for Postgres), and a `.env` with database and Django settings.
1) Install deps
```
poetry install
```
2) Start Postgres (local dev)
```
docker compose up -d postgres
```
3) Run migrations and seed roles
```
poetry run python manage.py migrate
poetry run python manage.py setup_roles
```
4) Create a superuser (optional but useful)
```
poetry run python manage.py createsuperuser
```
5) Run the API
```
poetry run python manage.py runserver
```
Authentication
--------------
- Obtain token: `POST /v1/auth/login/` with username/password → returns knox token and permissions.
- Current user info: `GET /v1/auth/user/` with `Authorization: Token `.
- Logout: `POST /v1/auth/logout/`.
API surface
-----------
- `GET/POST /v1/locations/` plus detail routes; filter by `type`, search by `name`, `city`, `country`.
- `GET/POST /v1/shipments/` plus detail routes; filter by `status`, search across origin/destination, tracking, order numbers.
- OpenAPI schema: `GET /v1/schema/`; Scalar UI: `GET /v1/docs/`.
Environment variables
---------------------
- `DJANGO_SECRET_KEY` (required)
- `DJANGO_DEBUG` (`True`/`False`, default `False`)
- `DJANGO_ALLOWED_HOSTS` (comma-separated)
- `CORS_ALLOWED_ORIGINS`, `CSRF_TRUSTED_ORIGINS` (comma-separated)
- `DATABASE_NAME`, `DATABASE_USER`, `DATABASE_PASSWORD`, `DATABASE_HOST` (default `localhost`), `DATABASE_PORT` (default `5432`), `DATABASE_TEST_NAME` (default `test_db`)
Running tests
-------------
```
poetry run python manage.py test
```