Skip to content
jay77721Public

About

High-throughput distributed cloud storage with chunked uploads, deduplication, MinIO/Local storage, and Vue 3 dark-mode UI.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

99 Commits

Folders and files

Repository files navigation

gofile

Production-grade, AI-powered lightweight self-hosted cloud drive Β· Go 1.25 + Gin + GORM + MySQL + MinIO (S3) + Redis + Asynq + Typesense + Vue 3 (TS)

CI Go Gin GORM MySQL MinIO Asynq Typesense Vue 3 License

Instant fast-upload dedup, S3 multipart direct upload with atomic server-side merge, VFS tree directory, HTTP Range 206 resumable download β€” and, most importantly: manage and retrieve your knowledge assets using natural language.

"Find distributed lock and database optimization materials from last week" β†’ Millisecond-level hybrid search results with AI summaries and auto-generated tags.

δΈ­ζ–‡ζ–‡ζ‘£ Β· Features Β· Quick Start Β· Architecture Β· AI Semantic Search Β· API Reference Β· Observability


✨ Features

πŸ“ Storage & File Capabilities

Feature Technical Implementation & Description
Instant Dedup (Fast Upload) SHA1 hash deduplication + Redis cache acceleration; globally unique physical storage with millisecond-level multi-user ownership association
S3 Multipart Direct Upload (M1) Batch presigned PUT URLs for direct client-to-MinIO streaming, server-side atomic merge (zero proxy I/O), and automatic 24h background GC for abandoned uploads
Virtual File System - VFS (M2) Hierarchical directory tree, Materialized Paths (dir_path), create/rename/move, deep anti-circular nested move prevention, and breadcrumb navigation
Streaming & Resumable Download HTTP Range 206 partial content request handling for video seeking and large-file resume
Intelligent Online Preview Double-layer safe MIME detection (extension + magic bytes), supporting inline preview for images, PDF, code, text, video, and audio
Recycle Bin & Safe Cascading Purge Complete isolation between soft-deleted and active files; purge operations inspect global reference counts and cascade deletion to physical storage and AI indexes only when references reach zero

πŸ€– Intelligent AI Semantic Pipeline (AI_ENABLED=true)

Feature Technical Implementation & Description
Distributed Task Orchestration (M3) Industrial-grade task queue powered by hibiken/asynq + Redis, featuring worker pools, exponential backoff retries (MaxRetry=3), dead-letter queues, and graceful in-memory channel fallback
Auto Summarization & Tagging Asynchronously extracts content and prompts LLM to generate concise summaries (≀100 chars) and structured tags (Docs/Code/Media, etc.)
Natural Language Hybrid Search Natural-language query parsing (temporal resolution like "past 3 days" + type filtering + semantic intent) + full-text & vector hybrid search (RRF fusion)
Per-User AI Provider Config Web UI settings allowing users to configure custom OpenAI-compatible endpoints with AES-GCM encrypted key storage and masked response
Similar Recommendations & Dedup Vector KNN cosine similarity matching for "find similar documents" and near-duplicate detection

πŸ› οΈ Production Engineering & Security

  • Layered Modular Architecture: internal/transport/http handles HTTP, internal/application/service owns use cases, and internal/port separates those use cases from internal/infrastructure adapters.
  • Security Guardrails: 40-character Hex hash validation (path traversal defense), dangerous extension blacklisting (stored XSS defense), HttpOnly + Secure cookies.
  • Distributed Rate Limiting & Locking: Redis + Lua fixed-window rate limiting for auth endpoints (5 req/s) and distributed locks protecting concurrent chunk merges.
  • End-to-End Observability: Request-scoped X-Request-ID log correlation + Prometheus metrics collection + pre-configured Grafana dashboard.
  • Full-Stack TypeScript: 100% Vue 3 SFC <script setup lang="ts"> with unified API contracts and type safety.

