Skip to content

Shadow2121/FileSharing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FileSharing - Secure File-Sharing Application

FileSharing is a cloud-based file-sharing platform built on Amazon Web Services (AWS), designed to provide secure file uploads, downloads, and sharing, similar to Google Drive. The application features a React-based web interface for user authentication and file management, with a serverless backend for scalability and cost-efficiency. FileSharing leverages AWS services to ensure high availability, robust security, and seamless user experience, targeting general users like students and professionals.

Features

  • User Authentication: Register and log in securely using email and password, with email verification.
  • File Upload: Upload files via a user-friendly UI, stored securely in the cloud.
  • File Management: View, download, and delete uploaded files, with organized file lists.
  • File Sharing: Share files via temporary pre-signed URLs sent through email notifications.
  • Real-Time Notifications: Receive instant email updates for sign-ups, uploads, and shares.
  • Security: Encrypt files at rest and in transit, restrict access with pre-signed URLs, and audit API calls.
  • Scalability: Handle up to 1,000 daily active users with serverless architecture.

Performance Targets

  • Upload/download latency: <5 seconds for 10 MB files.
  • API response time: <500 ms for authentication and URL generation.
  • Availability: 99.9% uptime, leveraging AWS service SLAs.

Architecture

FileSharing uses a hybrid architecture combining serverless and infrastructure-based AWS services in the us-east-2 region:

  • Frontend: React application hosted on an EC2 instance in a Docker container, served via Nginx.
  • Backend: Serverless AWS Lambda functions handle file operations, authentication, and notifications.
  • Storage: Amazon S3 stores user files and backend code, with AES-256 encryption.
  • Database: Amazon DynamoDB manages user credentials and file metadata.
  • Networking: Amazon API Gateway routes frontend requests to Lambda, with CORS configured for security.
  • Notifications: Amazon SNS sends real-time email notifications for user actions.
  • Authentication: Amazon Cognito provides secure user sign-up and sign-in.
  • Governance: AWS CloudTrail logs API calls for auditing.
  • Deployment: AWS CloudFormation automates infrastructure setup.

Architecture Diagram

Below is the architecture diagram created with Draw.io, illustrating the components and their interactions:

Architecture Diagram

Repository Structure

FileSharing/
├── frontend/                   # React frontend code (Vite)
│   ├── src/
│   │   ├── components/
│   │   ├── Files.jsx         # File management UI
│   │   └── App.jsx           # Main app component
│   ├── public/
│   ├── Dockerfile            # Docker configuration for frontend
│   ├── package.json          # Frontend dependencies
│   └── vite.config.js        # Vite configuration
├── lambda/                     # AWS Lambda functions
│   ├── filesharing_upload.py # File upload logic
│   ├── filesharing_share.py  # File sharing with pre-signed URLs
│   ├── filesharing_list.py   # List user files
│   ├── filesharing_delete.py # Delete files
│   ├── filesharing_confirm.py# User verification
│   ├── filesharing_notify.py # SNS notifications
│   └── requirements.txt      # Lambda dependencies
├── cloudformation/             # Infrastructure as Code
│   └── template.yaml         # CloudFormation template
├── docs/                       # Documentation
│   └── architecture-diagram.png  # Architecture diagram
├── .gitignore                 # Git ignore file
└── README.md                  # This file

Prerequisites

To deploy and run FileSharing, ensure you have:

  • AWS Account: Configured with access to us-east-2 region.
  • AWS CLI: Installed and configured with credentials (aws configure).
  • Node.js: Version 18.x or later for frontend development.
  • Docker: Installed for building and running the frontend container.
  • Python: Version 3.13 for Lambda functions, with pip for dependencies.
  • Git: For cloning the repository.
  • Text Editor: VS Code or similar for code editing.

Setup Instructions

1. Clone the Repository

git clone https://github.com/<your-username>/FileSharing.git
cd FileSharing

2. Configure AWS Credentials

Set up your AWS CLI credentials with a user having permissions for S3, Lambda, EC2, API Gateway, DynamoDB, SNS, Cognito, and CloudFormation.

aws configure

