Skip to content

Simple File Sharing - my attempt at writing a Google Drive clone backend in Rust, for my final year project. Currently I'm maintaining it just for fun, won't make it big.

License

Notifications You must be signed in to change notification settings

VintageWander/simple-file-sharing-backend

Repository files navigation

Simple file sharing backend

This is the backend for my simple file sharing service that I made for my final project, in order to graduate from my university.

I'm happy to report that all of the main functionalities are completed


Tech Stack

  1. Backend code written in Rust.
  2. Connects to PostgreSQL
  3. Modeling using Prisma
  4. File stored on AWS S3
  5. Local S3 Minio

Features list ( implemented )

User:

  • See all users
  • Create new user
  • Update user
  • Delete user

Folders:

  • See all public folders
  • See all personal folders
  • See all "shared to me" folders
  • Create new folders
  • Update folders
  • Delete folders
  • Manage folder's collaborators
  • Download folder
  • Manage folders' tags

Files:

  • See all public files
  • See all personal files
  • See all "shared to me" files
  • Create new files
  • Update files
  • Delete files
  • Manage file versions
  • Manage file's collaborators
  • Download file
  • Access to file temporary
  • File extensions unrestricted
  • Manage files' tags

Tags

  • Create new tags
  • Delete tags
  • Manage tags of files or folders

Collaboration

  • Add collaborator to files
  • Add collaborator to folders
  • Delete collaborators from files
  • Delete collaborators from folders

How to deploy locally

Adding certificates and keys

This server now runs https by DEFAULT
If you want to run this app locally, you can create some self-signed certificates
The tool mkcert in this example will be used, you can however create certificates and private keys in any certain way that you want
This server's certificates will be stored in /cert

cd cert
mkcert -cert-file localhost.cert -key-file localhost.key localhost
openssl pkcs12 -export -in localhost.cert -inkey localhost.key -out localhost.p12 -name localhost
# Type in your desired lock password
cd minio
mkcert -cert-file public.crt -key-file private.key minio

Finally, copy your CA certificate in the folder
Your /cert folder should look like this:

cert
├── localhost.cert
├── localhost.key
├── localhost.p12
├── minio
│   ├── private.key
│   └── public.crt
└── rootCA.pem

Adjusting variables

  1. Adjust some variables in the docker-compose.prod.yml based on your likings

  2. Wait for the backend container in the stack simple-file-sharing to finish building. Remember to look at the logs

  3. After the stack finished building and running successfully. These are the endpoints for checking the storage and database

  • Database:
    Access https://localhost:5556 to see the database tables and rows (opening Prisma Studio)
    Access https://localhost:5050 to enter pgAdmin4 webpage, can be used for advanced database monitoring

  • By default, the docker-compose stack exposes Minio console to manage the files underneath.
    Access https://localhost:9090 to see the MinIO console, login to see the buckets and data

Troubleshooting

1. If you enter Prisma Studio the first time and it shows up an error:

  • Refresh the webpage

The reason for this error is that the first time you enter Prisma Studio it causes a segmentation fault, that's why I've wrote a script that restarts Prisma Studio if it ever does so. Have a look in the docker-compose.prod.yml file, specifically until npx prisma studio; do :; done;

2. Build time is long and the process is slow

  • I purposely set the build parameters to optimize binary speed and size, sacrificing compile time. I will put up a pre-built image on Docker Hub soon.

About

Simple File Sharing - my attempt at writing a Google Drive clone backend in Rust, for my final year project. Currently I'm maintaining it just for fun, won't make it big.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published