πŸ—οΈ Architecture & Topology

                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                             β”‚                 Gin HTTP Server                  β”‚
                             β”‚   RequestID ──▢ Prometheus ──▢ RateLimit Chain   β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                      β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β–Ό                                                             β–Ό
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β”‚ internal/transport/httpβ”‚                                   β”‚ internal/application/ β”‚
           β”‚      /handler          β”‚                                   β”‚       /service        β”‚
           β”‚ β€’ vfs.go (Folders)     │──────────────────────────────────▢│ β€’ vfs_service.go (VFS) β”‚
           β”‚ β€’ multipart.go (S3)    β”‚                                   β”‚ β€’ multipart_service.go β”‚
           β”‚ β€’ download.go (Range)  β”‚                                   β”‚ β€’ trash_service.go     β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                                     β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β–Ό                                                             β–Ό                             β–Ό
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β”‚ internal/infrastructureβ”‚                                   β”‚ internal/infrastructureβ”‚    β”‚ internal/infrastructureβ”‚
           β”‚ GORM + MySQL 8.0       β”‚                                   β”‚ MinIO (S3) ⇄ Local     β”‚    β”‚ Asynq Redis Queue      β”‚
           β”‚ β€’ tbl_file (Dedup)     β”‚                                   β”‚ β€’ S3 Multipart Direct  β”‚    β”‚ (Worker Pool / Retry)  β”‚
           β”‚ β€’ tbl_user_file (VFS)  β”‚                                   β”‚ β€’ HTTP Range 206       β”‚    β”‚ (Fallback In-Mem Chan) β”‚
           β”‚ β€’ tbl_multipart_upload β”‚                                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                                                              β”‚
                       β”‚                                                                                           β–Ό
                       β–Ό                                                                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                                                 β”‚ internal/infrastructureβ”‚
           β”‚     /cache/redis       β”‚                                                                 β”‚     /ai                β”‚
           β”‚ Fast-upload/Lock/Limit β”‚                                                                 β”‚ β€’ LLM Summary & Tags   β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                                                 β”‚ β€’ Typesense Vector KNN β”‚
                                                                                                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

internal/app is the composition root: it loads configuration, opens infrastructure resources, wires internal/port contracts, and owns shutdown. Concrete MySQL, Redis, storage, queue, and AI adapters remain below internal/infrastructure; internal/observability/metrics provides request and business metrics.


πŸš€ Quick Start

Option 1: Docker Compose (Recommended)

git clone https://github.com/jay77721/gofile.git
cd gofile
docker compose -f docker/docker-compose.yml up -d

Service Endpoints:

  • 🌐 Web App: http://localhost:8080
  • πŸ—„οΈ MinIO Console: http://localhost:9001 (Credentials: minioadmin / minioadmin)
  • πŸ” Typesense Search Engine: http://localhost:8108
  • πŸ“ˆ Prometheus Metrics: http://localhost:9090
  • πŸ“Š Grafana Dashboard: http://localhost:3000 (Credentials: admin / admin, includes pre-configured Gofile dashboard)

Option 2: Local Development

# 1. Build frontend (Vue 3 + Vite + TypeScript)
cd web
npm install
npm run build
cd ..

# 2. Install backend dependencies and configure environment
go mod tidy
cp .env.example .env  # edit .env: MySQL is required; Redis/MinIO/Typesense/AI are optional (graceful fallback)
# All keys are documented in .env.example (mirrors internal/config/config.go):
# SERVER_ADDR, COOKIE_SECURE, MYSQL_DSN, UPLOAD_DIR/CHUNK_DIR,
# MINIO_*, REDIS_ADDR/PASSWORD/DB, AI_ENABLED/PROVIDER/API_KEY/MODEL/EMBED_DIM/WORKERS,
# TYPESENSE_*, AI_CONFIG_SECRET, ALLOW_PRIVATE_AI_URL, ASYNQ_ENABLED

# 3. Run backend server (auto-runs migrations/ on startup, loads .env via config.Load())
go run ./cmd/gofile

πŸ§ͺ Testing & CI/CD

The project comes with a comprehensive test suite and multi-stage GitHub Actions CI:

# 1. Run all backend unit & race detector tests
go test -count=1 -race ./...

# 2. Run frontend type check and Vitest tests
cd web && npm run build && npm test && cd ..

# 3. Run performance benchmarks
go test ./internal/common/hash -bench . -benchmem -run '^$'
go test ./internal/infrastructure/storage -bench . -benchmem -run '^$'

πŸ“‘ API Reference

Unified response format: {"code": 0|errorCode, "msg": "...", "data": ...} (code = 0 indicates success).

1. Files & VFS Folder Operations (/file)

