Development Guide
This guide will help you set up a development environment for contributing to Glance.
Prerequisites
- Go: 1.24 or higher
- Node.js: 20 or higher
- npm: Latest version
- Make: For build automation
- Git: For version control
Getting Started
1. Clone the Repository
git clone https://github.com/wahyudotdev/glance.git
cd glance2. Install Dependencies
Backend (Go)
go mod downloadFrontend (React)
cd web/dashboard
npm install
cd ../..3. Build the Project
# Build everything (backend + frontend)
make build
# Or build separately
make build-frontend
make build-backend4. Run in Development Mode
Backend Only
go run cmd/glance/main.goFrontend Only
cd web/dashboard
npm run devFor frontend development, you'll need the backend running on http://localhost:15500 and http://localhost:15501.
Project Structure
glance/
├── cmd/
│ └── glance/ # Main application entry point
├── internal/ # Internal packages
│ ├── proxy/ # MITM proxy implementation
│ ├── dashboard/ # Dashboard API handlers
│ ├── mcp/ # MCP server implementation
│ ├── storage/ # Database and persistence
│ └── ...
├── web/
│ └── dashboard/ # React frontend
│ ├── src/
│ ├── public/
│ └── package.json
├── scripts/ # Build and utility scripts
├── Makefile # Build automation
└── go.modMake Commands
The project uses a Makefile for common tasks:
# Build the complete binary
make build
# Run tests
make test
# Run linter
make lint
# Generate coverage report
make test-coverage
# Clean build artifacts
make clean
# Build frontend only
make build-frontend
# Build backend only
make build-backendRunning Tests
Backend Tests
# Run all tests
go test ./internal/...
# Run with coverage
go test -cover ./internal/...
# Run specific package
go test ./internal/proxy
# Verbose output
go test -v ./internal/...Frontend Tests
cd web/dashboard
npm testCode Style
Go
We use golangci-lint for Go code:
# Run linter
make lint
# Auto-fix issues
golangci-lint run --fixFollow the Effective Go guidelines.
TypeScript/React
We use ESLint for TypeScript:
cd web/dashboard
npm run lint
# Auto-fix
npm run lint:fixDatabase
Glance uses SQLite with the following characteristics:
- Location:
~/.glance.db - Mode: Write-Ahead Logging (WAL)
- Caching: Write-Behind for performance
Schema Migrations
Currently, schema is managed manually. When updating the database schema:
- Update the initialization code in
internal/storage/db.go - Test with a fresh database
- Consider backward compatibility
Adding New Features
Backend Feature
- Create new package in
internal/if needed - Implement the feature with tests
- Add API endpoints in
internal/dashboard/ - Update MCP tools if relevant
Frontend Feature
- Create components in
web/dashboard/src/components/ - Add hooks in
web/dashboard/src/hooks/if needed - Update routes if adding new pages
- Add corresponding API calls
MCP Tool
- Define tool in
internal/mcp/tools.go - Implement handler logic
- Add tests
- Update documentation in
docs/mcp/reference.md
Debugging
Backend Debugging
Use VS Code with the Go extension:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Glance",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/glance"
}
]
}Or use delve directly:
dlv debug cmd/glance/main.goFrontend Debugging
Use browser DevTools and the React DevTools extension.
Performance Profiling
Go Profiling
# CPU profile
go test -cpuprofile=cpu.prof ./internal/...
go tool pprof cpu.prof
# Memory profile
go test -memprofile=mem.prof ./internal/...
go tool pprof mem.profFrontend Profiling
Use React DevTools Profiler tab to analyze component render performance.
Release Process
Releases are automated via GoReleaser:
Tag a new version:
bashgit tag -a v0.1.5 -m "Release v0.1.5" git push origin v0.1.5GitHub Actions will automatically:
- Build binaries for all platforms
- Create a GitHub Release
- Update Homebrew tap
CI/CD
We use GitHub Actions for CI/CD:
.github/workflows/ci.yml- Tests, linting, coverage.github/workflows/release.yml- Release automation.github/workflows/gh-pages.yml- Documentation deployment
Contributing Guidelines
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Pull Request Checklist
- [ ] Tests pass locally
- [ ] Linter passes
- [ ] Added tests for new features
- [ ] Updated documentation
- [ ] Followed code style guidelines
- [ ] No breaking changes (or clearly documented)
Getting Help
- 📖 Read the Architecture Guide
- 💬 Open a discussion
- 🐛 Report issues
License
By contributing to Glance, you agree that your contributions will be licensed under the MIT License.