MediBridge is a comprehensive healthcare platform that connects patients, doctors, and medical suppliers in one integrated ecosystem. The platform includes various features like medicine ordering, doctor consultations, and an AI-powered medical assistant called Healia.
The project consists of two main components:
- Frontend - React-based user interface
- MediBridge AI - Node.js backend for the Healia AI assistant
- Node.js (v16 or higher)
- npm or yarn
- Go language runtime (for the main backend)
Navigate to the Frontend directory:
cd FrontendInstall dependencies:
npm installStart the development server:
npm run devThe frontend should now be running at http://localhost:5173
Navigate to the MediBridge AI directory:
cd medibridge-aiInstall dependencies:
npm installCreate a .env file in the medibridge-ai root directory with the following content:
PORT=3000
OPENAI_API_KEY=your_openai_api_key_here
Replace your_openai_api_key_here with your actual OpenAI API key.
Start the AI server:
npm run devThe AI server should now be running at http://localhost:3000
Once both the frontend and AI server are running:
- Navigate to the MediBridge homepage
- Click on the "Healia AI" button in the navigation bar
- You can now interact with the AI assistant by typing questions about medical symptoms, first aid, and health advice
- Real-time communication: Uses Socket.IO for real-time chat with the AI
- Fallback to REST API: Automatically falls back to REST API if WebSocket connection is unavailable
- Medical knowledge base: Includes first aid information and common condition advice
- OpenAI integration: Uses GPT-3.5 for complex medical queries
- Frontend: React, TailwindCSS, Three.js for 3D backgrounds
- AI Backend: Express.js, Socket.IO, OpenAI API
- Communication: WebSockets (primary) with REST API fallback
If you encounter connection issues with the AI:
- Ensure both servers are running
- Check that the port (3000) is not being used by another application
- Verify that your OpenAI API key is valid and has sufficient credits
- Check the browser console and server logs for any error messages
MIT
MediBridge offers a complete solution for managing medical inventory, patient profiles, doctor appointments, and pharmaceutical needs. The system includes:
- User Management: Separate authentication flows for patients, doctors, and medicine sellers
- Medicine Inventory: Complete medicine management with expiry tracking
- Cart System: Shopping cart functionality for medicine purchases
- Doctor Directory: Searchable doctor listings by specialization
- AI Assistant: "Aliza" - an AI agent to help users find medicines and doctors
- Secure API: Token-based authentication with secure access control
- Backend: Go (Golang) with Gin web framework
- Database: PostgreSQL with sqlc for type-safe SQL
- Authentication: PASETO tokens for secure authentication
- Email: Integrated email notifications for medicine expiry
- Docker: Containerization for easy deployment
- Go 1.16+
- Docker and Docker Compose
- PostgreSQL
- migrate CLI tool for database migrations
- Clone the repository
git clone https://github.com/your-username/MediBridge.git
cd MediBridge
- Start the PostgreSQL container
make postgres
- Create the database
make createdb
- Run database migrations
make migrateup
- Generate SQL code
make sqlc
- Start the server
make server
The server will start at http://localhost:8080 by default.
The database is structured with the following main entities:
- Users (Patients, Doctors, Sellers)
- Medicines
- Cart Items
- Patient Profiles
Database migrations are managed using the migrate tool. To create a new migration:
make migration name=add_new_feature
To apply migrations:
make migrateup # Apply all pending migrations
make migrateup1 # Apply only the next pending migration
To rollback migrations:
make migratedown # Rollback all migrations
make migratedown1 # Rollback only the last applied migration
All protected endpoints require a Bearer token in the Authorization header:
Authorization: Bearer {token}
POST /api/patients: Register a new patientPOST /api/loginpatient: Patient loginPOST /api/doctors: Register a new doctorPOST /api/logindoctor: Doctor loginPOST /api/sellers: Register a new medicine sellerPOST /api/loginseller: Seller login
GET /api/medicines/:id: Get medicine detailsGET /api/medicines/search: Search medicinesPOST /api/medicines: Add new medicine (Seller only)PUT /api/medicines: Update medicine (Seller only)DELETE /api/medicines/:id: Delete medicine (Seller only)
POST /api/cart: Add item to cartGET /api/cart: Get cart itemsPUT /api/cart/:id: Update cart item quantityDELETE /api/cart/:id: Remove item from cartDELETE /api/cart: Clear cartGET /api/cart/count: Get cart item count
GET /api/doctors/:username: Get doctor detailsPUT /api/doctors: Update doctor profile (Doctor only)
POST /api/aliza/query: Query the AI agent
Aliza is an AI assistant integrated into MediBridge that helps users with:
- Finding suitable medicines based on described conditions and allergies
- Locating doctors based on specialization
Aliza uses pattern matching to understand user queries and provide relevant responses using the MediBridge database.
Send a natural language query to Aliza:
POST /api/aliza/query
{
"query": "What medicine is good for headache?"
}MediBridge/
├── api/ # API handlers and server setup
├── db/ # Database related code
│ ├── migration/ # SQL migrations
│ ├── query/ # SQL queries
│ └── sqlc/ # Generated Go code from SQL
├── ai_agent/ # Aliza AI agent implementation
├── mail/ # Email notification system
├── token/ # Authentication token handling
├── util/ # Utility functions and configurations
├── app.env # Environment configuration file
├── Makefile # Project commands
└── main.go # Application entry point
The project includes several make commands for common tasks:
make postgres: Start PostgreSQL containermake createdb: Create the databasemake migration name=x: Create a new migrationmake migrateup/migratedown: Apply or rollback all migrationsmake migrateup1/migratedown1: Apply or rollback a single migrationmake sqlc: Generate Go code from SQL queriesmake server: Run the development servermake db_docs: Generate database documentationmake db_schema: Generate SQL schema from DBML