Cloud File Storage System is a full-stack web app for secure file uploads, storage, and management. The backend is built with FastAPI and MongoDB, and the frontend is built with React and Vite.
- Lets users register and log in securely.
- Issues a JWT token after successful login.
- Stores uploaded files in AWS S3.
- Saves file metadata in MongoDB.
- Protects file actions so only the signed-in user can access their own files.
- Enforces a 1 GB storage limit per user.
- Frontend: React, Vite, React Router, Axios, Tailwind CSS, React Icons
- Backend: FastAPI, Motor, MongoDB, JWT, bcrypt, Boto3
- Storage: AWS S3
- A user registers with a name, email, and password.
- The backend hashes the password before saving it in MongoDB.
- During login, the backend checks the email and password.
- If the credentials are valid, the backend returns a JWT access token.
- The frontend stores that token in
localStorage. - Protected requests send the token in the
Authorization: Bearer <token>header.
- The user selects a file from the dashboard.
- The frontend sends the file to the backend.
- The backend checks the logged-in user from the JWT token.
- The backend checks how much storage the user has already used.
- If the total is within the 1 GB limit, the file is uploaded to AWS S3.
- File metadata such as filename, size, type, owner, and URL is saved in MongoDB.
GET /files/my-filesreturns the authenticated user’s uploaded files.GET /files/{file_id}fetches one file record owned by the user.DELETE /files/{file_id}removes the file from S3 and deletes its metadata from MongoDB.
backend/- FastAPI API, database logic, authentication, and file servicesfrontend/- React app with login, register, dashboard, and protected routing
app/main.py- FastAPI app entry point and route registrationapp/routes/auth.py- Register and login endpointsapp/routes/files.py- File upload, fetch, and delete endpointsapp/services/auth_service.py- Password hashing and JWT creationapp/services/file_service.py- S3 upload, file lookup, and deletion logicapp/utils/security.py- Token verification and current-user lookup
pages/Login.jsx- Login form and token storagepages/Register.jsx- Registration formpages/Dashboard.jsx- File management screencomponents/ProtectedRoute.jsx- Blocks unauthenticated accessapi/axios.js- Shared Axios client for backend requests
- Open a terminal in
backend/. - Create and activate a virtual environment.
- Install dependencies:
pip install -r requirements.txt- Create a
.envfile fromexample.envand fill in your values. - Start the API server:
uvicorn app.main:app --reload- Open a terminal in
frontend/. - Install dependencies:
npm install- Start the Vite dev server:
npm run devThe backend expects these variables:
MONGO_URL=your-mongodb-url
DATABASE_NAME=your-database-name
SECRET_KEY=your-secret-key
AWS_ACCESS_KEY=your-aws-access-key
AWS_SECRET_KEY=your-aws-secret-key
AWS_BUCKET_NAME=your-s3-bucket-name
AWS_REGION=your-aws-regionPOST /auth/register- Register a new userPOST /auth/login- Log in and receive a JWT tokenGET /auth/me- Get the current authenticated user
POST /files/upload- Upload a fileGET /files/my-files- Get files for the current userGET /files/{file_id}- Get a single file recordDELETE /files/{file_id}- Delete a file
- The frontend login request must send JSON with
emailandpassword. - The backend CORS settings already allow the local Vite dev servers on ports
5173and5174. - The app is designed for user-specific storage, so all file actions are protected by JWT authentication.