Method Route Parameters / Body Description
POST /file/upload file (multipart) Standard file upload / fast-upload dedup
GET /file/meta ?filehash= Query file metadata (includes AI summary and tags)
GET /file/query ?parent_id=0&page=1&size=20 Query VFS folder contents with breadcrumb path navigation
POST /file/folder/create {"name":"Docs","parent_id":0} Create a virtual folder
POST /file/folder/rename {"file_id":1,"new_name":"NewDocs"} Rename folder or file (cascades path updates to subtrees)
POST /file/folder/move {"file_id":1,"target_parent_id":2} Move folder or file (includes anti-circular move prevention)
GET /file/download ?filehash= (supports Range: bytes=0-1024) Streaming download with HTTP Range 206 resume
GET /file/preview ?filehash= Online preview for images/PDF/video/text/code
POST /file/delete filehash (Form) Soft delete file to recycle bin
GET /file/trash ?page=1&size=20 Query recycle bin files
POST /file/restore filehash (Form) Restore file from recycle bin (triggers AI reindexing)
POST /file/purge filehash (Form) Permanently delete (cascades to storage and index on zero references)

2. S3 Multipart Direct Upload (/file/upload/multipart)

Method Route Parameters / Body Description
POST /file/upload/multipart/init {"filehash":"...","filename":"a.zip","filesize":104857600} Initiate S3 multipart session and issue presigned PUT URLs
POST /file/upload/multipart/complete {"upload_id":"...","parts":[{"part_number":1,"etag":"..."}]} Trigger atomic server-side merge on MinIO
POST /file/upload/multipart/abort {"upload_id":"..."} Abort multipart session and clean up storage parts

3. AI Semantic Search & Config (/file/ai & /ai/config)

Method Route Parameters / Body Description
GET /file/ai/search ?q=architecture documents from past 3 days Multi-dimensional natural language hybrid search (RRF)
GET /file/ai/similar ?filehash=...&limit=5 Find semantically similar documents
GET /file/ai/duplicates ?filehash=...&threshold=0.9 Detect near-duplicate documents
GET/POST/DELETE /ai/config {"base_url":"...","api_key":"...","model":"..."} Manage custom OpenAI-compatible provider per user
POST /ai/config/test {"base_url":"...","api_key":"..."} Test custom AI provider connection

πŸ“ Project Directory Structure

gofile/
β”œβ”€β”€ cmd/gofile/                    # Process entrypoint and signal handling
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ app/                       # Composition root and resource lifecycle
β”‚   β”œβ”€β”€ config/                    # Environment configuration loader
β”‚   β”œβ”€β”€ domain/                    # Domain models and invariants
β”‚   β”œβ”€β”€ application/service/       # File, user, share and AI use cases
β”‚   β”œβ”€β”€ port/                      # Cross-layer contracts and ports
β”‚   β”œβ”€β”€ transport/http/            # HTTP router and middleware
β”‚   β”‚   └── handler/               # HTTP controllers and cleanup hooks
β”‚   β”œβ”€β”€ infrastructure/            # Concrete infrastructure adapters
β”‚   β”‚   β”œβ”€β”€ persistence/mysql/     # GORM connection and migrations
β”‚   β”‚   β”œβ”€β”€ persistence/repository/ # MySQL repositories
β”‚   β”‚   β”œβ”€β”€ storage/               # MinIO S3 and local disk adapters
β”‚   β”‚   β”œβ”€β”€ cache/redis/           # Redis cache, locks and rate limiting
β”‚   β”‚   β”œβ”€β”€ queue/asynq/            # Asynq task client and server
β”‚   β”‚   └── ai/                    # LLM, extraction and Typesense adapters
β”‚   β”œβ”€β”€ job/                       # Cancellable background jobs
β”‚   β”œβ”€β”€ common/                    # Hash, crypto, URL and chunk primitives
β”‚   └── observability/metrics/     # Prometheus metrics and request tracing
β”œβ”€β”€ docker/                        # Dockerfile, Compose and monitoring config
β”œβ”€β”€ migrations/                    # golang-migrate versioned SQL scripts
└── web/                           # Frontend SPA (Vue 3 + Vite 6 + TypeScript 5 + Vitest)
    └── src/
        β”œβ”€β”€ components/           # 14 Strict TypeScript Vue components (<script setup lang="ts">)
        β”œβ”€β”€ api.ts                # Strongly-typed API client contract
        └── utils.ts & toast.ts   # Utilities & global toast alerts

πŸ“„ License

Apache License 2.0 Β© 2026 jay77721 β€” see LICENSE for details.

About

High-throughput distributed cloud storage with chunked uploads, deduplication, MinIO/Local storage, and Vue 3 dark-mode UI.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages