All Phase 1 features have been successfully implemented:
- ✅ User registration with email/password
- ✅ JWT-based authentication (7-day token expiration)
- ✅ Login endpoint
- ✅ Password hashing with Argon2
- ✅ Admin vs. User roles
- ✅ Registration can be disabled via
ALLOW_SIGNUPenv variable - ✅ Auto-creation of admin user on first startup
- ✅ Create projects with unique API keys (UUID-based)
- ✅ List user projects with file statistics
- ✅ Get project details
- ✅ Update project (name, visibility)
- ✅ Delete project (cascading delete)
- ✅ Regenerate API keys
- ✅ Public/private project support
- ✅ Multipart form-data upload
- ✅ Folder path specification (e.g.,
hrm/avatars,hrm/forms/leave) - ✅ Automatic folder creation on upload
- ✅ File metadata storage (name, size, MIME type, upload date)
- ✅ Unique file ID generation (UUID)
- ✅ Local filesystem storage
- ✅ File size limits (configurable)
- ✅ MIME type detection
- ✅ Download URL generation
- ✅ Download via file ID
- ✅ API key validation for private files
- ✅ Public access for public projects/folders
- ✅ Proper Content-Type headers
- ✅ Content-Disposition headers for proper file names
- ✅ File streaming support
- ✅ Create folders within projects
- ✅ Set folder visibility (public/private)
- ✅ List folders with statistics
- ✅ Update folder visibility
- ✅ Unique constraint on project_id + path
- ✅ Auto-inherit project visibility
- ✅ PostgreSQL with SQLx
- ✅ Complete schema with proper relationships
- ✅ Migrations system
- ✅ Cascading deletes
- ✅ Proper indexes for performance
- ✅ UUID primary keys
- ✅ JWT secret configuration
- ✅ Password hashing (Argon2)
- ✅ API key validation
- ✅ SQL injection prevention (parameterized queries)
- ✅ CORS configuration
- ✅ Role-based access control
- ✅ Ownership validation
- ✅ Environment variables (.env.example provided)
- ✅ Configurable server port/host
- ✅ Configurable storage path
- ✅ Configurable file size limits
- ✅ Configurable CORS origins
- ✅ Feature flags (ALLOW_SIGNUP)
- ✅ Custom error types
- ✅ Proper HTTP status codes
- ✅ Error serialization to JSON
- ✅ Tracing/logging with configurable levels
- ✅ Database error handling
- ✅ Validation errors
- ✅ Multi-stage Dockerfile for backend
- ✅ Docker Compose with PostgreSQL
- ✅ Volume configuration
- ✅ Health checks
- ✅ Production-ready setup
- ✅ Environment variable configuration
- ✅ Comprehensive README.md
- ✅ SETUP.md with step-by-step instructions
- ✅ API_EXAMPLES.md with curl, JavaScript, and Python examples
- ✅ Backend-specific README
- ✅ API endpoint documentation
- ✅ Database schema documentation
- ✅ Quick start scripts (start.sh, start.bat)
- Total Files Created: 35+
- Lines of Rust Code: ~2,500+
- API Endpoints: 15
- Database Tables: 4
- Database Migrations: 5
filerunner/
├── backend/
│ ├── src/
│ │ ├── main.rs # Application entry & routing
│ │ ├── config.rs # Environment configuration
│ │ ├── error.rs # Error types & handling
│ │ ├── models/ # Data models
│ │ │ ├── user.rs
│ │ │ ├── project.rs
│ │ │ ├── folder.rs
│ │ │ └── file.rs
│ │ ├── handlers/ # HTTP request handlers
│ │ │ ├── auth.rs
│ │ │ ├── project.rs
│ │ │ ├── file.rs
│ │ │ └── folder.rs
│ │ ├── middleware/ # Authentication middleware
│ │ │ └── auth.rs
│ │ ├── db/ # Database utilities
│ │ │ └── pool.rs
│ │ └── utils/ # Helper functions
│ │ ├── jwt.rs
│ │ └── password.rs
│ ├── migrations/ # SQL migrations
│ │ ├── 20240101000001_create_user_role_enum.sql
│ │ ├── 20240101000002_create_users_table.sql
│ │ ├── 20240101000003_create_projects_table.sql
│ │ ├── 20240101000004_create_folders_table.sql
│ │ └── 20240101000005_create_files_table.sql
│ ├── Cargo.toml # Rust dependencies
│ ├── Dockerfile # Docker build config
│ ├── .env.example # Example environment config
│ └── README.md # Backend documentation
├── frontend/ # Placeholder for Phase 2
│ └── README.md
├── cli/ # Placeholder for Phase 3
│ └── README.md
├── docker-compose.yml # Docker orchestration
├── README.md # Main documentation
├── SETUP.md # Setup instructions
├── API_EXAMPLES.md # API usage examples
├── LICENSE # MIT License
├── start.sh # Quick start (Linux/Mac)
├── start.bat # Quick start (Windows)
└── .gitignore
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user (requires JWT)
POST /api/projects- Create projectGET /api/projects- List user projectsGET /api/projects/:id- Get project detailsPUT /api/projects/:id- Update projectDELETE /api/projects/:id- Delete projectPOST /api/projects/:id/regenerate-key- Regenerate API keyGET /api/projects/:id/files- List project files
POST /api/upload- Upload file (requires API key)GET /api/files/:id- Download file (API key for private)DELETE /api/files/:id- Delete file (requires JWT)
POST /api/folders- Create folderGET /api/folders?project_id=<uuid>- List foldersPUT /api/folders/:id/visibility- Update visibility
GET /health- Health check endpoint
id(UUID, PK)email(VARCHAR, UNIQUE)password_hash(TEXT)role(user_role ENUM)created_at(TIMESTAMPTZ)
id(UUID, PK)user_id(UUID, FK → users)name(VARCHAR)api_key(UUID, UNIQUE)is_public(BOOLEAN)created_at(TIMESTAMPTZ)
id(UUID, PK)project_id(UUID, FK → projects)path(VARCHAR, UNIQUE with project_id)is_public(BOOLEAN)created_at(TIMESTAMPTZ)
id(UUID, PK)project_id(UUID, FK → projects)folder_id(UUID, FK → folders, NULLABLE)original_name(VARCHAR)stored_name(VARCHAR)file_path(TEXT)size(BIGINT)mime_type(VARCHAR)upload_date(TIMESTAMPTZ)
Windows:
start.batLinux/Mac:
chmod +x start.sh
./start.sh-
Install Prerequisites
- Rust 1.75+
- PostgreSQL 14+
- Docker (optional)
-
Setup Database
createdb filerunner
-
Configure Environment
cd backend cp .env.example .env # Edit .env with your settings
-
Run Migrations
cargo install sqlx-cli --no-default-features --features postgres sqlx migrate run
-
Start Backend
cargo run --release
-
Test
curl http://localhost:8000/health # Should return: OK
- Change
JWT_SECRETto a strong random value (min 32 chars) - Change
ADMIN_PASSWORDimmediately after first login - Set
ALLOW_SIGNUP=falseif public registration not needed - Configure proper CORS origins
- Use HTTPS in production
- Set up database backups
- Configure file storage limits appropriately
- Set up monitoring and logging
- Review and restrict file upload permissions
- Use environment variables (not .env files in production)
- User authentication UI
- User dashboard with project management
- File browser with drag & drop upload
- Admin dashboard
- Beautiful UI with shadcn/ui
- Dark mode support
- Upload/download commands
- List files and projects
- Configuration file support
- Progress bars for transfers
- Batch operations
- S3-compatible storage backend
- Image optimization and CDN features
- File versioning
- Share links with expiration
- Rate limiting
- File previews
- Full-text search
- Usage analytics
- Multi-tenant support
- Webhooks
# Register
curl -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password123"}'
# Login
curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password123"}'
# Save the token# Create project
curl -X POST http://localhost:8000/api/projects \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"name":"Test Project","is_public":true}'
# Save the api_key
# Upload file
echo "Hello FileRunner!" > test.txt
curl -X POST http://localhost:8000/api/upload \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@test.txt" \
-F "folder_path=test/files"
# Save the file_id
# Download file
curl http://localhost:8000/api/files/FILE_IDSee API_EXAMPLES.md for comprehensive examples including:
- JavaScript/TypeScript examples
- Python client examples
- React hooks
- Batch upload scripts
Phase 1 is COMPLETE with all planned features implemented:
- ✅ Production-ready Rust backend
- ✅ Complete authentication system
- ✅ Full file upload/download functionality
- ✅ Folder-based organization
- ✅ Public/private access control
- ✅ Docker deployment ready
- ✅ Comprehensive documentation
The codebase is:
- Secure: Argon2 password hashing, JWT auth, API key validation
- Performant: Async Rust with Axum, optimized database queries
- Maintainable: Well-structured, documented, type-safe
- Production-Ready: Error handling, logging, Docker support
- Developer-Friendly: Clear documentation, examples, quick start scripts
Time to Phase 2! 🚀