How manrajak/file_trans works
Project Type and Purpose
• Full-stack web application for secure file upload, sharing, and download
• Client: React + Redux (UI, state management)
• Server: Node.js + Express (REST API, business logic)
• Data stores: MongoDB Atlas (metadata), AWS S3 (file storage)
• External services: SMTP (Gmail via Nodemailer), optional QR-code service
Main Architectural Components
a. Frontend (Client)
– React components (pages, dashboards, auth guards)
– Redux Toolkit slices & thunks (authSlice, fileSlice)
– Axios instance (HTTP client)
– Tailwind CSS for styling
b. Backend (Server)
– Express app (app.js, index.js)
– MVC pattern:
• Controllers (user.controller.js, file.controller.js)
• Models (user.models.js, file.models.js)
• Routes (user.routes.js, file.routes.js)
– Middlewares (auth.middlewares.js for JWT, upload.middlewares.js for parsing multipart/form-data)
– Config modules (s3.js for AWS SDK, db/index.js for MongoDB connection)
– Constants (constant.js for app-wide settings)
c. Data Stores & External Services
– MongoDB Atlas (user & file metadata)
– AWS S3 bucket (actual file blobs)
– Gmail SMTP via Nodemailer (email notifications)
– (Optional) QR-code generation library
Interactions & Data Flow
• User opens React UI → Redux state manages session → Axios sends HTTP requests to Express API
• Authentication flow:
– Login/Signup request → user.controller → MongoDB → JWT issued → stored in client (localStorage)
– Protected routes in React check JWT, RequireAuth middleware on server validates token
• File upload flow:
– Client selects file → UploadPage component dispatches fileThunk → Axios multipart POST to /api/files/upload
– upload.middleware parses file → file.controller calls s3.upload → file metadata saved in MongoDB → returns short URL
• File download flow:
– User navigates to share link → Express route fetches S3 URL or streams file → Express updates download count → client triggers browser download
• Email notification flow:
– file.controller calls Nodemailer service → Gmail SMTP sends link to recipient
Architectural Patterns & Design Principles
– Separation of Concerns: UI vs. State vs. API vs. Database vs. Storage
– Layered Architecture:
1. Presentation (React)
2. Application (Redux, Axios)
3. API (Express routes/controllers)
4. Service/Integration (AWS SDK, Nodemailer)
5. Persistence (MongoDB)
– JWT-based authentication (stateless, token in header)
– RESTful API design (CRUD endpoints for users/files)
– Cloud-native storage handling (S3 abstraction via config module)