A modern, lightning-fast file upload service built with FastAPI (Python) and Vite + Svelte + DaisyUI. Features in-memory storage, beautiful UI, and production-ready Docker deployment.
# Run setup script (one-time)
./scripts/setup.sh
This will:
Start both backend and frontend with hot reload:
./scripts/dev.sh
This starts:
Both services auto-reload on file changes!
# Run all tests with coverage
./scripts/test.sh
# Watch mode (tests re-run on changes)
./scripts/test-watch.sh
# Build production artifacts
./scripts/build.sh
# Run production build locally
./scripts/run-production.sh
# Or use Docker
docker build -t file-upload:latest .
docker run -p 8000:8000 file-upload:latest
# Production
docker-compose up
# Development with volumes
docker-compose --profile dev up
.
├── backend/ # FastAPI backend
│ ├── app/
│ │ ├── main.py # Application entry point
│ │ ├── models.py # Pydantic models
│ │ ├── storage.py # In-memory storage
│ │ └── routers/
│ │ └── files.py # File endpoints
│ ├── tests/ # Comprehensive tests
│ ├── requirements.txt # Python dependencies
│ └── pytest.ini # Test configuration
├── frontend/ # Svelte frontend
│ ├── src/
│ │ ├── App.svelte # Main component
│ │ ├── lib/
│ │ │ ├── Upload.svelte
│ │ │ ├── FileList.svelte
│ │ │ └── api.js # API client
│ │ └── main.js
│ ├── package.json
│ └── vite.config.js
├── scripts/ # Development scripts
│ ├── setup.sh # Initial setup
│ ├── dev.sh # Development mode
│ ├── test.sh # Run tests
│ ├── test-watch.sh # Watch tests
│ ├── build.sh # Production build
│ └── clean.sh # Clean artifacts
├── docs/ # Documentation
│ ├── design.md # Architecture decisions
│ └── requirements.md # Detailed requirements
├── Dockerfile # Production Docker image
├── docker-compose.yml # Docker Compose config
├── CLAUDE.md # Development standards
└── README.md # This file
POST /api/upload
Content-Type: multipart/form-data
Response: 201 Created
{
"id": "uuid",
"filename": "example.pdf",
"size": 12345,
"uploaded_at": "2025-10-10T12:00:00Z"
}
GET /api/files
Response: 200 OK
{
"files": [...],
"total": 5
}
GET /api/download/{file_id}
Response: 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="example.pdf"
Interactive API documentation available at /api/docs when server is running.
The development environment is optimized for speed:
--reload watches Python files/api to backend (no CORS issues)All three can run simultaneously in separate terminals:
# Terminal 1: Full dev environment
./scripts/dev.sh
# Terminal 2: Watch tests
./scripts/test-watch.sh
# Format backend
cd backend && black . && isort .
# Format frontend
cd frontend && npm run format
# Lint frontend
cd frontend && npm run lint
Backend (.env):
ENVIRONMENT=development
MAX_FILE_SIZE=10485760 # 10MB
MAX_STORAGE_SIZE=104857600 # 100MB
LOG_LEVEL=INFO
Frontend (.env):
VITE_API_URL=http://localhost:8000/api
Build and run:
docker build -t file-upload:latest .
docker run -p 8000:8000 file-upload:latest
Access at http://localhost:8000
The Docker image works on any platform:
Example Cloud Run:
gcloud run deploy file-upload \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticated
# Run all tests
pytest backend/tests/
# Run specific test file
pytest backend/tests/test_upload.py
# Run with coverage
pytest --cov=backend/app --cov-report=html
# Watch mode
pytest-watch
Test coverage: >80% overall, 100% for critical paths.
test_storage.py - Storage module teststest_upload.py - Upload endpoint teststest_list.py - List endpoint teststest_download.py - Download endpoint testsSee docs/design.md for:
See docs/requirements.md for:
See CLAUDE.md for:
# Check Python version
python3 --version # Should be 3.11+
# Recreate venv
rm -rf backend/venv
./scripts/setup.sh
# Clear and reinstall
rm -rf frontend/node_modules
cd frontend && npm install
# Clean and reinstall
./scripts/clean.sh
./scripts/setup.sh
./scripts/test.sh
# Clear cache and rebuild
docker builder prune
docker build --no-cache -t file-upload .
MIT License - See LICENSE file for details
docs/ directoryBuilt with FastAPI + Vite + Svelte + DaisyUI
Fast • Modern • Production-Ready