π JCloud - Modern Cloud File Storage System

A high-performance, scalable cloud file storage system built with Go, featuring a clean architecture, comprehensive API, and modern CLI interface.
β¨ Features
π§ Core Functionality
- File Management: Upload, download, delete, and organize files
- Version Control: Track file versions with delta compression
- User Authentication: Secure session-based authentication
- Image Gallery: Dedicated image viewing and management
- File Metadata: Rich metadata support with descriptions and tags
- Hash Verification: SHA-256 file integrity checking
ποΈ Architecture
- Clean Architecture: Separation of concerns with service layers
- Interface-Based Design: Dependency injection and testability
- RESTful API: Comprehensive HTTP API with proper status codes
- Database Layer: SQLite3 with transaction support
- Middleware: Authentication, logging, and error handling
- WebSocket Support: Real-time file synchronization
π₯οΈ Client Applications
- CLI Client: Interactive command-line interface with Cobra
- Desktop App: Rust-based GUI for file selection (egui)
- Web Interface: Modern HTML5 interface
- Admin Panel: Administrative tools and user management
π Quick Start
Prerequisites
- Go 1.23+
- SQLite3
- Rust (for desktop app)
Installation
# Clone the repository
git clone https://github.com/JIIL07/jcloud.git
cd jcloud
# Build the server
go build -o bin/server cmd/server/main.go
# Build the CLI client
go build -o bin/jcloud cmd/cloud/main.go
# Build the desktop app (optional)
cd interactive_file_selector
cargo build --release
Running the Server
# Start the server
./bin/server
# Server will be available at http://localhost:8080
Using the CLI Client
# Login
jcloud login
# Upload a file
jcloud add /path/to/file.txt
# List files
jcloud list
# Download a file
jcloud download filename.txt
# Get help
jcloud --help
π Project Structure
jcloud/
βββ cmd/ # Application entry points
β βββ cloud/ # CLI client
β βββ server/ # HTTP server
βββ internal/ # Private application code
β βββ client/ # CLI client implementation
β β βββ app/ # Application logic
β β βββ cmd/ # CLI commands
β β βββ models/ # Data models
β β βββ requests/ # HTTP client
β βββ server/ # Server implementation
β βββ handlers/ # HTTP handlers
β βββ middleware/ # HTTP middleware
β βββ routes/ # Route configuration
β βββ storage/ # Database layer
β βββ types/ # Interface definitions
β βββ utils/ # Utility functions
βββ pkg/ # Public packages
β βββ hash/ # Hashing utilities
β βββ log/ # Logging utilities
β βββ params/ # Parameter handling
βββ interactive_file_selector/ # Rust desktop app
βββ static/ # Static assets
βββ web/ # Web interface
π§ Configuration
Server Configuration (config/config.yaml)
server:
address: ":8080"
read_timeout: 30s
write_timeout: 30s
idle_timeout: 60s
database:
path: "storage/storage.db"
static:
path: "static/"
env: "development"
Client Configuration (config/client.yaml)
server:
url: "https://jcloud.up.railway.app"
timeout: 30s
storage:
cache_path: "~/.jcloud/cache"
cookie_path: "~/.jcloud/cookies"
hints:
enabled: true
timeout: 5s
π API Endpoints
Authentication
POST /api/v1/login - User login
GET /api/v1/logout - User logout
GET /api/v1/user/{user} - Get current user
File Operations
POST /api/v1/user/{user}/files/upload - Upload files
GET /api/v1/user/{user}/files/list - List files
GET /api/v1/user/{user}/files/images - Image gallery
GET /api/v1/user/{user}/files/{filename}/download - Download file
DELETE /api/v1/user/{user}/files/{filename}/delete - Delete file
GET /api/v1/user/{user}/files/{filename}/info - File information
PATCH /api/v1/user/{user}/files/{filename}/metadata - Update metadata
GET /api/v1/user/{user}/files/{filename}/hash-sum - File hash
Version Control
POST /api/v1/user/{user}/files/{filename}/versions - Create version
GET /api/v1/user/{user}/files/{filename}/versions - List versions
GET /api/v1/user/{user}/files/{filename}/versions/{version} - Get version
GET /api/v1/user/{user}/files/{filename}/versions/last - Get last version
DELETE /api/v1/user/{user}/files/{filename}/versions/{version} - Delete version
GET /api/v1/user/{user}/files/{filename}/restore - Restore to version
Admin
GET /admin/admin - Admin authentication
GET /admin/checkadmin - Check admin status
GET /admin/all-users - List all users
GET /admin/sql - Execute SQL queries
GET /admin/cmd - Execute system commands
ποΈ Architecture Overview
Clean Architecture Principles
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Presentation Layer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β HTTP Handlers β CLI Commands β Desktop App β Web UI β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Business Logic Layer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β File Service β Auth Service β Validation Service β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Data Access Layer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Storage Service β Database Layer β File System β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Design Patterns
- Dependency Injection: Services are injected into handlers
- Interface Segregation: Small, focused interfaces
- Repository Pattern: Data access abstraction
- Service Layer: Business logic encapsulation
- Middleware Pattern: Cross-cutting concerns
π§ͺ Development
Code Quality
This project maintains high code quality standards:
- Linting: golangci-lint with 14 active linters
- Formatting: gofmt with simplification
- Error Handling: Comprehensive error checking
- Documentation: Clean, self-documenting code
- Testing: Unit and integration tests
Running Tests
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run linter
golangci-lint run
# Format code
go fmt ./...
Building
# Build all binaries
make build
# Build server only
make build-server
# Build client only
make build-client
# Clean build artifacts
make clean
π Deployment
Docker
# Build Docker image
docker build -t jcloud .
# Run container
docker run -p 8080:8080 jcloud
Railway
# Deploy to Railway
railway login
railway link
railway up
Manual Deployment
# Build for production
CGO_ENABLED=1 GOOS=linux go build -o jcloud-server cmd/server/main.go
# Run with production config
./jcloud-server
- Concurrent Requests: Handles 1000+ concurrent users
- File Upload: Supports files up to 100MB
- Database: SQLite3 with connection pooling
- Memory Usage: Optimized for low memory footprint
- Response Time: Sub-100ms API responses
π Security
- Authentication: Session-based with secure cookies
- Authorization: Role-based access control
- Input Validation: Comprehensive request validation
- SQL Injection: Parameterized queries
- XSS Protection: Input sanitization
- CSRF Protection: Token-based protection
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Development Guidelines
- Follow Go best practices
- Write comprehensive tests
- Update documentation
- Ensure all linters pass
- Use conventional commit messages
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments