A full-stack PHP/MySQL health & wellness website featuring live medicine search, patient registration, and MediMind β a healthcare-scoped AI chatbot powered by a custom LLM API.
- π Live Medicine Search β Search 100+ medicines by name, generic name, or category with pagination
- π€ Patient Registration β Welcome modal with persistent profile creation (MySQL-backed)
- π€ MediMind AI Chatbot β Healthcare-only conversational AI with multi-turn chat history
- π User Authentication β Secure register/login with server-side session tokens (64-char)
- π¬ Chat Management β Create, rename, and delete consultation sessions; full message history
- π Dark / Light Theme β Toggle persisted via
localStorage - π± Responsive Design β Mobile-friendly layout with real Unsplash photography
- β‘ Graceful Fallback β Pages degrade cleanly if the database is not yet connected
medicare/
βββ index.php # Main website (5 pages + theme toggle + chatbot logo)
βββ api.php # MediMind AI backend (auth, chats, messages, AI relay)
βββ api_medicines.php # JSON API β medicine search with pagination
βββ api_register.php # JSON API β patient registration
βββ config.php # Environment config (DB, API key, models, session TTL)
βββ db.php # PDO singleton + UUID/token helpers
βββ database.sql # Full MySQL schema (users, sessions, chats, messages, logs)
βββ schema.sql # Medicare schema + 100 seed medicines
βββ README.md # This file
| Requirement | Version |
|---|---|
| PHP | 7.4+ (with mysqli & pdo_mysql) |
| MySQL / MariaDB | 5.7+ |
| Web Server | Apache (XAMPP / WAMP / Laragon) or Nginx |
git clone https://github.com/your-username/medicare.git
cd medicareFor the medicine & patient features:
-- In phpMyAdmin or MySQL CLI:
source /path/to/schema.sqlFor the MediMind AI chatbot (auth + chats):
source /path/to/database.sqlEdit config.php with your settings:
define('DB_HOST', 'localhost');
define('DB_PORT', 3306);
define('DB_NAME', 'doss_ai');
define('DB_USER', 'root'); // β your MySQL username
define('DB_PASS', ''); // β your MySQL password
define('API_URL', 'https://api.longcat.chat/openai/v1/chat/completions');
define('API_KEY', 'your_api_key_here'); // β your LLM API keyEdit db.php (legacy mysqli connection for medicine/registration APIs):
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_NAME', 'medicare_db');Place all files in your web server root and open:
http://localhost/medicare/
MediMind is a healthcare-scoped AI assistant β it refuses all non-medical queries at the system-prompt level.
- Symptoms, conditions, and diseases
- Medication info (uses, dosage guidance, side effects)
- Preventive care, nutrition, and wellness
- Mental health awareness and coping strategies
- First aid and emergency guidance
- Chronic disease management (diabetes, hypertension, etc.)
- Women's health, pediatric & geriatric care
- Understanding lab results and medical terminology
| Method | Endpoint | Description |
|---|---|---|
POST |
api.php?action=register |
Create a new user account |
POST |
api.php?action=login |
Authenticate and receive a session token |
GET |
api.php?action=me |
Get the current authenticated user |
POST |
api.php?action=logout |
Invalidate the session token |
GET |
api.php?action=chats |
List all chat sessions |
POST |
api.php?action=chats |
Create a new chat session |
GET |
api.php?action=chat&uuid= |
Get a specific chat |
POST |
api.php?action=chat&uuid= |
Rename / update a chat |
DELETE |
api.php?action=chat&uuid= |
Delete a chat and its messages |
GET |
api.php?action=messages&uuid= |
Fetch full message history |
POST |
api.php?action=send |
Send a message and receive an AI reply |
POST |
api.php?action=profile |
Update display name, avatar color, or password |
All protected endpoints require an X-Auth-Token header with the 64-character session token.
Configured in config.php:
define('ALLOWED_MODELS', [
'LongCat-Flash-Chat',
'LongCat-Flash-Thinking',
'LongCat-Flash-Thinking-2601',
]);| Method | Endpoint | Description |
|---|---|---|
GET |
api_medicines.php |
List / search medicines |
GET |
api_medicines.php?q=paracetamol |
Search by name or generic |
GET |
api_medicines.php?cat=Antibiotic |
Filter by category |
GET |
api_medicines.php?page=2 |
Paginate results (12 per page) |
Response schema:
{
"success": true,
"data": [...],
"total": 100,
"page": 1,
"limit": 12,
"pages": 9
}medicinesβ brand name, generic name, category, dosage form, strength, price (TK), manufacturerpatientsβ full name, email, phone, date of birth, blood group
usersβ username, email, hashed password, display name, avatar colorsessionsβ 64-char tokens with 30-day TTLchatsβ UUID-keyed sessions with title auto-generationmessagesβ role/content pairs with token countsapi_logsβ per-request model usage, token counts, latency, HTTP status
- Passwords are hashed with
PASSWORD_BCRYPT(never stored in plain text) - Session tokens are 64 hex characters generated via
random_bytes(32) - All SQL queries use prepared statements β no raw interpolation
- API model selection is whitelisted server-side; client input is sanitized
- CORS headers are set to
*β restrict in production to your domain
100 medicines pre-loaded covering major categories:
| Category | Examples |
|---|---|
| Antibiotic | Amoxicillin, Ciprofloxacin |
| Analgesic | Paracetamol, Ibuprofen |
| Antidiabetic | Metformin, Glibenclamide |
| Antihypertensive | Amlodipine, Losartan |
| Antihistamine | Cetirizine, Loratadine |
| Antacid | Omeprazole, Ranitidine |
| And more⦠|
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/your-feature - Open a Pull Request
This project is licensed under the MIT License.
MediMind provides general health information only and is not a substitute for professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare provider for medical decisions.