This is the backend API for the LIMS (Laboratory Information Management System) application. It's a secure RESTful API built with Python, Django, and Django REST Framework, designed to manage user authentication and sample data.
Live API URL: https://laboratory-sample-tracker-api.onrender.com
Frontend Client Repo: [Link to your GitHub repo for the frontend]
- Token Authentication: Secure user registration and login endpoints using DRF's built-in
authtoken. - RESTful API: Full CRUD (Create, Read, Update, Delete) functionality for
Samplemodels. - Permissions: API endpoints are protected, ensuring users can only view and edit their own samples.
- Data Integrity: Automatically creates an
AuditLogentry for every sample creation and status update. - Custom Endpoints: Includes a
/api/user/endpoint to retrieve the current user's details from their token.
- Framework: Django & Django REST Framework
- Language: Python
- Database: PostgreSQL
- Authentication: DRF Token Authentication
- CORS:
django-cors-headers - Deployment: Render
All endpoints are prefixed with /api/.
| Endpoint | Method | Permission | Description |
|---|---|---|---|
/register/ |
POST |
AllowAny | Creates a new user. |
/login/ |
POST |
AllowAny | Logs in a user, returns an auth token. |
/user/ |
GET |
IsAuthenticated | Returns the logged-in user's details. |
/samples/ |
GET |
IsAuthenticated | Returns a list of the user's samples. |
/samples/ |
POST |
IsAuthenticated | Creates a new sample for the user. |
/samples/<id>/ |
GET |
IsAuthenticated | Returns details for a single sample. |
/samples/<id>/ |
PUT |
IsAuthenticated | Updates a sample (e.g., its status). |
/samples/<id>/ |
DELETE |
IsAuthenticated | Deletes a sample. |
- Clone the repository:
git clone [your-repo-url] cd laboratory-sample-tracker-api - Set up a virtual environment:
python3 -m venv env source env/bin/activate - Install dependencies:
pip install -r requirements.txt
- Set up PostgreSQL:
- Create a local PostgreSQL database (e.g.,
lims_db). - Create a user (e.g.,
lims_user) with a password. - Grant the user privileges on the database.
- Create a local PostgreSQL database (e.g.,
- Set up environment variables:
Create a
.envfile in the root.SECRET_KEY='your-django-secret-key' DEBUG='True' ALLOWED_HOSTS='127.0.0.1,localhost' DATABASE_URL='postgres://lims_user:password@127.0.0.1:5432/lims_db'
- Run migrations:
python manage.py migrate
- Run the development server:
The API will be running at http://127.0.0.1:8000.
python manage.py runserver