Skip to content

CRUD project related to Fitness centers using Django Rest Framework

Notifications You must be signed in to change notification settings

mdjaved24/Fitness-Center-Management-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‹๏ธโ€โ™‚๏ธ Fitness Center Management API

A secure and flexible Django REST Framework based API to manage fitness centers like gyms, yoga studios, and more. The API supports full CRUD operations, JWT authentication, and custom filtering options for listing and managing centers.


๐Ÿ“Œ Features

  • โœ… User Registration & JWT Authentication
  • โœ… Create, Read, Update, Delete (CRUD) Fitness Centers
  • โœ… Role-Based Permissions (Owner, Admin)
  • โœ… Filter & Sort Centers by:
    • Monthly fee (min/max)
    • Facilities (search)
    • Verified status
    • Category (via URL param)
    • Established date and fee (ordering)
  • โœ… Owner-only update/delete
  • โœ… Test Coverage using APITestCase

๐Ÿ› ๏ธ Tech Stack

  • Backend: Django, Django REST Framework
  • Auth: JWT (djangorestframework-simplejwt)
  • Database: SQLite (default)
  • Testing: Django APITestCase

๐Ÿ“ Project Structure

fitness_app/
โ”‚
โ”œโ”€โ”€ models.py           # FitnessCenter model
โ”œโ”€โ”€ views.py            # API views with permissions
โ”œโ”€โ”€ serializers.py      # Serializers (not shown here)
โ”œโ”€โ”€ tests.py            # Full test cases using APITestCase

fitness/
โ”œโ”€โ”€ urls.py             # Routes for API endpoints

๐Ÿ” Authentication

Uses JWT Authentication for secure login.

  • Register: POST /api/auth/register/
  • Login: POST /api/auth/login/
    Returns access and refresh tokens.

Include Authorization: Bearer <access_token> in headers for protected routes.


๐Ÿ“ก API Endpoints

Method Endpoint Description
POST /api/auth/register/ Register a new user
POST /api/auth/login/ Login and get JWT token
GET /api/centers/ List all centers (with filters)
POST /api/centers/ Create a new center (Authenticated)
GET /api/centers/<pk>/ Get details of a center
PUT/PATCH /api/centers/<pk>/ Update center (Owner only)
DELETE /api/centers/<pk>/ Delete center (Owner only)
GET /api/centers/<category>/ Get centers by category (e.g., YOGA)

๐Ÿงช Key Test Cases Covered

  • โœ… User registration & JWT login
  • โœ… Fetching center list with filters
  • โœ… Ordering by monthly fee and established date
  • โœ… Owner-based update and delete permission checks
  • โœ… Validation:
    • Minimum monthly_fee
    • Valid established_date
    • Unique name

๐Ÿ“Š Filtering & Sorting Query Params

You can pass query parameters like: /api/centers/?min_fee=1000&max_fee=1500&facilities=Showers&ordering=-established_date

  • min_fee: Minimum monthly fee
  • max_fee: Maximum monthly fee
  • facilities: Case-insensitive match in facilities text
  • is_verified: Filter by verification status
  • ordering: Fields like monthly_fee or -established_date

๐Ÿงฎ Bonus Field (Derived)

  • price_per_session is calculated as:
  • price_per_session = monthly_fee / total_sessions

Returned as part of the center's response.


๐Ÿงช Running Tests

python manage.py test

Runs all test cases under fitness_app/tests.py.


๐Ÿš€ Getting Started (Locally)


git clone https://github.com/yourusername/fitness-api.git
cd fitness-api

Install dependencies

pip install -r requirements.txt

Run migrations


python manage.py makemigrations
python manage.py migrate

Create superuser (optional)

python manage.py createsuperuser

Run server

python manage.py runserver

๐Ÿ“Œ Requirements

  • Django >= 4.0
  • djangorestframework
  • djangorestframework-simplejwt

๐Ÿ‘จโ€๐Ÿ’ป Author

Md Javed
Django & DRF Developer | Data Scientist
GitHub Profile


About

CRUD project related to Fitness centers using Django Rest Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages