Skip to content

TelMedSphere/backend

Repository files navigation

πŸ’–TelMedSphere - Backend

🧾 Table of Contents

πŸ“Œ Introduction.
πŸ’‘ Backend API Features.
πŸš€ Technology Stack.
πŸ—οΈ Backend Architecture.
πŸ’₯ Getting Started.
🐳 Docker Setup.
πŸ“‘ API Documentation.
πŸ“Š Environment Variables.
⚑ Project Admin & Mentors.
πŸ’¬ Contributing.
πŸ“‘ License.

πŸ“ŒIntroduction

This repository contains the backend server for TelMedSphere, a telemedicine platform designed to connect doctors and patients virtually. The backend provides RESTful API endpoints to support all the functionality required for the telemedicine application, including authentication, appointment scheduling, payment processing, video consultation management, and medical record handling.

πŸ’‘Backend API Features

🚨 Authentication & User Management:

  • Secure user registration and login system
  • JWT-based authentication
  • Role-based access control (patients, doctors, admins)
  • User profile management and verification

🚨 Appointment Management:

  • Scheduling system for consultation bookings
  • Availability management for doctors
  • Notification system for upcoming appointments
  • Queue management for virtual consultations

🚨 Payment Processing:

  • Secure payment processing with Stripe integration
  • Digital wallet functionality
  • Payment history and reporting
  • Invoice generation

🚨 Medical Records:

  • Electronic prescription generation
  • Medical history storage and retrieval
  • PDF report analysis using AI
  • Secure file uploads and storage using Cloudinary

🚨 Communication Services:

  • Email notifications via Flask-Mail
  • SMS alerts through Twilio integration
  • Template-based communication

πŸš€Technology Stack

Python Flask Mongo Docker Swagger JWT Stripe Twilio

🚨 Core: Python 3.10, Flask
🚨 Database: MongoDB Atlas
🚨 Authentication: Firebase Admin, JWT
🚨 Payment Processing: Stripe
🚨 File Storage: Cloudinary
🚨 Messaging: Twilio, Flask-Mail
🚨 AI Integration: Google Generative AI
🚨 PDF Processing: PyMuPDF
🚨 Security: Flask-Bcrypt
🚨 API Documentation: Swagger, Flasgger
🚨 Containerization: Docker
🚨 Deployment: Vercel

πŸ—οΈBackend Architecture

The TelMedSphere backend follows a RESTful API architecture built with Flask. Here's a high-level overview:

TelMedSphere Backend
β”‚
β”œβ”€β”€ API Routes - Organized by functionality
β”‚   β”œβ”€β”€ Authentication (register, login, profile)
β”‚   β”œβ”€β”€ Appointments (scheduling, management)
β”‚   β”œβ”€β”€ Payments (processing, wallet)
β”‚   β”œβ”€β”€ Medical Records (prescriptions, history)
β”‚   └── Communications (email, SMS)
β”‚
β”œβ”€β”€ Services
β”‚   β”œβ”€β”€ Cloudinary - Image and file storage
β”‚   β”œβ”€β”€ Stripe - Payment processing
β”‚   β”œβ”€β”€ Firebase - Authentication
β”‚   β”œβ”€β”€ Twilio - SMS notifications
β”‚   └── Google Generative AI - Medical report analysis
β”‚
β”œβ”€β”€ Database (MongoDB)
β”‚   β”œβ”€β”€ Users (patients, doctors)
β”‚   β”œβ”€β”€ Appointments
β”‚   β”œβ”€β”€ Medical Records
β”‚   β”œβ”€β”€ Payments
β”‚   └── Feedback
β”‚
└── Utils
    β”œβ”€β”€ PDF Processing
    β”œβ”€β”€ Image Handling
    └── Email Templates

πŸ’₯Getting Started

  • Fork this Repository.
  • Clone the forked repository in your local system.
git clone https://github.com/TelMedSphere/backend.git

πŸ’»Backend Setup

# Navigate to backend directory
cd TelMedSphere/backend

# Set up environment variables
cp .env.example .env
# Edit the .env file with your credentials (MongoDB, Stripe, Firebase, etc.)

# Create a virtual environment
python -m venv venv

# Activate the virtual environment
# For Windows
venv\Scripts\activate
# For Linux/Mac
source venv/bin/activate

# Install all dependencies
pip install -r requirements.txt

# Run the Flask server
flask run

# Access the server at http://localhost:5000
# Access API documentation at http://localhost:5000/api/docs

# Deactivate the virtual environment when done
deactivate

πŸ“ŠEnvironment Variables

