Skip to content

Commit 55fbd6c

Browse files
SilkePilonym
authored andcommitted
docs: add comprehensive DEVELOPMENT.md for JetKVM (#692)
* docs: add comprehensive DEVELOPMENT.md for JetKVM Add a detailed development guide covering setup, project structure, and workflows for both full device and frontend-only development. Include prerequisites, build commands, deployment scripts, environment variables, and testing instructions to streamline onboarding and contributions. This improves developer experience and standardizes development practices across the project. * docs: clean up DEVELOPMENT.md by removing outdated sections Remove the Custom Build Tags and Release Process sections to simplify the documentation and avoid confusion with deprecated build and release instructions. Focus the document on current performance profiling steps. * docs: rewrite DEVELOPMENT.md for clearer setup and usage Revise the JetKVM development guide to improve clarity and usability. Simplify the introduction and reorganize prerequisites and setup steps to help new developers get started quickly. Add explicit instructions for cloning, tool verification, deployment, and testing. Streamline common tasks sections with clear commands for UI and backend development, testing, and log viewing. Update project layout overview for easier navigation. These changes reduce onboarding friction and enhance the developer experience. * docs: remove duplicate "Get Started" header in DEVELOPMENT.md Clean up the DEVELOPMENT.md file by deleting the repeated "Get Started" header * docs: add recommended development environment section Add guidance recommending Linux or macOS for development and suggest using WSL on Windows to ensure compatibility with shell scripts and build tools. This improves the developer experience and reduces setup issues across different operating systems. * docs: add links to prerequisites in DEVELOPMENT.md Update DEVELOPMENT.md to URLs for Go, Node.js, Git, and SSH access prerequisites. This improves clarity and helps developers quickly find installation resources.
1 parent cff3dda commit 55fbd6c

File tree

2 files changed

+358
-1
lines changed

2 files changed

+358
-1
lines changed

DEVELOPMENT.md

Lines changed: 355 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,355 @@
1+
<div align="center">
2+
<img alt="JetKVM logo" src="https://jetkvm.com/logo-blue.png" height="28">
3+
4+
### Development Guide
5+
6+
[Discord](https://jetkvm.com/discord) | [Website](https://jetkvm.com) | [Issues](https://github.com/jetkvm/cloud-api/issues) | [Docs](https://jetkvm.com/docs)
7+
8+
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/jetkvm.svg?style=social&label=Follow%20%40JetKVM)](https://twitter.com/jetkvm)
9+
10+
[![Go Report Card](https://goreportcard.com/badge/github.com/jetkvm/kvm)](https://goreportcard.com/report/github.com/jetkvm/kvm)
11+
12+
</div>
13+
14+
# JetKVM Development Guide
15+
16+
Welcome to JetKVM development! This guide will help you get started quickly, whether you're fixing bugs, adding features, or just exploring the codebase.
17+
18+
## Get Started
19+
20+
### Prerequisites
21+
- **A JetKVM device** (for full development)
22+
- **[Go 1.24.4+](https://go.dev/doc/install)** and **[Node.js 22.15.0](https://nodejs.org/en/download/)**
23+
- **[Git](https://git-scm.com/downloads)** for version control
24+
- **[SSH access](https://jetkvm.com/docs/advanced-usage/developing#developer-mode)** to your JetKVM device
25+
26+
### Development Environment
27+
28+
**Recommended:** Development is best done on **Linux** or **macOS**.
29+
30+
If you're using Windows, we strongly recommend using **WSL (Windows Subsystem for Linux)** for the best development experience:
31+
- [Install WSL on Windows](https://docs.microsoft.com/en-us/windows/wsl/install)
32+
- [WSL Setup Guide](https://docs.microsoft.com/en-us/windows/wsl/setup/environment)
33+
34+
This ensures compatibility with shell scripts and build tools used in the project.
35+
36+
### Project Setup
37+
38+
1. **Clone the repository:**
39+
```bash
40+
git clone https://github.com/jetkvm/kvm.git
41+
cd kvm
42+
```
43+
44+
2. **Check your tools:**
45+
```bash
46+
go version && node --version
47+
```
48+
49+
3. **Find your JetKVM IP address** (check your router or device screen)
50+
51+
4. **Deploy and test:**
52+
```bash
53+
./dev_deploy.sh -r 192.168.1.100 # Replace with your device IP
54+
```
55+
56+
5. **Open in browser:** `http://192.168.1.100`
57+
58+
That's it! You're now running your own development version of JetKVM.
59+
60+
---
61+
62+
## Common Tasks
63+
64+
### Modify the UI
65+
66+
```bash
67+
cd ui
68+
npm install
69+
./dev_device.sh 192.168.1.100 # Replace with your device IP
70+
```
71+
72+
Now edit files in `ui/src/` and see changes live in your browser!
73+
74+
### Modify the backend
75+
76+
```bash
77+
# Edit Go files (config.go, web.go, etc.)
78+
./dev_deploy.sh -r 192.168.1.100 --skip-ui-build
79+
```
80+
81+
### Run tests
82+
83+
```bash
84+
./dev_deploy.sh -r 192.168.1.100 --run-go-tests
85+
```
86+
87+
### View logs
88+
89+
```bash
90+
91+
tail -f /var/log/jetkvm.log
92+
```
93+
94+
---
95+
96+
## Project Layout
97+
98+
```
99+
/kvm/
100+
├── main.go # App entry point
101+
├── config.go # Settings & configuration
102+
├── web.go # API endpoints
103+
├── ui/ # React frontend
104+
│ ├── src/routes/ # Pages (login, settings, etc.)
105+
│ └── src/components/ # UI components
106+
└── internal/ # Internal Go packages
107+
```
108+
109+
**Key files for beginners:**
110+
111+
- `web.go` - Add new API endpoints here
112+
- `config.go` - Add new settings here
113+
- `ui/src/routes/` - Add new pages here
114+
- `ui/src/components/` - Add new UI components here
115+
116+
---
117+
118+
## Development Modes
119+
120+
### Full Development (Recommended)
121+
122+
*Best for: Complete feature development*
123+
124+
```bash
125+
# Deploy everything to your JetKVM device
126+
./dev_deploy.sh -r <YOUR_DEVICE_IP>
127+
```
128+
129+
### Frontend Only
130+
131+
*Best for: UI changes without device*
132+
133+
```bash
134+
cd ui
135+
npm install
136+
./dev_device.sh <YOUR_DEVICE_IP>
137+
```
138+
139+
### Quick Backend Changes
140+
141+
*Best for: API or backend logic changes*
142+
143+
```bash
144+
# Skip frontend build for faster deployment
145+
./dev_deploy.sh -r <YOUR_DEVICE_IP> --skip-ui-build
146+
```
147+
148+
---
149+
150+
## Debugging Made Easy
151+
152+
### Check if everything is working
153+
154+
```bash
155+
# Test connection to device
156+
ping 192.168.1.100
157+
158+
# Check if JetKVM is running
159+
ssh [email protected] ps aux | grep jetkvm
160+
```
161+
162+
### View live logs
163+
164+
```bash
165+
166+
tail -f /var/log/jetkvm.log
167+
```
168+
169+
### Reset everything (if stuck)
170+
171+
```bash
172+
173+
rm /userdata/kvm_config.json
174+
systemctl restart jetkvm
175+
```
176+
177+
---
178+
179+
## Testing Your Changes
180+
181+
### Manual Testing
182+
183+
1. Deploy your changes: `./dev_deploy.sh -r <IP>`
184+
2. Open browser: `http://<IP>`
185+
3. Test your feature
186+
4. Check logs: `ssh root@<IP> tail -f /var/log/jetkvm.log`
187+
188+
### Automated Testing
189+
190+
```bash
191+
# Run all tests
192+
./dev_deploy.sh -r <IP> --run-go-tests
193+
194+
# Frontend linting
195+
cd ui && npm run lint
196+
```
197+
198+
### API Testing
199+
200+
```bash
201+
# Test login endpoint
202+
curl -X POST http://<IP>/auth/password-local \
203+
-H "Content-Type: application/json" \
204+
-d '{"password": "test123"}'
205+
```
206+
207+
---
208+
209+
## Common Issues & Solutions
210+
211+
### "Build failed" or "Permission denied"
212+
213+
```bash
214+
# Fix permissions
215+
ssh root@<IP> chmod +x /userdata/jetkvm/bin/jetkvm_app_debug
216+
217+
# Clean and rebuild
218+
go clean -modcache
219+
go mod tidy
220+
make build_dev
221+
```
222+
223+
### "Can't connect to device"
224+
225+
```bash
226+
# Check network
227+
ping <IP>
228+
229+
# Check SSH
230+
ssh root@<IP> echo "Connection OK"
231+
```
232+
233+
### "Frontend not updating"
234+
235+
```bash
236+
# Clear cache and rebuild
237+
cd ui
238+
npm cache clean --force
239+
rm -rf node_modules
240+
npm install
241+
```
242+
243+
---
244+
245+
## Next Steps
246+
247+
### Adding a New Feature
248+
249+
1. **Backend:** Add API endpoint in `web.go`
250+
2. **Config:** Add settings in `config.go`
251+
3. **Frontend:** Add UI in `ui/src/routes/`
252+
4. **Test:** Deploy and test with `./dev_deploy.sh`
253+
254+
### Code Style
255+
256+
- **Go:** Follow standard Go conventions
257+
- **TypeScript:** Use TypeScript for type safety
258+
- **React:** Keep components small and reusable
259+
260+
### Environment Variables
261+
262+
```bash
263+
# Enable debug logging
264+
export LOG_TRACE_SCOPES="jetkvm,cloud,websocket,native,jsonrpc"
265+
266+
# Frontend development
267+
export JETKVM_PROXY_URL="ws://<IP>"
268+
```
269+
270+
---
271+
272+
## Need Help?
273+
274+
1. **Check logs first:** `ssh root@<IP> tail -f /var/log/jetkvm.log`
275+
2. **Search issues:** [GitHub Issues](https://github.com/jetkvm/kvm/issues)
276+
3. **Ask on Discord:** [JetKVM Discord](https://jetkvm.com/discord)
277+
4. **Read docs:** [JetKVM Documentation](https://jetkvm.com/docs)
278+
279+
---
280+
281+
## Contributing
282+
283+
### Ready to contribute?
284+
285+
1. Fork the repository
286+
2. Create a feature branch
287+
3. Make your changes
288+
4. Test thoroughly
289+
5. Submit a pull request
290+
291+
### Before submitting:
292+
293+
- [ ] Code works on device
294+
- [ ] Tests pass
295+
- [ ] Code follows style guidelines
296+
- [ ] Documentation updated (if needed)
297+
298+
---
299+
300+
## Advanced Topics
301+
302+
### Performance Profiling
303+
304+
```bash
305+
# Enable profiling
306+
go build -o bin/jetkvm_app -ldflags="-X main.enableProfiling=true" cmd/main.go
307+
308+
# Access profiling
309+
curl http://<IP>:6060/debug/pprof/
310+
```
311+
### Advanced Environment Variables
312+
313+
```bash
314+
# Enable trace logging (useful for debugging)
315+
export LOG_TRACE_SCOPES="jetkvm,cloud,websocket,native,jsonrpc"
316+
317+
# For frontend development
318+
export JETKVM_PROXY_URL="ws://<JETKVM_IP>"
319+
320+
# Enable SSL in development
321+
export USE_SSL=true
322+
```
323+
324+
### Configuration Management
325+
326+
The application uses a JSON configuration file stored at `/userdata/kvm_config.json`.
327+
328+
#### Adding New Configuration Options
329+
330+
1. **Update the Config struct in `config.go`:**
331+
332+
```go
333+
type Config struct {
334+
// ... existing fields
335+
NewFeatureEnabled bool `json:"new_feature_enabled"`
336+
}
337+
```
338+
339+
2. **Update the default configuration:**
340+
341+
```go
342+
var defaultConfig = &Config{
343+
// ... existing defaults
344+
NewFeatureEnabled: false,
345+
}
346+
```
347+
348+
3. **Add migration logic if needed for existing installations**
349+
350+
351+
---
352+
353+
**Happy coding!**
354+
355+
For more information, visit the [JetKVM Documentation](https://jetkvm.com/docs) or join our [Discord Server](https://jetkvm.com/discord).

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ JetKVM is written in Go & TypeScript. with some bits and pieces written in C. An
3737

3838
The project contains two main parts, the backend software that runs on the KVM device and the frontend software that is served by the KVM device, and also the cloud.
3939

40-
For most of local device development, all you need is to use the `./dev_deploy.sh` script. It will build the frontend and backend and deploy them to the local KVM device. Run `./dev_deploy.sh --help` for more information.
40+
For comprehensive development information, including setup, testing, debugging, and contribution guidelines, see **[DEVELOPMENT.md](DEVELOPMENT.md)**.
41+
42+
For quick device development, use the `./dev_deploy.sh` script. It will build the frontend and backend and deploy them to the local KVM device. Run `./dev_deploy.sh --help` for more information.
4143

4244
## Backend
4345

0 commit comments

Comments
 (0)