Web Team(Backend) Task:
Problem Statement: Library Shelf Token Management System
Managing bags in a library is often a manual process, which can lead to inefficiencies,
confusion, or even misplacement. To streamline this process, we aim to build a Library Shelf
Token Management System using [Link] and an in-memory database.
Objective
Design and implement a backend system that efficiently manages the assignment and
retrieval of library shelves for students depositing their bags.
Core Workflow
1. Shelf Assignment
- There are `n` shelves available (default: 100).
- A student requests a shelf through the system.
- The backend checks for an available shelf and assigns it to the student.
- Along with the shelf ID, a randomly generated token code is created and mapped to the
shelf in the backend.
- The token is provided to the student as proof of shelf ownership.
2. Bag Retrieval
- To retrieve the bag, the student provides the shelf ID and the random token code.
- The backend validates the token-shelf pair.
- If valid, the shelf is marked as available again for future use.
Constraints & Requirements
- No two students can be assigned the same shelf at the same time.
- The system should maintain efficiency for allocation and deallocation.
- Implementation must be done only in [Link] or Django
- Authentication and user management may be added as an extension, but are not a core
necessity.
Expected API Endpoints
Shelf Management APIs
1. POST /shelf/assign – Assign an available shelf to a student and generate a token.
2. POST /shelf/retrieve – Validate shelf ID + token and mark the shelf as available again.
3. GET /shelf/status – Get a list of available and occupied shelves (for monitoring).
Utility APIs
4. GET /config – Fetch configuration (e.g., total number of shelves).
Other routes you prefer
Authentication (Optional Extension)
To enhance security and support more advanced workflows, an authentication system can
be integrated:
- User Registration & Login
- POST /auth/register – Register a student.
- POST /auth/login – Login and receive a session token / JWT.
- Protected Endpoints
- Only authenticated users can request shelves or retrieve bags.
- Tokens ensure shelf access is tied to the right user.
- Future Enhancements
- Role-based access (e.g., admin librarians vs. students).
- Tracking usage history per student.
- Analytics dashboard (popular times, shelf utilization, etc.).
Expected Outcome
A working backend service that can:
- Assign shelves securely and reliably.
- Validate token-shelf mappings for retrieval.
- Ensure shelves are efficiently recycled for new requests.
- Provide a foundation for future enhancements (authentication, history logs, analytics).