Local-first Django clinic management system for a small clinic. It runs on a laptop with SQLite and keeps the operational data offline by default.
- Django authentication with login, logout, password change, groups, and permissions.
- Admin and staff roles through the
seed_rolesmanagement command. - Medicine, incoming stock, stock adjustment, low-stock, and expiry tracking.
- Patient registration and patient medicine history.
- One-screen dispensing that creates a bill, debt record, and optional payment.
- Bills, printable invoices, PDF invoices, debts, and payments.
- Dashboard cards and local canvas chart with no internet CDN dependency.
- Excel exports for medicines and debts.
- JSON and SQLite backup downloads, plus JSON restore.
- Internal audit log for key model create, update, and delete events.
- Token-protected phone/laptop sync API with device approval, change journal, idempotent pushes, and cursor pulls.
Linux:
cd /home/levis/Desktop/clinic
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py seed_roles
python manage.py createsuperuser
python manage.py runserver 127.0.0.1:8000If python3 -m venv says ensurepip is missing on Ubuntu/Debian, install the venv package first:
sudo apt install python3.14-venvWindows:
py -m venv .venv
.venv\Scripts\activate
python -m pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py seed_roles
python manage.py createsuperuser
python manage.py runserver 127.0.0.1:8000Open http://127.0.0.1:8000/ and log in with the superuser account.
Run this after migrations:
python manage.py seed_rolesThen assign users to groups in Django Admin:
Admin: full access.Staff: view inventory, register patients, dispense medicines, record payments, and view bills/debts.
Staff users are intentionally not granted delete permissions or user-management permissions.
- Create medicines under
Medicines. - Add stock under
Stock In. - Register patients under
Patients. - Use
Dispenseto select a patient, medicine, quantity, discount, and optional payment. - View generated bills under
Bills. - Track pending balances under
Debts. - Export reports under
Reports. - Download backups under
Backups.
Use both backup types:
- SQLite database backup: easiest full local restore when the app is stopped.
- JSON backup: useful for Django data restore through the app.
Keep at least one backup copy outside the laptop, such as an encrypted USB drive.
The app is local-first on the laptop and now includes the Django sync backend under /api/.
Sync endpoints:
POST /api/devices/register/POST /api/sync/push/GET /api/sync/pull/?cursor=0POST /api/sync/ack/
Use Tailscale first so the Android phone can reach the laptop privately. See docs/TAILSCALE_SYNC_GUIDE.md and docs/ANDROID_SYNC_SCHEMA.md.