How mahi-kumari/medikart works
Project Type and Purpose
• This is a full-stack web application called “medikart” for online medicine ordering and doctor consultations.
• The front end is a static HTML/CSS/JS client. The back end is a Node.js/Express REST API that handles user authentication, prescription uploads (with OCR), consultation requests, medicine search, orders, and payments.
File Structure
Top‐level:
· README.md – project overview and feature list
· index.html, login.html, consultation.html, prescription.html, payment.html – static UI pages
· script.js, style.css, variables.scss – front-end logic and styling
· addressRoutes.js, authRoutes.js, consultationRoutes.js, prescriptionRoutes.js, server.js, db.js – root‐level server files (potentially legacy or alternative entrypoint)
· /uploads – storage for uploaded prescriptions
· /image – static assets
backend/
· backend/server.js – main Express application entrypoint
· backend/db.js – MySQL connection logic
· backend/routes/*Routes.js – Express route definitions for address, auth, consultation, prescription
· backend/uploads – nested storage for uploaded files
· backend/google-credentials.json.json – Google Cloud Vision credentials
Observations: MVC-style separation (routes vs. DB config), file upload middleware, nested back-end folder for isolation.
README for Additional Insights
• Uses MySQL to store users, prescriptions, consultation records, orders, locations.
• OCR via Google Cloud Vision API called from the prescription upload endpoint.
• OTP login/signup via Firebase Authentication.
• Real-time medicine search with filters.
• Doctor suggestions using an AI service (could be internal logic or external AI API).
• Payment options: UPI (QR scan), Card (secure entry), COD.
• Location integration saved to DB; delivery charges vary by location.
• WhatsApp integration for support (deep link).
Main Components & Their Interactions
a. Frontend (Client)
• Static pages + script.js call REST endpoints over HTTPS.
• Firebase SDK for OTP login.
• File input for prescription uploads.
• UI for browsing medicines, filling consultation form, making payments, and contacting via WhatsApp.
b. Backend (Node.js/Express)
• API Gateway: server.js
• Route Handlers: /auth, /address, /consultation, /prescription
• Business Logic: calls to Firebase Admin SDK, Google Cloud Vision client, AI suggestion engine, and payment gateway SDKs.
• File Upload Middleware: stores in /uploads.
c. Database (MySQL)
• Tables: Users, Prescriptions, Medicines, Orders, Consultations, Locations, etc.
• db.js encapsulates connection pooling and query methods.
d. External Services
• Firebase Auth for OTP verification
• Google Cloud Vision API for OCR
• Payment Gateway (UPI QR service, Card processing API)
• AI service for doctor suggestion (could be an internal microservice or external API)
• WhatsApp Business deep-link URL
Architectural Patterns & Design Principles
• Separation of Concerns: static front end vs. Express REST API vs. DB layer.
• MVC–Lite: routes (controllers) ≠ db.js (models) ≠ static UI (views).
• Modular Routing: each resource (auth, address, prescription, consultation) has its own router.
• Middleware for cross‐cutting concerns: authentication, file uploads, error handling.
• Externalization of credentials and config (google-credentials.json.json).