How vishruthb/melo works
Project Type and Purpose
• This is a single-page, ML-driven web application built on Streamlit that allows end users (patients) to upload images of skin lesions, get an on-the-fly melanoma risk assessment, track history, and generate referral packages.
• It combines a Streamlit frontend, Python business‐logic modules for model loading and PDF/ZIP generation, a custom EfficientNet inference model, secure Auth0 authentication, MongoDB Atlas storage, and the Gemini external API for email drafting.
File Structure
• Top-level files:
• .streamlit/config.yml: Streamlit and secrets configuration (Auth0 client ID/secret, MongoDB URI, Gemini API keys).
• main.py: The Streamlit UI definition (pages, widgets, sidebar, session state management).
• loader.py: Model‐loading utility, wraps the EfficientNet B0 checkpoint (best.pt) in a cached resource.
• pdfgen.py: Functions to assemble referral PDFs (ReportLab) and ZIP archives.
• requirements.txt: Lists Python dependencies (Streamlit, pymongo, reportlab, Auth0 component, PIL, etc.).
• model.ipynb: Experiment notebook (not part of deployment).
• No separate “frontend”/“backend” folders—Streamlit serves both UI and business logic in one process.
Extract Architecture from README
• Authentication via Auth0 (OAuth/OIDC flows).
• MongoDB Atlas used to store scan history (results collection, grouped by user).
• Real-time inference via custom EfficientNet model.
• External Gemini API for generating referral emails.
• ReportLab + in-memory PIL buffers for PDF creation; ZIP packaging for downloads.
Main Components
a. Client Layer
• User’s Web Browser (HTTP/S over Streamlit Cloud or localhost)
b. Application Server (Streamlit Process)
• UI Module (main.py)
• Model Loader (loader.py + best.pt)
• PDF/ZIP Generator (pdfgen.py)
• Session & State Manager (st.session_state)
c. Data Layer
• MongoDB Atlas (hosted, HIPAA-compatible)
d. Authentication Service
• Auth0 (OAuth/OIDC endpoints)
e. External AI Service
• Gemini API (email generation)
Relationships and Data Flows
• From the Streamlit server:
• Internal flow from PDF Generator to user-download endpoint (ZIP/PDF).
Architectural Patterns and Design Principles
• Monolithic Streamlit server that uses modular Python files for separation of concerns (UI vs. model vs. PDF logic).
• Cache pattern (@st.cache_resource) for efficient model reuse.
• OAuth security boundary between front end and Auth0.
• Layered architecture: presentation (Streamlit UI), business logic (inference, PDFgen), data persistence (MongoDB), external services.
Relevant Technologies and Libraries
• Streamlit (UI framework)
• Python 3.x modules: pymongo, auth0‐component, reportlab, PIL, BytesIO
• EfficientNet B0 model (torch or tensorflow depending on loader)
• MongoDB Atlas (SRV connection string)
• Gemini API (HTTP/REST with streaming responses)
Detail Without Overthinking
• Data flows—authentication tokens, images, inference results, PDF streams—are represented.
• Keep the layout clean: group related components (all external services on one side, data stores on another) and minimize crossing lines.