This guide covers setting up a local development environment for the Homelab File Manager.
- Go 1.23+
- Node.js 22+ (or Bun)
- Git
git clone https://github.com/yourusername/homelab-file-manager.git
cd homelab-file-managercd backend
# Install dependencies
go mod download
# Create test directories
mkdir -p /tmp/filemanager/media
mkdir -p /tmp/filemanager/documents
# Update config.yaml with test paths
cat > config.yaml << EOF
port: 8080
host: "0.0.0.0"
jwt_secret: "dev-secret-change-in-production"
max_upload_mb: 1024
chunk_size_mb: 5
mount_points:
- name: "media"
path: "/tmp/filemanager/media"
read_only: false
- name: "documents"
path: "/tmp/filemanager/documents"
read_only: false
EOF
# Run the server
go run ./cmd/servercd frontend
# Install dependencies
npm install
# or
bun install
# Start development server
npm run dev
# or
bun devAccess the application at http://localhost:5173
homelab-file-manager/
├── backend/ # Go backend
│ ├── cmd/server/ # Entry point
│ ├── internal/ # Internal packages
│ │ ├── config/ # Configuration
│ │ ├── handler/ # HTTP handlers
│ │ ├── middleware/ # Middleware
│ │ ├── model/ # Data models
│ │ ├── service/ # Business logic
│ │ ├── websocket/ # WebSocket hub
│ │ └── pkg/ # Shared utilities
│ ├── config.yaml # Configuration file
│ ├── go.mod
│ └── go.sum
├── frontend/ # Svelte frontend
│ ├── src/
│ │ ├── lib/ # Components, stores, utils
│ │ └── routes/ # SvelteKit routes
│ ├── package.json
│ └── svelte.config.js
├── docs/ # Documentation
├── nginx/ # Nginx configuration
├── docker-compose.yml
└── README.md
cd backend
# Run all tests
go test ./...
# Run with verbose output
go test -v ./...
# Run specific package
go test -v ./internal/service/...
# Run with coverage
go test -cover ./...
# Generate coverage report
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.outThe backend includes property-based tests using gopter:
# Run property tests (may take longer)
go test -v -timeout 300s ./internal/service/...cd frontend
# Type checking
npm run check
# Linting
npm run lint
# Format code
npm run format- Follow Effective Go
- Use
gofmtfor formatting - Run
go vetbefore committing
# Format code
gofmt -w .
# Run vet
go vet ./...- Use Prettier for formatting
- Follow ESLint rules
# Format
npm run format
# Lint
npm run lint-
Define the model in
internal/model/:type NewFeature struct { ID string `json:"id"` Name string `json:"name"` }
-
Create the service in
internal/service/:type NewFeatureService interface { Get(ctx context.Context, id string) (*model.NewFeature, error) }
-
Create the handler in
internal/handler/:func (h *NewFeatureHandler) Get(w http.ResponseWriter, r *http.Request) { // Implementation }
-
Register routes in
cmd/server/main.go:r.Route("/newfeature", func(r chi.Router) { newFeatureHandler.RegisterRoutes(r) })
-
Add API function in
src/lib/api/:export async function getNewFeature(id: string): Promise<NewFeature> { return api.get<NewFeature>(`/newfeature/${id}`); }
-
Create store if needed in
src/lib/stores/:export const newFeatureStore = writable<NewFeature | null>(null);
-
Use in component:
<script lang="ts"> import { getNewFeature } from '$lib/api/newfeature'; let feature = $state<NewFeature | null>(null); async function load() { feature = await getNewFeature('123'); } </script>
Using VS Code:
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Backend",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/backend/cmd/server",
"cwd": "${workspaceFolder}/backend"
}
]
}Using Delve:
cd backend
dlv debug ./cmd/serverUse browser DevTools or VS Code debugger with the Svelte extension.
Backend uses zerolog:
import "github.com/rs/zerolog/log"
log.Info().Str("path", path).Msg("Processing request")
log.Error().Err(err).Msg("Operation failed")# Backend
cd backend
go get -u ./...
go mod tidy
# Frontend
cd frontend
npm updatego install github.com/golang/mock/mockgen@latest
mockgen -source=internal/service/file.go -destination=internal/service/mock_file.go# Backend
cd backend
CGO_ENABLED=0 go build -ldflags="-w -s" -o server ./cmd/server
# Frontend
cd frontend
npm run build# Find process using port
lsof -i :8080
# or on Windows
netstat -ano | findstr :8080
# Kill process
kill -9 <PID>go clean -modcache
go mod downloadrm -rf node_modules
rm package-lock.json
npm installEnsure the backend is running and the frontend is configured to use the correct API URL.
For development, the Vite proxy handles CORS. Check vite.config.ts.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
go test ./...andnpm run check - Commit:
git commit -m "Add my feature" - Push:
git push origin feature/my-feature - Create a Pull Request
Follow conventional commits:
feat:New featurefix:Bug fixdocs:Documentationrefactor:Code refactoringtest:Adding testschore:Maintenance