Create an API called Personal Data Locker, a secure and decentralized platform for storing and retrieving personal files, notes, and encrypted information. The system ensures data integrity and high security without relying on third-party services like paid cloud storage or PostgreSQL.
-
User Authentication and Authorization:
- Implement JWT-based authentication.
- Password hashing using bcrypt or another secure Go library.
- User roles: Admin and Regular User.
-
Data Storage:
- Store data as encrypted files or JSON-like structures in SQLite or BoltDB (a lightweight key-value store).
- Each user has a separate namespace for their stored data.
-
File Upload and Download:
- Allow users to upload small files (like PDFs, images, or text files) with metadata.
- Use a secure folder structure on the server to organize files by user.
- Implement rate-limiting for file uploads.
-
Data Encryption:
- Encrypt sensitive files and notes using Go's
crypto
package before storage. - Ensure the encryption key is user-specific and never stored on the server.
- Encrypt sensitive files and notes using Go's
-
Searchable Metadata:
- Allow users to tag their data with searchable metadata (e.g., file type, creation date, tags).
- Implement efficient search functionality.
-
Activity Logs:
- Log user activities such as logins, uploads, and downloads into an activity log stored locally.
-
API Documentation:
- Use Swagger or Postman to provide comprehensive API documentation.
-
Local Deployment:
- Package the API for easy local deployment using Docker or a simple installation guide.
-
WebSocket Notifications:
- Real-time notifications for file upload/download activities.
-
Version Control:
- Allow users to upload new versions of existing files, retaining previous versions for download.
-
Offline Sync:
- Provide a CLI tool (also written in Go) to sync local files with the server.
-
Role-based Data Sharing:
- Implement a feature where users can share specific files or data with other registered users.
-
Backup & Restore:
- Allow users to export their data as encrypted zip files for backup.
- Provide a restore endpoint for uploading backups.
- API Design: RESTful API principles with clean and efficient routes.
- Security: JWT, encryption, rate-limiting, and secure file storage practices.
- Database Management: Using SQLite or BoltDB creatively for structured data storage.
- Concurrency: Handle simultaneous requests effectively using Go routines.
- Documentation: API usability and onboarding for developers.
- Packaging and Deployment: Dockerize and deploy locally or on a low-resource server.
- Define the Schema: Plan user models, file metadata structures, and database schema.
- Choose Libraries:
- SQLite: Use
gorm
orsqlx
for database interaction. - JWT:
github.com/golang-jwt/jwt/v4
. - File encryption:
crypto/aes
. - CLI Sync Tool:
cobra
for CLI tool creation.
- SQLite: Use
- Implementation Plan:
- Start with user authentication and database setup.
- Build core CRUD functionality.
- Implement encryption and file upload/download.
- Add search and metadata tagging.
Would you like me to help you with any specific aspect, like structuring the database, setting up a project skeleton, or designing the API endpoints?
Packages used:
"github.com/blacac3/go-rest-api/internal/api"
"golang.org/x/crypto/argon2"
"github.com/go-playground/validator/v10"
"github.com/stretchr/testify/assert"
"github.com/mattn/go-sqlite3"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"