π Introduction.
π‘ Backend API Features.
π Technology Stack.
ποΈ Backend Architecture.
π₯ Getting Started.
π³ Docker Setup.
π API Documentation.
π Environment Variables.
β‘ Project Admin & Mentors.
π¬ Contributing.
π License.
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.
π¨ 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
π¨ 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
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
- Fork this Repository.
- Clone the forked repository in your local system.
git clone https://github.com/TelMedSphere/backend.git
# 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
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.
The backend can be easily deployed using Docker.
- Docker installed on your system
- Environment variables ready for configuration
- Clone the repository:
git clone https://github.com/TelMedSphere/backend.git
cd TelMedSphere/backend
- Set up environment variables:
cp .env.example .env
# Edit the .env file with your credentials
- 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.
docker stop <container_id>
# Or with docker-compose
docker-compose down
The backend API is documented using Swagger following the OpenAPI Specification.
# Local Development
http://localhost:5000/api/docs
# Production
https://telmedsphere-server.vercel.app/api/docs
# 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)
Pratik Mane (Project Admin) |
Harshwardhan Patil (KWoC Mentor) |
Aditya Bavadekar (SWoC Mentor) |
Raj Khanke (DWoC Mentor) |
We welcome contributions to the backend of TelMedSphere. If you're interested in contributing:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature-name
) - Make your changes
- Run tests to ensure functionality
- Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature-name
) - Open a Pull Request
Read our Contributing Guidelines for more details.
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.