The Inspection Management System is a full-stack application designed to streamline the inspection process. The backend is built using Django and Django REST Framework with JWT-based authentication, while the frontend is developed in React with TypeScript, Vite, Tailwind CSS, and Material UI.
The system provides secure API endpoints for managing inspections (including creating, reading, updating, and deleting records). The frontend interfaces with these endpoints, decoding JWT tokens to control access and display appropriate UI elements (for example, showing admin-only buttons based on the embedded user type).
-
Obtain Token
Endpoint:POST /api/v1/token/
Description: Accepts a JSON payload withusernameandpasswordand returns an access token and a refresh token. The access token includes custom claims such asis_adminto indicate the user's role. -
Refresh Token
Endpoint:POST /api/v1/token/refresh/
Description: Accepts a JSON payload with the refresh token and returns a new access token. This endpoint is used to maintain a valid session without forcing the user to re-authenticate frequently.
-
List/Create Inspections
Endpoint:GET, POST /api/v1/inspections/
Description:- A
GETrequest retrieves all inspections. - A
POSTrequest creates a new inspection record. The request must include a valid JWT in theAuthorizationheader.
Data Fields: title(string)description(string)latitude(float)longitude(float)due_date(string in YYYY-MM-DD format)
- A
-
Retrieve/Update/Delete Inspection
Endpoint:GET, PUT, DELETE /api/v1/inspections/{id}/
Description:- A
GETrequest retrieves details for a specific inspection. - A
PUTrequest updates an inspection. - A
DELETErequest removes an inspection.
Note: All these endpoints are secured and require the access token for authentication.
- A
-
Complete an inspection Endpoint:
PUT /api/v1/inspections/{id}/
Description:- A
PUTrequest completes the pending inspection.
Note: All these endpoints are secured and require the access token for authentication.
- A
-
List All Activities
Endpoint:GET /api/v1/activities/
Description:- Retrieves all activity records.
- Requires a valid JWT token in the
Authorizationheader.
Permissions: Authenticated users only.
Response Fields: id(integer)title(string)description(string)status(string)inspection(integer)created_at(datetime)updated_at(datetime)
-
Retrieve Specific Activity
Endpoint:GET /api/v1/activities/{activity_id}/
Description:- Retrieves a specific activity by its ID.
- Requires a valid JWT token in the
Authorizationheader.
Permissions: Authenticated users only.
-
List Activities by Inspection
Endpoint:GET /api/v1/inspection/{inspection_id}/activities/
Description:- Returns a list of all activities linked to a specific inspection.
- Requires a valid JWT token in the
Authorizationheader.
Permissions: Authenticated users only.
-
Create Activities (Single or Multiple)
Endpoint:POST /api/v1/inspection/{inspection_id}/activities/
Description:- Creates one or more activity records tied to a specific inspection.
- For multiple creations, send a list of activity objects.
- Requires a valid JWT token in the
Authorizationheader.
Permissions: Admins and analysts only.
Request Fields: title(string, required)description(string)status(string, optional)- If multiple, send as a list of objects.
-
Update Activity
Endpoint:PUT /api/v1/activities/{id}/
Description:- Updates an existing activity.
- Requires a valid JWT token in the
Authorizationheader.
Permissions: Admins, analysts, and inspectors only.
Request Fields: title(string)description(string)status(string)
-
Delete Activity
Endpoint:DELETE /api/v1/activities/{id}/
Description:- Deletes a specific activity.
- Requires a valid JWT token in the
Authorizationheader.
Permissions: Admins and analysts only.
-
Authentication:
The login form captures the username and password of the user sending the request to the backend, if any of the information does not match the records it will show an error message advising to check the credentials and to try again. in the case the suer is able to sucessfully login it will redirect it to the dashboard saving and decoding the JWT token in the local storage. -
Dashboard:
The dashboard displays a list of inspections in a table format with columns for ID, title, and inspection date. Each row provides buttons for editing, viewing details, and deleting an inspection. Editing and viewing details are handled through modal dialogs. -
Routing:
The application uses React Router for navigation. Private routes ensure that only authenticated users can access the dashboard, while the login view redirects to the dashboard after a successful authentication. -
Redux:
Redux is used for global state management. Authentication status, user information, and the list of inspections are stored in the Redux store. Actions are dispatched to update the store when a user logs in, logs out, or when inspections are fetched, created, updated, or deleted. Middleware like Redux Thunk is used to handle asynchronous API calls.
For detailed information on how to run the front end, please refer to the documentation inside the frontend folder.
The backend is implemented with Django and Django REST Framework. Key aspects include:
-
JWT Authentication:
The backend usesdjangorestframework-simplejwtto generate JWT tokens that include custom fields likeis_admin. Endpoints are secured, and only requests with a valid token in theAuthorizationheader can access protected resources. -
Inspection Management:
The API provides endpoints for creating, listing, retrieving, updating, and deleting inspection records. The endpoints are designed following RESTful principles and include proper validation and error handling. -
Image and Map Handling:
The backend uses thePillowlibrary for image processing and manipulation when handling image uploads or editing tasks. Additionally,StaticMapis used to generate static map images with markers based on the coordinates (latitude and longitude) of inspection locations. -
CORS Configuration:
CORS is handled usingdjango-cors-headersto allow cross-origin requests from the frontend domain. (Running locally, for deployment pourposes please refer to the docs inside the backend folder)
For further details on configuring and running the backend, please refer to the documentation inside the backend folder.
The Inspection Management System provides a great solution for managing inspections with secure JWT authentication. For more detailed usage instructions and configuration details, please consult the README files located within the respective frontend and backend directories.