Skip to main content

๐Ÿš€ Developer Quick Start Guide

Fast Track: Get up and running with Uptime Watcher development in minutes.

๐Ÿ“‹ Overviewโ€‹

Uptime Watcher is a sophisticated Electron desktop application for monitoring website uptime with real-time updates, comprehensive analytics, and desktop notifications.

โšก Quick Setupโ€‹

Prerequisitesโ€‹

  • Node.js: 18+ (LTS recommended)
  • npm: 9+ (comes with Node.js)
  • Git: Latest version

1. Clone & Installโ€‹

git clone https://github.com/Nick2bad4u/Uptime-Watcher.git
cd Uptime-Watcher
npm install

2. Start Developmentโ€‹

# Start both Vite dev server and Electron
npm run electron-dev

# Or start separately:
npm run dev # Vite dev server (port 5173)
npm run electron # Electron (waits for Vite)

3. Verify Setupโ€‹

  • Application window should open automatically
  • React DevTools available in development
  • Hot reload enabled for both frontend and backend changes

๐Ÿ—๏ธ Architecture Quick Referenceโ€‹

Technology Stackโ€‹

  • Frontend: React + TypeScript + Tailwind CSS + Vite
  • Desktop: Electron (main + renderer processes)
  • Database: SQLite (node-sqlite3-wasm)
  • State: Zustand (domain-specific stores)
  • Testing: Vitest (dual configuration)
  • IPC: Type-safe Electron contextBridge

Project Structureโ€‹

uptime-watcher/
โ”œโ”€โ”€ electron/ # Main process (Node.js backend)
โ”‚ โ”œโ”€โ”€ main.ts # Entry point
โ”‚ โ”œโ”€โ”€ services/ # Service-oriented architecture
โ”‚ โ”‚ โ”œโ”€โ”€ database/ # Repository pattern
โ”‚ โ”‚ โ”œโ”€โ”€ ipc/ # IPC handlers
โ”‚ โ”‚ โ””โ”€โ”€ monitoring/ # Monitoring services
โ”‚ โ””โ”€โ”€ managers/ # Business logic orchestrators
โ”œโ”€โ”€ src/ # Renderer process (React frontend)
โ”‚ โ”œโ”€โ”€ components/ # React components
โ”‚ โ”œโ”€โ”€ stores/ # Zustand state management
โ”‚ โ””โ”€โ”€ services/ # Frontend services
โ”œโ”€โ”€ shared/ # Common code (types, validation)
โ””โ”€โ”€ docs/ # Comprehensive documentation

๐Ÿ› ๏ธ Common Development Tasksโ€‹

Adding a New Featureโ€‹

  1. Backend: Add service/repository in electron/services/
  2. IPC: Create type-safe handlers in electron/services/ipc/
  3. Frontend: Add components and store in src/
  4. Types: Define shared types in shared/types/
  5. Tests: Add tests in both electron/test/ and src/test/

Database Changesโ€‹

  1. Repository: Create/modify in electron/services/database/
  2. Manager: Update business logic in electron/managers/
  3. Migration: Handle schema changes in DatabaseService
  4. Types: Update interfaces in shared/types/

Frontend Changesโ€‹

  1. Components: Add to src/components/
  2. State: Create/modify Zustand stores in src/stores/
  3. Styling: Use Tailwind CSS classes
  4. IPC: Communicate via window.electronAPI (typed)

๐Ÿ”ง Available Scriptsโ€‹

Developmentโ€‹

npm run electron-dev    # Start full development environment
npm run dev # Vite dev server only
npm run electron # Electron only (needs Vite running)
npm run build # Production build
npm run dist # Build and package application

Testingโ€‹

npm test              # Run all tests
npm run test:electron # Backend tests only
npm run test:frontend # Frontend tests only
npm run test:watch # Watch mode

Code Qualityโ€‹

npm run lint          # ESLint + Stylelint
npm run lint:fix # Auto-fix lint issues
npm run format # Prettier formatting
npm run check-types # TypeScript type checking

Documentationโ€‹

npm run docs          # Generate TypeDoc documentation
npm run context # Generate AI context (for AI assistants)

๐ŸŽฏ Key Development Patternsโ€‹

1. Repository Pattern (Database)โ€‹

// Always use repositories for database access
const sites = await siteRepository.findAll();
await siteRepository.create(newSite);

2. IPC Communicationโ€‹

// Backend: electron/services/ipc/
ipcService.registerStandardizedIpcHandler(
"sites:create",
async (data: SiteCreationData) => {
return await siteManager.createSite(data);
},
isSiteCreationData
);

// Frontend: React components
const result = await window.electronAPI.sites.create(siteData);

3. Event-Driven Updatesโ€‹

// Emit events for cross-service communication
await eventBus.emitTyped("sites:added", { site: newSite });

// Listen to events
eventBus.onTyped("sites:added", (data) => {
updateUI(data.site);
});

4. Zustand State Managementโ€‹

// Domain-specific stores
export const useSitesStore = create<SitesStore>()((set, get) => ({
sites: [],
addSite: (site) =>
set((state) => ({
sites: [...state.sites, site],
})),
// ... other actions
}));

๐Ÿšจ Important Guidelinesโ€‹

DO's โœ…โ€‹

  • Follow TypeScript strict mode - No any or type shortcuts
  • Use established patterns - Repository, Service, IPC patterns
  • Write tests - Both frontend and backend tests required
  • Document with TSDoc - Follow established standards
  • Use error handling utilities - withErrorHandling() for consistency

DON'Ts โŒโ€‹

  • No direct database access - Always use repositories
  • No untyped IPC - All communication must be typed
  • No global state - Keep Zustand stores domain-specific
  • No direct state mutations - Use store actions
  • No bypassing error handling - Use established patterns

๐Ÿ› Debuggingโ€‹

Development Toolsโ€‹

  • React DevTools: Available in development mode
  • Electron DevTools: F12 in the application window
  • VS Code Debugging: Configured launch configurations available

Common Issuesโ€‹

  1. SQLite WASM not found: Run npm run postbuild
  2. IPC communication fails: Check type definitions and handlers
  3. Hot reload not working: Restart development server
  4. Database errors: Check transaction safety and repository usage

Loggingโ€‹

# Enable debug logging
npm run electron-dev -- --debug

# Production-level logging
npm run electron-dev -- --log-production

# Info-level logging
npm run electron-dev -- --log-info

๐Ÿ“š Essential Documentationโ€‹

Architecture Understandingโ€‹

Implementation Guidesโ€‹

Code Standardsโ€‹

๐ŸŽฏ Next Stepsโ€‹

For New Contributorsโ€‹

  1. Read: docs/AI-CONTEXT.md for project understanding
  2. Explore: Run the application and explore existing features
  3. Practice: Try adding a simple feature following the patterns
  4. Ask: Check documentation first, then ask questions

For AI Assistantsโ€‹

  1. Context: Load docs/AI-CONTEXT.md for comprehensive context
  2. Patterns: Reference docs/Architecture/ for coding patterns
  3. Examples: Use templates in docs/Architecture/Templates/

๐ŸŽ‰ Ready to contribute! The codebase follows strict patterns and comprehensive documentation. When in doubt, check the existing code and documentation patterns.