3. Deploy Infrastructure with CloudFormation

  1. Navigate to the CloudFormation directory:

    cd cloudformation
  2. Deploy the stack (replace <stack-name> with your preferred name):

    aws cloudformation create-stack --stack-name <stack-name> --template-body file://template.yaml --capabilities CAPABILITY_NAMED_IAM
  3. Wait for the stack to complete (check status in AWS Console or CLI):

    aws cloudformation describe-stacks --stack-name <stack-name>
  4. Note the outputs (e.g., EC2 public IP, API Gateway URL) for frontend configuration.

4. Build and Deploy the Frontend

  1. Navigate to the frontend directory:

    cd ../frontend
  2. Install dependencies:

    npm install
  3. Build the React app:

    npm run build
  4. Build the Docker image:

    docker build -t filesharing-frontend .
  5. Push the image to a registry (e.g., Docker Hub):

    docker tag filesharing-frontend <your-dockerhub-username>/filesharing-frontend:latest
    docker push <your-dockerhub-username>/filesharing-frontend:latest
  6. Update the EC2 instance (via SSH, using the public IP from CloudFormation outputs):

    ssh -i <your-key.pem> ec2-user@<ec2-public-ip>
    sudo docker pull <your-dockerhub-username>/filesharing-frontend:latest
    sudo docker stop filesharing-container || true
    sudo docker rm filesharing-container || true
    sudo docker run -d --name filesharing-container -p 3000:3000 <your-dockerhub-username>/filesharing-frontend:latest
  7. Configure the frontend to use the API Gateway URL (from CloudFormation outputs):

    • Create a config.js in frontend/src:

      export const API_URL = process.env.REACT_APP_API_URL || 'https://<api-gateway-id>.execute-api.us-east-2.amazonaws.com';
    • Update the Dockerfile to inject the URL at runtime (see frontend/Dockerfile).

5. Package and Deploy Lambda Functions

  1. Navigate to the Lambda directory:

    cd ../lambda
  2. Install dependencies:

    pip install -r requirements.txt -t .
  3. Zip each Lambda function (e.g., for filesharing_upload.py):

    zip -r filesharing_upload.zip filesharing_upload.py .
  4. Upload to S3 (replace <code-bucket> with the S3 bucket from CloudFormation outputs):

    aws s3 cp filesharing_upload.zip s3://<code-bucket>/lambda/
  5. Repeat for other Lambda functions (filesharing_share.py, etc.).

  6. CloudFormation automatically deploys these functions using the S3 code.

6. Access the Application

  • Open a browser and navigate to http://<ec2-public-ip>:3000.
  • Register a new account, verify your email, and log in.
  • Upload files, view your file list, and share files via email links.

Usage

  1. Sign Up: Create an account with your email and password. Check your inbox for a verification code.
  2. Log In: Use your credentials to access the file management dashboard.
  3. Upload Files: Select files via the UI to upload to S3. Receive an email confirmation.
  4. View Files: See your uploaded files with options to download or share.
  5. Share Files: Generate a pre-signed URL for a file and send it via email using SNS.
  6. Delete Files: Remove unwanted files to manage storage.

Security

FileSharing implements robust security measures:

  • Encryption: S3 uses AES-256 for data at rest and in transit.
  • Access Control: Pre-signed URLs (1-hour expiry) restrict file access.
  • Authentication: Cognito secures user credentials with TLS.
  • CORS: API Gateway restricts requests to the EC2 public IP and localhost.
  • Auditing: CloudTrail logs all API calls for traceability.
  • VPC: EC2 resides in a secure VPC with limited ports (22, 3000).

Note: The application uses a single S3 bucket with user-specific folders due to IAM restrictions in the development environment. In production, use separate buckets per user for enhanced isolation.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/your-feature).
  3. Commit changes (git commit -m 'Add your feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a Pull Request.

Please follow the Code of Conduct and ensure tests pass before submitting.

Future Enhancements

  • File Versioning: Store multiple file versions using S3 Versioning.
  • Large File Uploads: Support multi-part uploads for files >100 MB.
  • File Search: Enable metadata-based search with Amazon OpenSearch Service.
  • Monitoring: Add Amazon CloudWatch for performance tracking.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • Built with AWS services.
  • Frontend powered by React and Vite.
  • Architecture visualized with Draw.io.

For issues or questions, open a GitHub issue or contact the maintainer at [email protected].

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published