Skip to content

About

An advanced Django REST API for managing vaccine campaigns, doctors, patients, and dose centers — with authentication, role-based access, filters, search, secure payments (SSLCommerz) and admin control.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

VaxPlus - REST API for a Vaccination Management System

Django DRF JWT Redis Postgres Vercel

VaxPlus is a secure and scalable RESTful API built using Django and Django REST Framework. This system allows users to register, book vaccination slots, view vaccine details, and manage appointments efficiently. It also includes admin-level capabilities to manage vaccine centers, doses, and more.


🌐 Live Deployment

Infrastructure:

Layer Provider
Backend hosting Vercel (serverless, Python 3.11)
Database Supabase (managed PostgreSQL)
Cache Upstash Redis (production) / Docker Redis (local dev)
Media storage Cloudinary
Payments SSLCommerz
Email SMTP (Djoser activation flow)

🚀 Key Features

  • JWT Authentication – Secure, token-based login and access management
  • Email Activation – Automatic account activation via email upon registration
  • Role-Based Access – Patient / Doctor / Admin permissions across all endpoints
  • User Management – Register, log in, and manage user profiles
  • Doctor Applications – Apply as a doctor with certificate upload; admin approval workflow
  • Campaign Management – Full CRUD operations for vaccination campaigns
  • Vaccination Centers – Create, update, and manage vaccine center details
  • Booking System – Book, reschedule, or cancel vaccination appointments
  • Vaccination Records – Auto-generated history once a booking is marked completed
  • Campaign Reviews – Ratings & comments, restricted to patients who booked/completed a campaign
  • Payment Integration (SSLCommerz) – Secure online payments for vaccination booking
  • Admin Panel – Manage users, vaccine info, and appointment data
  • Advanced Filters – Filter campaigns by category, date, status, and more
  • Search & Ordering – Search by campaign or vaccine title and description; order by date or relevance
  • API Documentation – Integrated Swagger and ReDoc for easy API exploration

📈 Performance Optimizations

  • Reduced repeated API response latency by 82% (2.51s → 0.45s) using Redis (Upstash) response caching with version-based cache invalidation.
  • Reduced Campaign List API database queries by 62.5% (8 → 3) using Django ORM optimization (select_related(), prefetch_related(), Prefetch()).
  • Minimized database overhead by retrieving only required fields with Django's only() QuerySet optimization.
  • Improved API scalability with pagination, filtering, searching, and ordering support.

🛠️ Technologies Used

  • Backend: Django 5.2.1, Django REST Framework 3.16.0
  • Authentication: JWT (SimpleJWT), Djoser
  • Caching: django-redis, Upstash Redis (prod), Docker Redis w/ ACL (local)
  • Database: PostgreSQL via Supabase
  • Docs: drf-yasg (Swagger/ReDoc)
  • Image Handling: Pillow
  • Filtering: django-filter
  • Payment Gateway: SSLCommerz
  • Dependencies: See requirements.txt

📚 API Documentation


🔧 Installation & Local Setup

  1. Clone the repository

    git clone https://github.com/anis191/vaxplus-backend.git
     cd vaxplus-backend
  2. Create & activate virtual environment

    python -m venv .example_env
    # For Windows
    source .example_env/Scripts/activate
    # For macOS/Linux
    source .example_env/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure environment variables Create a .env file in the project root:

    # Database (Supabase Postgres or local Postgres)
    dbname=your_db_name
    user=your_db_user
    password=your_db_password
    host=your_db_host
    port=5432
    
    # Redis (must match the ACL user/password set in redis.conf)
    REDIS_URL=redis://djangoapp:your_local_password@localhost:6379/0
    
    # Cloudinary
    cloud_name=your_cloud_name
    cloudinary_api_key=your_key
    api_secret=your_secret
    
    # Email
    EMAIL_HOST=smtp.example.com
    EMAIL_PORT=587
    EMAIL_USE_TLS=True
    EMAIL_HOST_USER=your_email
    EMAIL_HOST_PASSWORD=your_app_password
    
    # Djoser frontend URLs
    FRONTEND_PROTOCOL=http
    FRONTEND_DOMAIN=localhost:5173
    FRONTEND_URL=http://localhost:5173
    BACKEND_URL=http://127.0.0.1:8000
    
    # SSLCommerz
    STORE_ID=your_store_id
    STORE_PASS=your_store_pass
    IS_SANDBOX=True
  5. Run migrations

    python manage.py migrate
  6. Start development server

    python manage.py runserver
  • API Access: http://127.0.0.1:8000/ (Localhost only)
  • Redis check: docker exec -it <container_name> redis-cli -u redis://djangoapp:your_password@localhost:6379 PING → should return PONG

🔐 Authentication

This API uses JWT (JSON Web Tokens) for secure, stateless user authentication.

📌 Endpoints

Base URL: http://127.0.0.1:8000/api/v1 (Localhost)

🔑 Endpoints

Method Endpoint Description
POST /auth/jwt/create/ Login – Obtain access & refresh tokens
POST /auth/jwt/refresh/ Refresh access token
POST /auth/users/ Register a new user (Sign up) ✅

💡 Note: After registration, use the /auth/jwt/create/ endpoint to log in and receive your JWT tokens.

💳 Payment Integration (SSLCommerz)

Payments are required only for premium vaccination campaigns.

📌 Payment Flow

  1. User selects a premium vaccination campaign.
  2. At checkout, the system redirects to the SSLCommerz hosted payment page.
  3. Upon successful payment, SSLCommerz notifies the system via IPN (Instant Payment Notification).
  4. The campaign booking is confirmed and marked as Paid.

📂 Project Structure

vaxplus-backend/
 ├── vaxplus/ – Django settings & core configuration
 │ ├── __init__.py
 │ ├── settings.py
 │ ├── urls.py
 │ └── wsgi.py
 │
 ├── api/ – API root and endpoint routing
 │ └── (views, urls, models)
 │
 ├── booking/ – Vaccination booking management
 │ └── (models, views, serializers)
 │
 ├── campaigns/ – Vaccine campaigns, categories, vaccines, and centers
 │ └── (models, views, serializers)
 │
 ├── core/ – Shared utilities (Redis caching, decorators, cache helpers)
 │ └── (cache.py, decorators.py, etc.)
 │
 ├── payments/ – SSLCommerz payment integration and payment management
 │ └── (models, views, serializers)
 │
 ├── users/ – Custom user authentication, profiles, and roles
 │ └── (models, views, serializers, urls)
 │
 ├── fixtures/ – Demo/sample data for development
 │ └── campaigns_data.json
 │
 ├── media/ – Uploaded media files
 │
 ├── requirements.txt – Project dependencies
 ├── manage.py – Django management script
 └── README.md – Project documentation

🤝 Contributing

Contributions help make this project better and are always welcome!

How to Contribute

  • ⭐ Star the repo
  • 🍴 Fork the project
  • 📥 Clone your fork
  • 💡 Create a feature branch: git checkout -b feature/awesome-feature
  • ✅ Commit your changes: git commit -m 'Add some feature'
  • 📤 Push your branch: git push origin feature/awesome-feature
  • 🛠️ Open a Pull Request

Ensure your code follows the project standards and passes all tests.


💻 Author

Anisul Alam
Full-Stack Developer | Django | React | PostgreSQL

LinkedIn Portfolio


About

An advanced Django REST API for managing vaccine campaigns, doctors, patients, and dose centers — with authentication, role-based access, filters, search, secure payments (SSLCommerz) and admin control.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages