Developer Guide
This guide teaches you how to work on the zmNinjaNg codebase. It is written for developers who may not have React experience, explaining concepts from first principles with real examples from the code.
New to React? Start with Chapter 2 (React Fundamentals), then Chapter 3 (Zustand).
Adding a feature? Read Chapter 9 (Contributing) for the workflow, then Chapter 6 (Testing).
Debugging? Check Chapter 8 (Common Pitfalls) for previously encountered bugs and their fixes.
Understanding the architecture? Chapter 5 (Component Architecture) explains file organization, and Chapter 11 (Application Lifecycle) explains the runtime flow.
- Introduction to zmNinjaNg Development
- React Fundamentals
- The mental shift
- JSX
- Components
- Props: data flowing in
- State: data the component owns
- Render: what triggers it
- Hooks
- useEffect: doing things after render
- useRef: a value that survives renders without triggering one
- useMemo and useCallback: stable references
- Object identity: the bug that hides everywhere
- React.memo: skipping unnecessary renders
- Putting it together
- Where to go next
- State Management with Zustand
- Pages and Views
- Project Architecture
- Directory Structure
- Component Structure
- Monitor Components
- Dashboard Components
- Event Components
- Video Playback
- Filter Components
- QR Scanner
- Common Components
- UI Components
- Settings Components
- Kiosk Mode
- Component Composition
- Testing Data Attributes
- Key Patterns
- Component Communication
- Platform Integrations (
src/services/)
- Testing Strategy
- API and Data Fetching
- ZoneMinder API
- HTTP Client Architecture
- Server API (
api/server.ts) - Monitor API Updates (
api/monitors.ts) - Event API Updates (
api/events.ts) - Monitor Exclusion
- Monitor Groups API
- Event Tags API
- Adjacent Event Navigation
- Notifications API
- Event Poller Service
- WebSocket Notification Service
- End-to-end Flow: Viewing Monitors
- Error Handling
- ZoneMinder Streaming Protocol
- Common Pitfalls
- Contributing to zmNinjaNg
- Key Libraries
- Application Lifecycle
- Shared Services and Reusable Components
- External Network Endpoints
- Go2RTC WebRTC Streaming Integration
Quick Reference
State Types
Type |
Where |
Example |
When to Use |
|---|---|---|---|
Local |
|
Form inputs, UI toggles |
Component-specific, temporary |
Global |
Zustand stores |
Current profile, settings |
Shared across components |
Server |
React Query |
Monitor list, events |
Data from ZoneMinder API |
File Organization
app/src/
├── api/ # API functions (thin wrappers around HTTP client)
├── components/ # React components (visual)
├── hooks/ # Custom React hooks (component logic)
├── lib/ # Pure utilities (no React dependencies)
├── pages/ # Route-level views
├── services/ # Platform-specific code (Capacitor plugins)
├── stores/ # Global state (Zustand)
└── locales/ # i18n translations (en, de, es, fr, zh)
Development Quick Start
cd app
npm install
npm run dev # Start development server
npm test # Run unit tests
npm run build # Build for production
Also see the AGENTS.md file for the full development guidelines and checklists.