The backend requires several environment variables to be set up. Create a .env file in the backend directory with the following variables:

# MongoDB URL
DBURL=your-mongodb_url

# NodeMailer
HOST_EMAIL=your_host_email
PASSWORD=your_app_password
PORT=587

# Stripe
STRIPE_SECRET_KEY=your_stripe_secret_key

# Backend server after deployment
DOMAIN=your_domain

# JWT Secret for encryption
SECRET=your_secret_key

# WhatsApp Notification
TWILIO_WHATSAPP_ACCOUNT_SID="ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
TWILIO_WHATSAPP_AUTH_TOKEN="your_auth_token"
TWILIO_WHATSAPP_FROM="whatsapp:+1234567890"

# Firebase Authentication Keys
FIREBASE_TYPE=service_account
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_PRIVATE_KEY_ID=your-private-key-id
FIREBASE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\\nyour-private-key\\n-----END PRIVATE KEY-----\\n
FIREBASE_CLIENT_EMAIL=firebase-adminsdk-xxxxx@your-project-id.iam.gserviceaccount.com
FIREBASE_CLIENT_ID=your-client-id
FIREBASE_AUTH_URI=https://accounts.google.com/o/oauth2/auth
FIREBASE_TOKEN_URI=https://oauth2.googleapis.com/token
FIREBASE_AUTH_PROVIDER_CERT_URL=https://www.googleapis.com/oauth2/v1/certs
FIREBASE_CLIENT_CERT_URL=https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-xxxxx%40your-project-id.iam.gserviceaccount.com
FIREBASE_UNIVERSE_DOMAIN=googleapis.com

# Cloudinary Authentication Keys
CLOUDINARY_CLOUD_NAME="your-cloud-name"
CLOUDINARY_API_KEY="your-api-key"
CLOUDINARY_API_SECRET="your-api-secret"

# Gemini Authentication
GEMINI_API_KEY="your-api-key"

For detailed setup instructions, refer to the complete Environment Variables Setup Guide.

🐳Docker Setup

The backend can be easily deployed using Docker.

Prerequisites

  • Docker installed on your system
  • Environment variables ready for configuration

Steps to Run Backend with Docker

  1. Clone the repository:
git clone https://github.com/TelMedSphere/backend.git
cd TelMedSphere/backend
  1. Set up environment variables:
cp .env.example .env
# Edit the .env file with your credentials
  1. Build and run the Docker container:
docker build -t telmedsphere-backend .
docker run -p 5000:5000 --env-file .env telmedsphere-backend

The backend API will be available at http://localhost:5000.

Stopping the Container

docker stop <container_id>
# Or with docker-compose
docker-compose down

πŸ“‘API Documentation

The backend API is documented using Swagger following the OpenAPI Specification.

API Documentation URLs:

# Local Development
http://localhost:5000/api/docs

# Production
https://telmedsphere-server.vercel.app/api/docs

Key API Endpoints:

# Authentication
POST /api/auth/register - Register a new user
POST /api/auth/login - Authenticate a user
GET /api/auth/profile - Get user profile

# Appointments
GET /api/appointments - List user appointments
POST /api/appointments - Create a new appointment
PUT /api/appointments/:id - Update appointment details

# Payments
POST /api/payments/create-payment-intent - Create payment intent
GET /api/payments/history - Get payment history

# Medical Records
POST /api/prescriptions - Create a prescription
GET /api/prescriptions/patient/:id - Get patient prescriptions
POST /api/reports/analyze - Analyze medical reports using AI

# Admin
GET /api/admin/users - List all users (admin only)
PUT /api/admin/users/:id - Update user status (admin only)

⚑Project Admin and Collaborators

Pratik Mane
Pratik Mane
(Project Admin)
Pratik Mane
Harshwardhan Patil
(KWoC Mentor)
Pratik Mane
Aditya Bavadekar
(SWoC Mentor)
Raj Khanke
Raj Khanke
(DWoC Mentor)

πŸ’¬Contributing

forthebadge

We welcome contributions to the backend of TelMedSphere. If you're interested in contributing:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature-name)
  3. Make your changes
  4. Run tests to ensure functionality
  5. Commit your changes (git commit -m 'Add some feature')
  6. Push to the branch (git push origin feature/your-feature-name)
  7. Open a Pull Request

Read our Contributing Guidelines for more details.

🧾License

This project is licensed under the Apache License 2.0. See the LICENSE file for more details.

 Copyright 2025 Pratik Mane

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

Releases

No releases published

Packages

No packages published

Contributors 36