How mahender-reddy85/dropin works
Project type & purpose (what you’re diagramming)
DropIn is a small full-stack web application for temporary, code/QR-based file transfer:
• Frontend: static HTML/CSS/JS (drag/drop upload, code display, QR gen/scan).
• Backend: Node.js + Express API (upload/download endpoints), uses Multer to receive files, generates a unique 5-digit code (README says UUID is used in backend deps, likely adapted/shortened), stores files + metadata on local disk, and enforces 1-hour expiration.
• The browser UI and its flows (upload, receive, scan).
• The Express API and endpoints.
• The storage model (uploads dir + metadata dir) and expiry cleanup.
• Deployment split: static hosting (Vercel) vs Node server hosting.
From the tree:
Frontend (frontend/)
• index.html → UI entry point (tabs: send/receive, QR modal/button likely)
• script.js → core client logic: calls API, manages progress, QR libraries
• styles.css → theming (CSS variables, dark mode)
• vercel.json → indicates typical deployment to Vercel static hosting
Backend (backend/)
• index.js → single-server entry: Express app, routes, middleware, expiry logic
• package.json / lock → deps: Express, Multer, UUID, CORS, etc.
README also references uploads/ and metadata/ directories created at runtime.
• REST endpoints (/api/upload, /api/info/:code, /api/download/...)
• File persistence to disk
• Metadata persistence (likely JSON files per code, or a simple store)
• Cleanup/expiry mechanism (timer/cron-like interval, or on-read checks)
User Device (Browser)
• Runs: frontend/index.html + script.js + styles.css
• QR libs: QRCode.js (generate), Html5-QRCode (scan)
• Responsibilities: select files, upload with progress, render code/QR, request metadata, download
Static Hosting / CDN (Vercel)
• Serves the frontend assets
• frontend/vercel.json implies rewrites/headers may exist—worth reflecting if it proxies to backend (check file)
Backend API (Node.js / Express)
• backend/index.js
• Middleware: CORS, Multer multipart handling, file size limits
• Responsibilities: code generation, metadata creation, download streaming, expiry enforcement
Storage (Local Filesystem)
• uploads/ directory: actual file blobs
• metadata/ directory: per-code metadata (filenames, sizes, mime types, timestamps, expiry)
• (If metadata is in-memory instead of disk, show that—but README strongly implies disk)
Expiry/Cleanup Worker (logical component)
• deletes expired upload groups after 1 hour
• may run periodically or on each request
Backend (Multer): writes files to uploads/
3. Backend → Metadata store: writes metadata to metadata/ (includes code, file list, createdAt, expiresAt)
Download all flow (group)
• If it’s only metadata, keep it as “list”.
• If it creates an archive, show a “zip/pack” step (CPU/IO) inside backend.
Expiration flow
• Cleanup Worker → uploads/ + metadata/: delete expired entries
• Backend request path performing TTL checks (reject/404 expired code)
Architectural patterns worth highlighting (specific to this project)
• Two-tier web app: Static client + REST API server.
• Ephemeral storage with TTL: Files are not permanent; lifecycle management is a core architectural element.
Labels
• Use explicit names that match the repo:
• “backend/index.js (Express API)”
• “frontend/script.js (client logic)”
• “uploads/ (file blobs)”
• “metadata/ (JSON metadata by code)”
File size limits (Multer limits; mention in component notes)
• [User Browser]
• loads → [Vercel Static Hosting: frontend/]
• calls → [Node/Express API: backend/index.js]
• [Node/Express API]
• writes/reads ↔ [uploads/ (filesystem)]
• writes/reads ↔ [metadata/ (filesystem)]
• runs → [TTL Cleanup / Expiration] (logical subcomponent)
• POST /api/upload (multipart)
• GET /api/info/:code (json)
• GET /api/download/:code/:filename (stream)
• GET /api/download/:code (list/zip?)