How mvarunreddy8203/sendit works
Project Overview
• SendIt is a full-stack file transfer service that allows users to send files to an email address without any signup. It consists of a clear separation between frontend and backend components.
• The frontend is built on React (with Vite as a build tool) and uses ChakraUI for its UI components. The backend is a NodeJS-based server using Express, which handles file uploads, file metadata management (with Firebase Firestore and Firebase Storage), rate limiting via Redis (Upstash), and sending emails via NodeMailer.
Main Components
a. Frontend:
• Represents the user interface where users interact, fill in details (email and file upload), and show status notifications (via the custom toast hook).
• Architecturally, it interacts with the backend via the /upload and /warmup API endpoints.
b. Backend:
• Acts as the API layer handling file upload (POST /upload), file download (GET /download/:fileID), and server warmup (GET /warmup).
• Contains middleware such as the rateLimiter, which consults Redis to prevent abuse.
• Implements background tasks (via a setInterval mechanism) to check and delete expired files.
c. External and Supporting Services:
• Firebase Firestore: NoSQL database for storing file metadata.
• Firebase Storage: For actually storing the uploaded file objects.
• Redis (via Upstash): For in-memory caching and rate limiting.
• Email Service: Managed through NodeMailer (configured with a Gmail account) to send file download links and metadata.
• Optional: Cron-job or periodic pinging mechanism for keeping the backend “warmed up” to counteract Render’s sleep mode.
Relationships and Data Flow
• User submits file and email via the frontend.
• The Frontend sends a POST request to the backend’s /upload endpoint.
• The backend uses Multer to handle file upload, then generates a unique filename using uuid, and uploads the file to Firebase Storage under a ‘files’ folder.
• After the file is stored, file metadata (including upload and expiry dates) is saved in Firestore.
• A signed URL (with 7-day expiry) is generated and returned in response.
• The backend then sends an email (using NodeMailer) with download details to the user.
• Additional data flows:
• GET /download/:fileID: retrieves file metadata, generates a signed URL valid for 15 minutes, and sends the file to the user.
• GET /warmup: used for pinging the backend server to keep it active.
• The rate limiter communicates with Redis to verify request frequency.
• A background worker (using setInterval) periodically checks for and deletes expired files.
Architectural Patterns and Principles
• Layered architecture, with clear separation between frontend (UI), backend (API/business logic), and external services (Firebase, Redis, Email).
• Use of middleware (rateLimiter) and background processing for maintenance tasks.
• Deployment separation: the frontend is deployed on Vercel, and the backend on Render, with environment-specific configuration provided via .env files.