Architecture Documentation Index
This directory contains comprehensive architectural documentation for the Uptime-Watcher application, including Architecture Decision Records (ADRs), development patterns, code templates, and documentation standards.
๐ Directory Structureโ
docs/Architecture/
โโโ README.md # This file
โโโ ADRs/ # Architecture Decision Records
โ โโโ ADR-001-Repository-Pattern.md
โ โโโ ADR-002-Event-Driven-Architecture.md
โ โโโ ADR-003-Error-Handling-Strategy.md
โ โโโ ADR-004-Frontend-State-Management.md
โ โโโ ADR-005-IPC-Communication-Protocol.md
โโโ Patterns/ # Development patterns guide
โ โโโ Development-Patterns-Guide.md
โโโ Templates/ # Code templates for common patterns
โ โโโ Repository-Template.md
โ โโโ Zustand-Store-Template.md
โ โโโ IPC-Handler-Template.md
โโโ TSDoc-Standards.md # Documentation standards
๐๏ธ Architecture Decision Records (ADRs)โ
ADRs document the key architectural decisions made during development, their context, consequences, and implementation guidelines.
ADR-001: Repository Patternโ
Status: Accepted - Establishes the repository pattern for all database access
- Dual method pattern (public async + internal sync)
- Transaction safety with
executeTransaction()
- Consistent error handling and event emission
- All repositories follow this pattern:
SiteRepository
,MonitorRepository
,HistoryRepository
,SettingsRepository
ADR-002: Event-Driven Architectureโ
Status: Accepted - Core communication mechanism using TypedEventBus
- Type-safe event system with compile-time checking
- Automatic metadata injection (correlation IDs, timestamps)
- Domain-based event naming (
domain:action
) - IPC event forwarding for frontend integration
ADR-003: Error Handling Strategyโ
Status: Accepted - Multi-layered error handling across all application layers
- Shared
withErrorHandling()
utility with frontend/backend overloads withDatabaseOperation()
for retry logic and database operations- Error preservation principles maintaining stack traces
- Safe store operations preventing cascading failures
ADR-004: Frontend State Managementโ
Status: Accepted - Zustand-based state management with modular composition
- Type-safe store interfaces with comprehensive TypeScript
- Modular composition for complex stores
- Selective persistence for user preferences
- Integration with error handling and IPC systems
ADR-005: IPC Communication Protocolโ
Status: Accepted - Standardized Electron IPC communication
- Centralized IPC service with domain-specific handlers
- Type-safe preload API with contextBridge isolation
- Consistent validation and error handling
- Event forwarding protocol for real-time updates
๐ Development Patternsโ
Development Patterns Guideโ
Comprehensive guide to all established patterns in the codebase:
- Repository Pattern - Database access with transaction safety
- Event-Driven Communication - TypedEventBus usage and event naming
- Error Handling Patterns - Multi-layered error handling strategies
- Frontend State Management - Zustand stores and modular composition
- IPC Communication - Electron IPC patterns and type safety
- Testing Patterns - Consistent testing approaches across layers
๐ ๏ธ Code Templatesโ
Ready-to-use templates for implementing common patterns:
Repository Templateโ
Complete template for creating new repository classes:
- Full TypeScript implementation with dual methods
- Query constants and dependency injection
- Comprehensive TSDoc documentation
- Test template and integration checklist
Zustand Store Templateโ
Templates for both simple and complex Zustand stores:
- Simple store pattern for straightforward state
- Complex store with modular composition
- Module templates for focused functionality
- Testing patterns and error integration
IPC Handler Templateโ
Complete IPC communication implementation:
- Handler registration with validation
- Preload API extensions
- Type definitions and error handling
- Test templates and naming conventions
๐ Documentation Standardsโ
TSDoc Standardsโ
Standardized documentation patterns for inline code examples:
- Repository pattern documentation examples
- Event system documentation standards
- Frontend store documentation patterns
- Error handling documentation
- IPC communication documentation
- Code example categories and validation checklist
๐ฏ Using This Documentationโ
For New Developersโ
- Start with ADRs - Understand the architectural decisions and their context
- Read the Patterns Guide - Learn the established patterns and conventions
- Use Templates - Implement new features using the provided templates
- Follow TSDoc Standards - Document your code using the established patterns
For Existing Developersโ
- Reference ADRs - When making architectural changes, consult existing decisions
- Update Patterns - If you discover new patterns, document them in the guide
- Improve Templates - Update templates based on learnings and improvements
- Maintain Standards - Follow and improve the documentation standards
For Code Reviewsโ
- Check Pattern Compliance - Ensure new code follows established patterns
- Verify Documentation - Check that TSDoc follows the standards
- Validate Architecture - Ensure changes align with ADR decisions
- Template Usage - Verify that new repositories/stores/handlers use templates
๐ Maintenance Guidelinesโ
When to Update ADRsโ
- Status Changes - Mark ADRs as superseded when patterns evolve
- New Decisions - Create new ADRs for significant architectural changes
- Context Updates - Update context and consequences as understanding improves
Pattern Evolutionโ
- Document New Patterns - Add emerging patterns to the guide
- Update Templates - Evolve templates based on best practices
- Maintain Consistency - Ensure all patterns work together harmoniously
Documentation Qualityโ
- Regular Reviews - Periodically review and update documentation
- Example Accuracy - Ensure code examples remain current and accurate
- Cross-References - Maintain links between related documents
๐ Compliance Trackingโ
Repository Patternโ
- โ All database access uses repository pattern
- โ All repositories implement dual-method pattern
- โ
All mutations use
executeTransaction()
- โ
All operations use
withDatabaseOperation()
Event Systemโ
- โ All communication uses TypedEventBus
- โ All events follow naming conventions
- โ All events include proper metadata
- โ IPC events are automatically forwarded
Error Handlingโ
- โ All layers use appropriate error handling utilities
- โ All errors preserve original context
- โ All operations emit appropriate events
- โ Frontend stores use safe operations
Frontend Stateโ
- โ All stores use TypeScript interfaces
- โ Complex stores use modular composition
- โ Persistence is selective and purposeful
- โ Actions include consistent logging
IPC Communicationโ
- โ All handlers use standardized registration
- โ All parameters are validated
- โ All channels follow naming conventions
- โ Preload API is type-safe
๐ Quick Startโ
To implement a new feature:
- Identify the pattern - Determine which architectural pattern applies
- Use the template - Start with the appropriate template
- Follow the standards - Use TSDoc standards for documentation
- Test thoroughly - Use testing patterns from the guide
- Review compliance - Ensure the implementation follows all relevant ADRs
๐ Supportโ
For questions about architectural patterns or documentation:
- Check the ADRs - Look for existing decisions
- Review the patterns guide - Find established conventions
- Use the templates - Adapt templates to your needs
- Follow the standards - Use TSDoc standards for consistency
This documentation represents the living architectural knowledge of the Uptime-Watcher project. It should be updated as the architecture evolves and new patterns emerge.