Skip to main content

Future-Proofing Architecture Summary

Overview

The system has been designed with maximum flexibility and extensibility in mind. Multiple mechanisms allow adding new properties, categories, and relationships without requiring schema changes or code deployments.

Dynamic Systems Implemented

1. LookupTable - Dynamic Categories/Types ✅

Purpose: Replace hard-coded enums with database-driven lookup tables.

Benefits:

  • Add new values without code changes
  • User-defined categories
  • Hierarchical categories (parent-child)
  • Metadata for each value
  • Usage tracking

Hybrid Approach: Entities can use both enums (for type safety) AND lookup tables (for extensibility).

Example:

// RodBlank supports both enum and lookup
rodBlank.Power = RodPower.MediumHeavy; // Standard enum
rodBlank.PowerLookupId = customPower.Id; // Custom value from lookup table

2. EntityAttribute - Generic Attribute System ✅

Purpose: Add custom attributes to any entity without schema changes.

Benefits:

  • No schema changes needed
  • Support for multiple value types (string, number, boolean, DateTime, JSON)
  • Unit support (cm, kg, mph, etc.)
  • Lookup references for standardized values

Entities with Attributes:

  • Rod, Reel, Lure, Line, Brand
  • FishSpecies
  • FishingLogEntry, FishingSession
  • GearSetup, RodBuild
  • LocationWeatherHistory, RetailLink

3. EntityTag - Generic Tagging System ✅

Purpose: Tag any entity with normalized tags.

Benefits:

  • Works with any entity type
  • Uses normalized Tag entity
  • Context-aware (Category, UseCase, Condition, etc.)
  • No need for entity-specific tag relationships

Entities with Tags:

  • Rod, Reel, Lure, Line, Brand
  • FishSpecies
  • FishingLogEntry, FishingSession
  • GearSetup, RodBuild

4. EntityMetadata - JSON Metadata Storage ✅

Purpose: Store extensible JSON data for any entity.

Benefits:

  • Store complex nested data
  • Schema versioning support
  • Multiple metadata keys per entity
  • No schema changes needed

Entities with Metadata:

  • Rod, Reel, Lure, Line, Brand
  • FishSpecies
  • FishingLogEntry, FishingSession
  • GearSetup, RodBuild
  • LocationWeatherHistory, RetailLink

5. EntityRelationship - Generic Relationship System ✅

Purpose: Create relationships between any entities without hard-coded foreign keys.

Benefits:

  • Dynamic relationships
  • Relationship types (RelatedTo, SimilarTo, Replaces, etc.)
  • Relationship strength/confidence
  • Bidirectional support
  • Metadata for relationship details

Extensibility Strategy

Phase 1: Current (Enums + Extensible Systems)

  • Enums: Provide type safety for standard values
  • Lookup Tables: Allow extending categories
  • EntityAttribute: Allow custom properties
  • EntityMetadata: Allow complex data
  • EntityTag: Allow flexible categorization

Phase 2: Future (Full Dynamic)

  • Migrate frequently extended enums to lookup tables
  • Use EntityAttribute for all custom properties
  • Use EntityMetadata for complex nested data
  • Use EntityRelationship for dynamic links

Key Entities Made Extensible

Core Gear Entities

  • Rod - Attributes, Metadata, Tags
  • Reel - Attributes, Metadata, Tags
  • Lure - Attributes, Metadata, Tags
  • Line - Attributes, Metadata, Tags
  • Brand - Attributes, Metadata, Tags

Fishing Entities

  • FishingLogEntry - Attributes, Metadata, Tags
  • FishingSession - Attributes, Metadata, Tags
  • GearSetup - Attributes, Metadata, Tags

Rod Building

  • RodBuild - Attributes, Metadata, Tags
  • RodBlank - Hybrid enum/lookup for Power, Action, Material

Weather & Environmental

  • LocationWeatherHistory - Attributes, Metadata

Other

  • FishSpecies - Attributes, Metadata, Tags
  • RetailLink - Attributes, Metadata

Benefits

  1. No Schema Changes: Add new properties without migrations
  2. User-Defined Values: Users can create custom categories
  3. Type Safety: Enums provide compile-time safety
  4. Extensibility: Lookup tables allow runtime extensions
  5. Flexibility: EntityAttribute allows any custom property
  6. Complex Data: EntityMetadata stores nested JSON data
  7. Future-Proof: System can evolve without breaking changes

Migration Path

  1. Start with Enums: Use enums for standard, stable values
  2. Add Lookup Tables: Seed lookup tables with enum values
  3. Add Optional Lookup References: Entities can reference lookup tables
  4. Use EntityAttribute: For completely custom properties
  5. Use EntityMetadata: For complex nested data

Example: Adding New Rod Power

Without Dynamic Systems (Old Way)

// Would require:
// 1. Code change to enum
// 2. Migration
// 3. Deployment
public enum RodPower
{
// ... existing values
SuperHeavy // NEW - requires code change
}

With Dynamic Systems (New Way)

// No code changes needed!
var customPower = new LookupTable
{
Category = "RodPower",
Name = "Super Heavy",
Code = "SuperHeavy",
IsSystemDefined = false,
DisplayOrder = 8
};
// Use immediately - no deployment needed

Performance Considerations

  • Indexes: All dynamic systems have proper indexes for fast queries
  • Query Patterns: Filter by EntityType + EntityId for best performance
  • Caching: Consider caching lookup tables (they change infrequently)
  • Denormalization: Consider denormalizing frequently accessed attributes

Future Enhancements

  1. UI for Managing Lookup Tables: Admin interface for managing categories
  2. User-Defined Categories: Allow users to create their own categories
  3. Category Templates: Pre-defined category sets for common use cases
  4. Attribute Schemas: Define schemas for EntityAttribute values
  5. Relationship Validation: Validate relationship types and entities
  6. Metadata Schemas: Versioned schemas for EntityMetadata JSON data
  7. Attribute Search: Full-text search on EntityAttribute values
  8. Metadata Querying: Query JSON metadata fields efficiently