The goal of this project is to implement a simplified Dropbox-like service where users can upload, retrieve, and manage their files through a set of RESTful APIs. Alongside the backend APIs, a basic UI will also be provided to showcase these functionalities. The service should also support the storage of metadata for each uploaded file, such as the file name, creation timestamp, and more.
- POST
/files/upload
Allow users to upload files onto the platform. - GET
/files/{fileID}
Retrieve a specific file based on a unique identifier. - PUT
/files/{fileID}
Update an existing file or its metadata. - DELETE
/files/{fileID}
Delete a specific file based on a unique identifier. - GET
/file
List all available files and their metadata.
Note: Applied a soft delete, instead of hard delete for the file. Wrote a separate cron to delete the file data after 30 days of inactivity.
- File Upload Section: A form to upload a new file and its metadata.
- File List Section: A table or list view that showcases all the files available on the platform.
- File Action Section: Options to download, update, or delete files by interacting with the corresponding APIs.
- Backend: Vanilla Golang with libraries support like Cobra, Gorilla, SQL ORM, etc.
- Database: MySQL (Relational database) to store the files and metadata.
- Frontend: A basic UI developed using ReactJS Framework.
- Storage: Used AWS S3 for storing files, which can be configured using environment file.
- Golang v1.19 or above
- MySQL database (v8.0 or above)
- make (used to run Makefile)
- S3 bucket with public access and following server ACLs: GetObject, PutObject, DeleteObject, ListObject, etc.
- Sample S3 bucket Policy:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1405592139000", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": [ "arn:aws:s3:::bucketname/*", "arn:aws:s3:::bucketname" ] } ] }
- Navigate to the project directory in terminal and fetch all the dependencies using following command:
$ go mod download
- Create and update the .env file in the project directory by using
.env.example
file. Fill in all the necessary values to make connection with the pre-requisites defined above. - Add the required table(s) to your RDBMS system by using commands from
metadata.sql
. Note: This is a one-time step only. Taking this step again will clear all the metadata from RDBMS. - Run the application using terminal by typing:
$ make run
- Navigate to the directory
mini-dropbox-ui
inside the root directory of project. Install all the dependencies using following command:$ npm install
- Create and update the .env.local file in the
mini-dropbox-ui
directory with keyREACT_APP_BACKEND_HOST
. Sample:REACT_APP_BACKEND_HOST="http://localhost:8082"
- Run the React application on local computer using the following command:
$ npm start
- Open your browser and navigate to the UI using the address:
http://localhost:3000
- Graceful shutdown: This avoids any side effects on conflicts that may occur on closing the server and the new deployment can be started without any kind of difficulty.
- Logging: For debugging and monitoring the application on remote servers, it is recommended to log the application functionality.
- Panic Handler: Used to prevent the application from being killed, in case of any runtime errors or application malfunctioning.
- Unit tests
- Caching the RDBMS response, to save DB queries
- Dockerfile - to improve collaboration and ease of working
- Pagination - implement pagination for the listing page to improve performance and efficiency.