This repository contains a CRUD API for a gym management system built using Django REST Framework. The API allows users to manage gyms, trainers, clients, and workout sessions.
The project structure is organized as follows:
api
: Contains URL configurations for the API.gym
: Main project settings, URL configurations, and deployment files.app
: Core application logic, including models, views, serializers, and custom authentication.
- Defines database structure for Gym, Trainer, Client, and WorkoutSession entities.
- Establishes relationships between entities.
- Converts data types (models) into JSON format and vice versa using Django REST Framework's ModelSerializer.
- Handles serialization/deserialization for API endpoints.
- Manages CRUD operations for each model using Django REST Framework's ModelViewSet.
- Customizes error handling and permissions for specific endpoints.
- Defines URL patterns for API endpoints.
- Routes requests to corresponding views and ViewSets.
settings.py
: Project-level configurations for database, middleware, installed apps, authentication, etc.admin.py
: Registers models with Django's admin interface.auth.py
: Contains custom permission classes for authentication.
- Clone the repository:
git clone https://github.com/sachin-404/gym-management-system-api.git
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
- linux:
source venv/bin/activate
- Windows:
venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Apply migrations:
python manage.py migrate
- Run the development server:
python manage.py runserver
/gyms/
: CRUD operations for gyms./trainers/
: CRUD operations for trainers./clients/
: CRUD operations for clients./workouts/
: CRUD operations for workout sessions.
- Implemented Gym, Trainer, Client, and WorkoutSession models as per the requirements.
- Established appropriate relationships between the models.
- Created GymSerializer, TrainerSerializer, ClientSerializer, WorkoutSessionSerializer for data validation and JSON conversion.
- Implemented API views using Django REST Framework's ModelViewSet.
- Defined queryset and serializer classes for each view.
- Configured API URLs for CRUD operations on gyms, trainers, clients, and workout sessions.
- Named the API URLs appropriately.
- Created comprehensive API documentation detailing available endpoints, request/response formats, and authentication (if any).
- Implemented token-based authentication for the API.
- Configured permissions to restrict access to specific endpoints based on roles (e.g., trainers modifying workout sessions).
- Implemented robust error handling, returning appropriate HTTP status codes and error messages for various scenarios (e.g., invalid input, non-existent resources).
- Provided a Postman collection containing requests for all API endpoints.
- Shared the Postman collection to facilitate testing and validation of the API endpoints.
This project's analogy considers the Gym as the blog platform, Trainers as Authors, Clients as Users, and WorkoutSessions as Posts. The relationship between Trainer and Gym represents a 1:1 relationship, while the relationship between Client and WorkoutSession represents a 1:n relationship.
Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or create a pull request.
This project is licensed under the MIT License.