Skip to content

ram-shankar58/Vaultman

Repository files navigation

File Vault System

A secure file storage and sharing platform with deduplication capabilities.

NOTE: This has been configured to have maximum size of 5MB per normal user, and 10MB per premium/entreprise users!

Quick Start

Prerequisites

  • Docker & Docker Compose
  • Git

Setup

git clone this repo
cd Vaultman
cp .env.example backend/.env
cd backend
docker-compose up -d
 go run cmd/server/main.go

LIkewise make frontend run by

cd frontend
npm install
ng serve

Access at: http://localhost

Access

FIrst register in the register page.

LOgin using the username and password set.

Please go to My Files to view or upload files.

To share, click on the share button. Enter the email of the recipient and give permissions for view alone or to download

UNder shared section, the files shared to you, and also by you are visible.

You can view or download (if permission given) other's shared files, as well as your ones

Working Features

Authentication & User Management

  • User registration and login
  • JWT-based session management
  • Role-based access (admin/user)
  • Secure logout with session cleanup

File Operations

  • File upload with drag & drop
  • File listing and management
  • File download
  • File deletion
  • Storage deduplication (saves space for duplicate files)

Dashboard & Analytics

  • Real-time storage statistics
  • File count and storage usage tracking
  • Deduplication savings display
  • User-specific dashboard

UI/UX

  • Responsive Material Design interface
  • Real-time user state management
  • Loading states and error handling

File Sharing

  • Public file links
  • Permission management for shared files

Advanced Features

  • File versioning
  • Folder organization
  • File search and filtering
  • Bulk operations
  • File preview

Admin Panel

  • User management
  • System-wide analytics
  • Storage quota management

Security & Performance

  • File encryption at rest
  • Rate limiting
  • Audit logging
  • File virus scanning

Architecture

Backend (Go)

cmd/server/          
internal/
├── database/        
├── services/        
├── middleware/      
└── models/          

Frontend (Angular)

src/app/
├── auth/           
├── components/     
├── services/       
├── pages/          
└── shared/         

Design Principles

  • Separation of concerns: Clear distinction between UI, business logic, and data layers
  • Stateless API: JWT tokens for authentication, no server-side sessions
  • File deduplication: SHA-256 hashing prevents duplicate storage
  • Reactive UI: RxJS observables for real-time state updates

Database Schema

Core Tables

users(id, username, email, password_hash, role, account_type, status, created_at, last_login_at)

  • Primary key: id (UUID)
  • Unique: username, email
  • Indexes: email

files(id, name, original_name, size, mime_type, file_path, checksum, owner_id, is_public, download_count, upload_date, deleted_at)

  • Primary key: id (UUID)
  • Foreign key: owner_id → users(id)
  • Indexes: owner_id, checksum
  • Checksum used for deduplication

file_shares(id, file_id, owner_id, shared_with_email, permissions, created_at)

  • Primary key: id (UUID)
  • Foreign keys: file_id → files(id), owner_id → users(id)
  • Indexes: file_id

API Documentation

Authentication Endpoints

POST /api/auth/register

Register a new user account.

Request:

{
  "username": "johndoe",
  "email": "john@example.com",
  "password": "securepassword"
}

Response:

{
  "success": true,
  "message": "Registration successful",
  "user": {
    "id": "uuid",
    "username": "johndoe",
    "email": "john@example.com",
    "role": "user"
  },
  "token": "jwt_token_here"
}

POST /api/auth/login

Authenticate user and receive JWT token.

Request:

{
  "email": "john@example.com",
  "password": "securepassword"
}

GET /api/auth/me

Get current authenticated user information.

Headers: Authorization: Bearer <token>

Response:

{
  "success": true,
  "data": {
    "id": "uuid",
    "username": "johndoe",
    "email": "john@example.com",
    "role": "user"
  }
}

File Management Endpoints

GET /api/files

List all files for authenticated user.

Headers: Authorization: Bearer <token>

Response:

{
  "success": true,
  "data": [
    {
      "id": "file_uuid",
      "name": "document.pdf",
      "size": 1048576,
      "mimeType": "application/pdf",
      "uploadDate": "2024-01-15T10:30:00Z",
      "downloadCount": 5,
      "isDuplicate": false
    }
  ]
}

POST /api/files/upload

Upload a new file with automatic deduplication.

Headers:

  • Authorization: Bearer <token>
  • Content-Type: multipart/form-data

Body: Form data with file field

Response:

{
  "success": true,
  "message": "File uploaded successfully",
  "data": {
    "id": "new_file_uuid",
    "name": "document.pdf",
    "size": 1048576,
    "isDuplicate": false
  }
}

DELETE /api/files/{id}

Delete a file (soft delete).

Headers: Authorization: Bearer <token>

GET /api/files/{id}/download

Download file content.

Headers: Authorization: Bearer <token>

Response: File binary data

Storage Analytics

GET /api/storage/stats

Get storage statistics for authenticated user.

Headers: Authorization: Bearer <token>

Response:

{
  "success": true,
  "data": {
    "totalFiles": 25,
    "actualStorageUsed": 52428800,
    "duplicateFiles": 3,
    "storageSaved": 10485760,
    "savingsPercentage": 16.7
  }
}

Admin Endpoints

GET /api/admin/users

List all users (admin only).

GET /api/admin/stats

Get system-wide statistics (admin only).

Development Setup

Backend Development

cd backend
go mod download
createdb file_vault
go run cmd/server/main.go

Frontend Development

cd frontend
npm install
ng serve

Environment Variables

DB_HOST=localhost
DB_PORT=5432
DB_NAME=file_vault
DB_USER=postgres
DB_PASSWORD=password
PORT=8080

export const environment = {
  production: false,
  apiUrl: 'http://localhost:8080/api'
};

Testing

Backend Tests

cd backend
go test ./...

Frontend Tests

cd frontend
npm test

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors