Create a backend system for a secure file-sharing platform that allows users to share encrypted text files. Users can register by providing a username, create encrypted files, add other users to access those files, and view decrypted files shared with them. Each user will have a public and private key pair for encryption and decryption. No user authentication or database storage is required.
-
Register User
- Description: Allows users to register by providing a username.
- Request Body:
{ "username": "example_user" }
- Response:
{ "message": "User registered successfully" }
-
Create Encrypted File
- Description: Allows users to create an encrypted file by providing the text content.
- Request Body:
{ "content": "plain_text_content" }
- Response:
{ "message": "File created successfully" }
-
Add User to File
- Description: Allows users to add other users to access the encrypted file.
- Request Parameters: fileId (ID of the encrypted file)
- Request Body:
{ "username": "username_to_add" }
- Response:
{ "message": "User added successfully" }
-
View All Files
- Description: Allows users to view all encrypted files created by all users. Only files shared with the user or created by the user will be decrypted and visible in plain text.
- Response: Array of encrypted file objects
- Users can register with a unique username.
- Users can create encrypted text files.
- Users can add other users to access their encrypted files.
- Encrypted files are decrypted only for the user who created the file or for users added to access the file.
- Each user has a public and private key pair for encryption and decryption.
-
Security:
- Encryption algorithms should be secure (e.g., AES).
- Public and private keys should be securely stored and managed.
-
Performance:
- The system should handle concurrent requests efficiently.
- Response times should be reasonable even with a large number of files and users.
-
Scalability:
- The system should be able to scale horizontally to accommodate increasing numbers of users and files.
-
Reliability:
- The system should be robust and reliable, with minimal downtime.
- Data integrity should be maintained at all times.
-
Usability:
- The API should have clear and intuitive endpoints.
- Error messages should be descriptive and user-friendly.
-
Documentation:
- Comprehensive documentation should be provided for API endpoints and usage.
- Encryption and decryption processes should be documented for developer's reference.
- User authentication is not required; username serves as the unique identifier.
- No database storage is needed; data can be stored in memory or a temporary storage solution (using local JSON DB or plain JS objects, anything should be fine).
- TypeScript and Node.js should be used for development, with the choice of any framework or library for handling HTTP requests and other functionalities
NodeJS, Express, Typescript, File System, Crypto, Joi
- Clone Project :
git clone https://github.com/ppreetii/File-Sharing-Backend.git
- Install dependencies:
yarn or npm install
-
Create .env file in root directory using .env.example, and update with your information
-
To start server locally, run following in project directory terminal:
yarn start or npm start