SnapVault is a complete, production-ready file upload and management system built with Ruby on Rails 8.0.2. It provides secure, user-authenticated file storage with a modern web interface and RESTful API.
- Framework: Ruby on Rails 8.0.2 (API mode)
- Database: SQLite3 (development), PostgreSQL ready (production)
- Authentication: JWT tokens with bcrypt password hashing
- File Storage: Active Storage with local/cloud support
- File Processing: Marcel for MIME type detection
- CORS: Rack-CORS for cross-origin requests
- Technology: Vanilla JavaScript with modern ES6+ features
- Styling: CSS3 with custom properties and Flexbox/Grid
- UI/UX: Responsive design with mobile-first approach
- Interactions: Drag & drop file uploads, real-time feedback
snapvault/
โโโ app/
โ โโโ controllers/
โ โ โโโ application_controller.rb # Base controller with auth
โ โ โโโ auth_controller.rb # Login/registration
โ โ โโโ files_controller.rb # File management
โ โ โโโ health_controller.rb # Health checks
โ โ โโโ home_controller.rb # Serves frontend
โ โ โโโ uploads_controller.rb # File uploads
โ โโโ models/
โ โ โโโ user.rb # User authentication
โ โ โโโ user_file.rb # File metadata
โ โโโ services/
โ โ โโโ auth/
โ โ โ โโโ jwt_service.rb # JWT token handling
โ โ โโโ authorize_api_request.rb # Request authorization
โ โ โโโ exception_handler.rb # Error handling
โ โ โโโ message.rb # Consistent messages
โ โโโ controllers/concerns/
โ โโโ authenticable.rb # Auth concern
โโโ config/
โ โโโ routes.rb # API routes
โ โโโ database.yml # Database config
โ โโโ initializers/cors.rb # CORS setup
โโโ public/
โ โโโ index.html # Main application
โ โโโ demo.html # Landing page
โโโ db/
โโโ migrate/ # Database migrations
- Registration: Secure user signup with validation
- Login: Email/password authentication
- JWT Tokens: Stateless authentication with 24-hour expiry
- Password Security: bcrypt hashing with Rails defaults
- Upload: Support for JPG, PNG, GIF, SVG, TXT, MD, CSV
- Validation: File type and size (2MB limit) validation
- Ownership: Strict user-file association
- Metadata: Filename, size, type, upload date tracking
- Authorization: JWT-based API protection
- File Access Control: Users can only access their own files
- MIME Type Validation: Prevents malicious file uploads
- Error Handling: Consistent error responses without data leakage
POST /auth/register- User registrationPOST /auth/login- User login
POST /upload- Upload new fileGET /files- List user's filesGET /files/:id- Get file detailsGET /files/:id/download- Download fileDELETE /files/:id- Delete file
GET /health- Health checkGET /- Frontend application
- Responsive Design: Mobile-first approach
- Interactive Elements: Hover effects, animations
- Visual Feedback: Progress bars, loading states
- Accessibility: Semantic HTML, keyboard navigation
- Drag & Drop: Intuitive file dropping
- File Selection: Traditional file picker
- Progress Tracking: Visual upload progress
- Validation Feedback: Real-time error messages
- Grid Display: Card-based file listing
- File Icons: Type-specific visual indicators
- Metadata Display: Size, date, type information
- Actions: Download, delete with confirmation
- Authentication Tabs: Seamless login/register switching
- Dashboard: Usage statistics and file overview
- Alerts: Toast notifications for actions
- Empty States: Helpful guidance for new users
- Ruby 3.3.5
- Rails 8.0.2
- SQLite3 (development)
- ImageMagick or libvips (optional, for image processing)
# Clone and setup
cd snapvault
bundle install
# Database setup
bin/rails db:create
bin/rails db:migrate
# Start server
bin/rails server -p 3000- Visit
http://localhost:3000 - Register a new account or login
- Upload files via drag & drop or file picker
- Manage your files through the interface
curl -X POST http://localhost:3000/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","email":"john@example.com","password":"password123"}'curl -X POST http://localhost:3000/upload \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-F "file=@/path/to/your/file.png"curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
http://localhost:3000/files- Authentication: JWT tokens with expiration
- Authorization: Request-level user verification
- File Validation: MIME type and size checking
- Ownership Control: Strict file access enforcement
- Password Security: bcrypt hashing
- Error Handling: No sensitive data in error messages
- HTTPS: Always use SSL in production
- Database: Switch to PostgreSQL for production
- File Storage: Use cloud storage (S3, GCS) for scalability
- Rate Limiting: Implement API rate limiting
- Monitoring: Add application monitoring and logging
- Backup: Regular database and file backups
- Efficient database queries with includes
- File size limits to prevent abuse
- Minimal API response payloads
- Client-side file validation
- Background job processing for large files
- CDN integration for file delivery
- Database connection pooling
- Caching layer (Redis)
- Horizontal scaling with load balancers
# Required environment variables
export RAILS_ENV=production
export SECRET_KEY_BASE=your_secret_key
export DATABASE_URL=postgresql://user:pass@host:port/dbname# Dockerfile already included in the project
docker build -t snapvault .
docker run -p 3000:3000 snapvault- Heroku: One-click deployment ready
- Railway: GitHub integration available
- DigitalOcean: Docker-based deployment
- AWS/GCP: Container or serverless deployment
- โ Basic file upload/download
- โ User authentication
- โ Web interface
- โ API endpoints
- File sharing with expiration links
- Batch operations
- File previews and thumbnails
- Advanced search and filtering
- File versioning
- Collaboration features
- Mobile applications
- Enterprise features (SSO, LDAP)
The application includes Swagger-ready endpoints and can be easily documented using tools like:
- OpenAPI/Swagger specifications
- Postman collections
- Insomnia workspaces
The codebase follows Rails conventions and best practices:
- Code Style: Standard Ruby formatting
- Testing: RSpec test framework ready
- Security: Brakeman security scanning
- Quality: Rubocop linting
SnapVault is open source and available under the MIT License, making it suitable for both personal and commercial use.
Built with โค๏ธ for developers who need simple, secure file storage.