How princeunadkat-dev/text-storage works
Project Type and Purpose
• Full-stack single-page web application with a static frontend and a minimal Node.js backend proxy.
• Purpose: Let users store/retrieve text in Firebase, generate QR codes, copy text, and send it via email (without exposing secrets).
File Structure
• Top-level files:
– index.html, script.js → Static frontend
– server.js → Express backend proxy for email
– .env → Secrets for Sendinblue/Brevo API (gitignored)
– CNAME → Custom domain configuration
• No separate “src” folders; everything lives at root, simplifying component boundaries.
Key Architecture Insights from README
• Frontend directly communicates with Firebase for storage.
• Frontend POSTs to /send-email on the Node.js server to relay email requests securely.
• Backend uses express, node-fetch, cors, and dotenv to call Sendinblue/Brevo’s API.
• QR-generation and copy-to-clipboard handled entirely in the browser.
Main Components and Their Roles
a. User Browser (Client)
– index.html, script.js
– UI: dark theme, card layout, chat-style animation
– Libraries: Firebase SDK, QR-code JS library
b. Static Hosting Layer
– Serves index.html & script.js (can be Netlify, Vercel, S3 + CloudFront)
c. Firebase
– Data storage & retrieval (Realtime Database or Firestore)
– Provides JS SDK endpoints
d. Node.js Backend (server.js)
– Endpoint: POST /send-email
– Reads API key & sender info from .env
– Uses express + cors + node-fetch → Sendinblue/Brevo REST API
e. External Email Service (Sendinblue/Brevo)
– Actual mail delivery
Architectural Patterns & Principles
• Separation of concerns: UI vs. business logic vs. secret management.
• Client-heavy app: most logic (QR, clipboard, Firebase calls) lives in browser.
• Backend as a secure proxy for email to protect API keys.
• Static vs. dynamic: Static hosting for UI, dynamic Node.js for protected operations.