An API that serves as a cloud backup system
To run the application using Docker Compose, follow these steps:
You need Docker, Gmail email account and and bucket S3 (I reccomend Supabase for this).
To install docker on Linux:
curl -fsSL https://get.docker.com | bash
- Go to the Supabase website.
- Click on the "Start your project" button to sign up or log in if you already have an account.
- After logging in, click on the "New project" button.
- Fill in the required details:
- Project name: Choose a unique name for your project.
- Organization: Select or create an organization.
- Database password: Set a password for your database.
- Region: Choose the region closest to you for optimal performance.
- Click on the "Create new project" button to proceed.
- Once your project is created, navigate to the "Storage" section in the sidebar.
- Click on "Create a new bucket".
- Enter the following details:
- Bucket name: Choose a name for your S3 bucket.
- Public: Decide if you want the bucket to be public or private.
- Click on "Create bucket".
- After creating the bucket, click on the bucket name to open its details.
- Note down the bucket name and the API URL provided by Supabase. You will need these details for your environment variables.
Configure the following environment variables (.env file) to run the application:
-
PORT: Set the port number that your application will listen on.
- Example:
PORT=3000
- Example:
-
DB_URL: Connection string for your PostgreSQL database.
- Example:
DB_URL="host=localhost user=postgres password=password dbname=mydatabase port=5432 sslmode=disable"
- Example:
-
SECRET: Secret key used for JWT authentication.
- Example:
SECRET=auth-api-jwt-secret
- Example:
-
S3_BUCKET: Name of your S3 bucket where files will be stored.
- Example:
S3_BUCKET=mybucket
- Example:
-
S3_REGION: AWS region where your S3 bucket is located.
- Example:
S3_REGION=sa-east-1
- Example:
-
S3_ENDPOINT: Endpoint URL for your S3-compatible storage provider (if using one).
- Example:
S3_ENDPOINT=http://s3-provider-url:9000
- Example:
-
S3_FILEPOINT: Path prefix or directory structure inside the S3 bucket where files will be stored.
- Example:
S3_FILEPOINT=s3/storage/v1/object/public/
- Example:
-
S3_ACCESS_KEY_ID: Access key ID for authenticating with your S3 provider.
- Example:
S3_ACCESS_KEY_ID=my-access-key-id
- Example:
-
S3_ACCESS_KEY: Secret access key corresponding to the access key ID.
- Example:
S3_ACCESS_KEY=my-secret-access-key
- Example:
-
RABBITMQ_HOST: Connection URL for RabbitMQ server.
- Example:
RABBITMQ_HOST=amqp://user:password@localhost:5672/
- Example:
-
SMTPHOST: SMTP server host for sending emails.
- Example:
SMTPHOST=smtp.gmail.com
- Example:
-
SMTPPORT: SMTP server port number.
- Example:
SMTPPORT=587
- Example:
-
SENDER_EMAIL: Email address used as the sender for outgoing emails.
- Example:
[email protected]
- Example:
-
PASSWD_EMAIL: Password or app-specific password for the sender email account.
- Example:
PASSWD_EMAIL=your-email-password
- Example:
Start the application using Docker Compose:
sudo docker compose up -d
For detailed information on how to use the API endpoints, please refer to the API Endpoint Documentation and the included Postman collection postman.json.
The API provides endpoints for user authentication, file management, folder management, and streaming. Each endpoint is documented with its functionality, request methods, required headers, and request/response formats.
- API Endpoint Documentation:
- The API Endpoint Documentation provides comprehensive details about each endpoint, including descriptions, request methods, request bodies, headers, and possible responses.
- Use this documentation to understand the purpose of each endpoint and how to interact with it.
- Postman Collection:
- The postman.json file is a Postman collection that includes all the endpoints with predefined requests.
- Import this file into Postman to test and explore the API easily.
- To import the collection:
- Open Postman.
- Click on the "Import" button.
- Select the
postman.json
file and import it. - You can now see all the API endpoints organized in the collection and can start testing them.
- Sign Up:
/auth/signup
(POST) - Login:
/auth/login
(POST)
- Get User Profile:
/user/profile
(GET) - Check Authentication:
/user/isauth
(GET)
- List Files (v1):
/api/v1/file
(GET) - List Files (v2):
/api/v2/file
(GET) - Upload File:
/api/v1/file
(POST) - Mark File as Unsafe:
/api/v1/unsafe
(POST)
- List Folders:
/api/v1/folder
(GET) - Create Folder:
/api/v1/folder
(POST)
- Stream File:
/stream/:filekey
(GET)
For each endpoint, you will find:
- Endpoint URL: The URL to access the endpoint.
- Method: The HTTP method (GET, POST, etc.) to use.
- Description: A brief description of the endpoint’s functionality.
- Request Body: The required format for sending data to the endpoint (if applicable).
- Headers: Any required headers, such as authorization tokens.
- Response: The expected response, including success and error codes.
Use this information to integrate the API into your applications and ensure correct usage of the endpoints.
Your contributions are welcome! If you encounter any bugs or have feature requests, please open an issue. To contribute code, follow these steps:
- Fork the repository.
- Clone your forked repository to your local machine.
- Create a new branch (git checkout -b feature-or-bugfix-name).
- Make your changes and commit them (git commit -m "Description of your changes").
- Push your branch to your forked repository (git push origin feature-or-bugfix-name).
- Open a pull request with a clear description of your changes.
- Users can create an account with:
- email address
- password
- full name
- Users can upload files up to 200mb - up to 50mb (supabase limit)
- Users can download uploaded files
- Users can create folders to hold files
- An admin user type for managing the content uploaded
- Admins can mark pictures and videos as unsafe
- Unsafe files automatically get deleted
- Users can stream videos and audio
- Compression
- File History
- RabbitMQ:
- New files notifications
- Queue to delete files
.
├── controllers
│ ├── authController.go // Authentication controllers
| ├── authController_test.go // Test for authentication controllers
│ ├── fileController.go // Controllers for file upload/download
| ├── fileController_test.go // Test for file controllers
│ ├── folderController.go // Controllers for folder management
| └── folderControler_test.go // Test for folder controllers
├── example_env // Example of environment variables file
├── go.mod
├── go.sum
├── main.go // Entry point of the application
├── middlewares
│ └── checkAuth.go // Authentication middleware
├── migrate
│ └── migrate.go // Database migration scripts
├── models
│ ├── authInput.go // Models for authentication input data
│ ├── database.go // Initialization and connection with the database
│ ├── file.go // File models
│ ├── folder.go // Folder models
│ ├── loadEnvs.go // Loading environment variables
│ ├── queue.go // Initialization and connection with the RabbitMQ
│ └── user.go // User models
├── services
│ └── rb
│ │ └── services // Notify and Delete queues
│ ├── fileService.go // File business logic
│ └── folderService.go // Folder business logic
├── README.md
├── Dockerfile // Docker file to containerize the application
└── docker-compose.yml // docker-compose file to facilitate container management
- Users can create an account with:
- email address
- password
- full name
- Users can upload files up to 200mb
- Users can download uploaded files
- Users can create folders to hold files
- An admin user type for managing the content uploaded
- Admins can mark pictures and videos as unsafe
- Unsafe files automatically get deleted
- Users can stream videos and audio
- Compression
- File History
- Revokable session management
- Multiple admin reviews before file is deleted
At minimum you must implement everything in simple mode. You're free to pick and choose what else you implement along side it. The harder the task, the better your chances. Though make sure to finish the Simple Mode first.
- NodeJs (TypeScript & Express) or Golang
- Postgres for pure data
- Redis
- Docker
- Postman
- S3 or any other shared cloud storage provider
Unit tests are a must, submissions without tests will be ignored.
7 days
- Your API endpoints should be well documented in POSTMAN.
- Code should be hosted on a git repository, Github preferably.
- The API should be hosted on a live server (e.g. https://heroku.com)
- Your app should be
containerized
usingdocker
. - Share with us through email the:
- Repository
- Hosted API URL
- Postman Collection
- A list of tasks you did beyond Simple Mode