How kushagraagarwal525/medilocker works
Project Type & Purpose
• Full-stack web application for secure medical records management
• Frontend: React + TypeScript (Vite, Tailwind, Radix UI)
• Backend: Node.js + Express.js API server
• Key features: end-to-end encryption, blockchain verification on Polygon, AI-powered analysis (Gemini), Firebase/Firestore storage
Main Components
a. Frontend
• React App (src/main.tsx, App.tsx, components/)
• UI library (src/components/ui/*)
• Client-side encryption (src/lib/crypto.ts, Web Crypto API)
b. Backend API
• Express server (server.js)
• Routes (routes/users.js, routes/reports.js)
• Business logic modules (ignition/modules/module.ts)
• Configuration (config/firebase.js, blockchain.js, gemini.js)
c. Data Layer
• Firebase Firestore (via Admin SDK, serviceAccountKey.json)
d. Blockchain Layer
• Smart contracts (backend/contracts/)
• Ethers.js + Hardhat (hardhat.config.js) interacting with Polygon network
e. AI Service
• Google Gemini API (via config/gemini.js)
f. External Actors
• Patients & Doctors (UI users)
• Admin/Dev (deployment, Hardhat scripts)
Data Flows & Interactions
• Frontend → Backend API (HTTPS/JSON) for login, report upload/download
• Frontend: encrypts/decrypts medical reports before sending/after receiving
• Backend → Firestore: store/retrieve encrypted blobs & metadata
• Backend → Smart Contracts via Ethers.js: anchor report hashes on Polygon
• Backend → Google Gemini API: send decrypted reports for AI analysis, receive insights
• Config modules supply credentials/endpoints to backend services
Architectural Patterns & Design Principles
• Layered architecture: Presentation (UI), API, Data, External Services
• Separation of concerns: route handlers, service modules, config abstraction
• Secure-by-design: E2E encryption, .env for secrets, strict .gitignore
• Modular UI: reusable Radix-based components under src/components/ui
Detail & Clarity
• UI components under one block to avoid clutter, but call out the crypto/lib module separately
• Every major directory (frontend/src, backend/routes, backend/contracts) maps to a visual component