Contributing Guide
April 7, 2026 ยท View on GitHub
Thank you for your interest in 0trace! This document will help you get started with development.
๐ Development Environment
Prerequisites
- Rust 1.75+
- Cargo
- Git
Clone Repository
git clone https://github.com/momo2029/0trace
cd 0trace
๐ ๏ธ Development Workflow
Start Development Server
Method 1: Hot-reload Mode (Recommended)
./dev.sh
Features:
- โ Automatically watches for code changes
- โ Automatically recompiles
- โ Automatically restarts server
Watch scope:
backend/src/**/*.rs- Backend codeshared/src/**/*.rs- Shared library code
Method 2: Normal Mode
make dev
Modify Code
Backend Code
- Edit
backend/src/*.rsorshared/src/*.rs - Hot-reload mode: auto-restart โ
- Normal mode: Ctrl+C to stop โ
make devto restart
Frontend Code
- Edit
frontend/static/*.{html,css,js} - Copy to backend:
cp frontend/static/* backend/static/ - Refresh browser โ
Shortcut commands:
# Update all frontend files
cp -r frontend/static/* backend/static/
# Or update individually
cp frontend/static/style.css backend/static/
cp frontend/static/app.js backend/static/
๐งช Testing
Run Tests
make test
Local File Transfer Test
-
Open two browser windows (or use incognito mode)
Window 1: http://localhost:2029 Window 2: http://localhost:2029 -
Window 1 (Sender):
- Select "Send Files" tab
- Choose test file (recommended < 10MB)
- Copy share link
-
Window 2 (Receiver):
- Paste link into address bar
- Auto-start receiving
Suggested Test Files
| File Type | Size | Purpose |
|---|---|---|
| Text file | < 1MB | Quick test |
| Image | 1-10MB | Regular test |
| Video | 10-100MB | Performance test |
๐ Debugging
Enable Detailed Logs
RUST_LOG=debug ./dev.sh
Log levels:
error- Errors onlywarn- Warnings and aboveinfo- Info and above (default)debug- Debug infotrace- All info
Browser Debugging
- Open Developer Tools: F12
- Console tab: View JS logs
- Network tab: View requests
- Application tab: View localStorage
๐ฆ Building
Development Build
cargo build
Production Build
make build
# Binary: backend/target/release/backend
Docker Build
docker build -t 0trace .
docker run -p 2029:2029 0trace
๐ Code Standards
Rust Code
# Format
cargo fmt
# Lint
cargo clippy
# Fix warnings
cargo clippy --fix
JavaScript Code
- Use ES6+ syntax
- Avoid frameworks (stay lightweight)
- Add necessary comments
Commit Convention
Use semantic commit messages:
feat: Add new feature
fix: Fix bug
docs: Update documentation
style: Code formatting changes
refactor: Refactor code
test: Add tests
chore: Build/toolchain updates
Examples:
git commit -m "feat: Add multi-file transfer support"
git commit -m "fix: Fix memory overflow for large files"
git commit -m "docs: Update README deployment instructions"
๐๏ธ Project Structure
0trace/
โโโ shared/ # Shared library (protocol definitions)
โ โโโ src/
โ โ โโโ protocol.rs # Signaling protocol
โ โ โโโ room.rs # Room management
โ โโโ Cargo.toml
โ
โโโ backend/ # Rust backend
โ โโโ src/
โ โ โโโ main.rs # Server entry point
โ โ โโโ room.rs # Room manager
โ โ โโโ ws.rs # WebSocket handling
โ โโโ static/ # Static files (production)
โ
โโโ frontend/ # Frontend development
โ โโโ static/
โ โโโ index.html # Main page
โ โโโ app.js # WebRTC logic
โ โโโ style.css # Styles
โ โโโ i18n.js # Multilingual system
โ โโโ i18n/ # Translation files
โ
โโโ Dockerfile
โโโ Makefile
โโโ README.md
๐ค Submitting Pull Requests
- Fork the project
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m "feat: Add new feature" - Push branch:
git push origin feature/amazing-feature - Submit Pull Request
PR Checklist
- Code formatted with
cargo fmt - Code passes
cargo clippychecks - Added necessary tests
- Updated relevant documentation
- Tested locally
- Commit messages follow convention
๐ง Common Issues
Port Already in Use
# Find process using port
lsof -ti:2029
# Kill process
lsof -ti:2029 | xargs kill -9
Hot-reload Not Working
# Install cargo-watch
cargo install cargo-watch
# Check version
cargo watch --version
Frontend Changes Not Applied
# Confirm files copied
ls -la backend/static/
# Force refresh browser
Cmd+Shift+R (Mac)
Ctrl+Shift+R (Windows/Linux)
Compilation Errors
# Clean build cache
make clean
# Update dependencies
cargo update
# Rebuild
make build
๐ Resources
- Rust Official Documentation
- Axum Framework Documentation
- WebRTC API Documentation
- Project Architecture Documentation
๐ก Development Tips
- Small commits - Each commit should do one thing
- Write comments - Add comments for complex logic
- Test first - Write tests before modifying features
- Keep it simple - Avoid over-engineering
- Performance mindset - Consider memory and performance impact
๐ฏ Optimization Ideas
Contributions welcome for:
Short-term
- Add transfer speed display
- Support resumable transfers
- Add file preview
- Optimize large file transfers
Medium-term
- Integrate TURN server
- Add file encryption option
- Support batch transfers
- Mobile optimization
Long-term
- Text message transfer
- QR code sharing
- Transfer history
- Custom STUN/TURN configuration
๐ง Contact
Questions or suggestions?
- Open Issue: https://github.com/momo2029/0trace/issues
- Discussions: https://github.com/momo2029/0trace/discussions
Thank you for your contributions! ๐