How I Built Dhiva Pet: An Electron Desktop Companion
A complete walkthrough of building a transparent overlay pet app with Electron, physics, and SVG animations.
Dhiva Pet started as a simple idea: what if your desktop had a little life on it? A pet that walks around, jumps between windows, and reacts to your mouse — all without interfering with your actual work.
The Core Idea
The foundation of Dhiva Pet is a transparent, always-on-top Electron window that spans your entire screen. Inside this window, we render animated SVG characters that move around using a simple physics engine.
Unlike other desktop pets, Dhiva Pet never injects into other applications. It doesn't hook into Windows APIs to detect window edges. Instead, it uses a clever click-through system where only the pet itself captures mouse events — everywhere else, clicks pass through to the underlying application.
The Tech Stack
- Electron 28 — For cross-platform desktop framework
- JavaScript — Core logic and physics
- SVG + CSS — Animated characters
- esbuild — Fast bundling
- electron-builder — Packaging and installers
The Physics Engine
Every pet has velocity, position, and gravity applied. The engine runs at 60 FPS using requestAnimationFrame, updating positions based on delta time to ensure smooth motion across different monitor refresh rates.
update(dt) {
this.vy += GRAVITY * dt;
this.x += this.vx * dt;
this.y += this.vy * dt;
if (this.y >= floorY) {
this.y = floorY;
this.vy = 0;
this.onGround = true;
}
}SVG Characters
Each character is built from SVG paths — no sprite sheets, no image loading. This makes them tiny (a few KB each) and infinitely scalable. Animations are pure CSS keyframes, applied via state classes like .pet--walk .leg-l.
Publishing to Microsoft Store
After building the app with electron-builder, I converted the resulting.exeto MSIX using Microsoft's MSIX Packaging Tool. This gave me a signed, auto-updating package that Microsoft Store could accept.
Lessons Learned
- Transparent windows have quirks —
setIgnoreMouseEventswith forward:true is essential for click-through. - SVG animations are dramatically lighter than sprite sheets.
- Physics-based movement feels alive — random timers make AI feel natural.
- MSIX is the safest bet for Microsoft Store approval.
Dhiva Pet is available now on the Microsoft Store and free on the website.