How pil0u/lewagon-aoc works
Main System Components
a) Client Layer
• Web Interface (Rails Views + ViewComponents)
• JavaScript Controllers (Stimulus)
• TailwindCSS Styling
b) Application Layer
• Controllers (handling HTTP requests)
• Components (ViewComponents architecture)
• Domains (business logic)
• Jobs (background processing)
• Presenters (view logic)
c) Data Layer
• Models (ActiveRecord)
• Database (PostgreSQL)
• Cache System
d) External Services
• Advent of Code API Integration
• OAuth (GitHub)
• Slack Integration
Key Architectural Patterns to Highlight
a) MVC Pattern with Enhanced Components
• Traditional Rails MVC
• ViewComponents for reusable UI elements
• Presenters for complex view logic
b) Domain-Driven Design
• Separate domains for different concerns (achievements, completions, ranks, scores)
• Clear business logic separation in domain classes
c) Background Processing
• GoodJob for async operations
• Scheduled tasks for data updates
Data Flow Representation
a) Primary Flows
• User authentication flow via GitHub OAuth
• Score computation and caching flow
• Achievement unlocking flow
• API data fetching and processing
b) Secondary Flows
• Real-time updates via Stimulus controllers
• Cache invalidation paths
• Background job processing
Component Relationships
Clear connections between:
• Models and their associations
• Controllers and their corresponding views/components
• Domain services and their dependencies
• Background jobs and their triggers
Implementation Details
• Ruby/Rails versions (3.3.5/7.2.2.1)
• Database schema highlights
• Key gem dependencies
• Environment configurations