Effect Patterns Hub Documentation

repository·main·Indexed 20 days ago

https://github.com/pauljphilp/effectpatterns

A community-driven knowledge base and toolset for Effect-TS patterns. It features a curated collection of over 700 architectural patterns, the @effect-patterns/analysis-core library for AST-based code analysis and automated refactorings, and an MCP 2.0 compatible API server for pattern management and AI-powered architectural review.

Tokens
677.1K
Snippets
1.4K
Records
1.9K
Agent score
73%

What's inside Effect Patterns Hub

  1. Overview of the Ingest Service

    main

    The Ingest Service is a pattern ingestion and processing service for the Effect Patterns publishing pipeline. It automates the lifecycle of a pattern from discovery to publication by handling:

    • Discovery: Finding patterns within raw directories.
    • Validation: Checking pattern structure and content.
    • Testing: Verifying TypeScript code within patterns for compilation success.
    • Deduplication: Checking for duplicate patterns in the published directory.
    • Migration: Moving validated patterns to the published directory.
    • Reporting: Running complete pipelines and generating summary reports.
  2. Overview of the Effect Learning Roadmap

    main

    The Effect Learning Roadmap is a structured guide designed to take developers from fundamental concepts to building production-ready applications using Effect-TS. It follows a progressive mastery approach:

    1. Foundation First: Understanding the core problems Effect solves.
    2. Building Blocks: Learning to compose small, reliable pieces.
    3. Real-World Applications: Applying patterns to production systems.
    4. Advanced Techniques: Mastering sophisticated enterprise patterns.

    The roadmap is organized into specialized modules covering core concepts, web servers, data pipelines, resource management, concurrency, and more.

  3. Overview of Concurrency Anti-Patterns in Effect

    main

    The @effect-patterns/analysis-core package includes a set of concurrency anti-patterns designed to prevent production failures, resource leaks, and silent failures. These rules are categorized by severity (High, Medium, Low) and are intended to guide developers toward proper fiber management, supervision, and controlled parallelism.

    Key focus areas include:

    • Preventing unbounded parallelism.
    • Avoiding fire-and-forget forks.
    • Preventing forking inside loops.
    • Managing racing effects to ensure 'losers' are handled correctly.
  4. Overview of API Building Jobs-to-be-Done

    main
    This document serves as a checklist of developer tasks (Jobs) required to build robust HTTP APIs using the Effect ecosystem. It categorizes these tasks into five main stages: Server Setup, Handling Requests, Sending Responses, Dependencies, and Advanced API Patterns. This framework is used to ensure that the available Effect patterns provide complete coverage for standard API development workflows.
  5. Overview of the Pattern QA Process

    main

    The Pattern Quality Assurance (QA) system ensures all patterns in the Effect Patterns Hub meet quality standards before publication. The process covers automated validation of frontmatter, structure, and links; TypeScript testing for type checking and runtime validation; content analysis for completeness; and automated repair tools for common issues.

    QA Goals:

    • Consistency: Uniform structure across all patterns.
    • Correctness: TypeScript examples must compile and run.
    • Completeness: All required metadata and sections must be present.
    • Quality: Patterns must meet effectiveness standards.
    • Discoverability: Proper categorization and tagging.
  6. Overview of Schema Patterns with @effect/schema

    main

    The Schema section of the Effect Patterns Hub provides a comprehensive collection of patterns for validation, parsing, and transformation using @effect/schema. These patterns are categorized by skill level (Beginner, Intermediate, Advanced) and cover a wide range of real-world use cases including:

    • AI Integration: Defining schemas for LLM outputs, handling malformed AI responses, and integrating with tools like the Vercel AI SDK.
    • Data Validation: Validating API responses, JSON files, environment variables, form inputs, and database columns (e.g., PostgreSQL JSONB).
    • Complex Data Structures: Handling recursive structures (trees, linked lists), nested objects, arrays, tuples, and unions.
    • Error Handling: Collecting all validation errors, creating custom tagged errors, and implementing user-friendly error messages.
    • Advanced Transformations: Implementing bidirectional transformations (API ↔ Domain ↔ DB), branded types for type-safe IDs, and data normalization.
    • Async Operations: Performing asynchronous validation (e.g., checking username availability) and batched async validation for efficiency.
  7. Overview of Effect Schema Jobs-to-be-Done

    main

    This document serves as a roadmap for developers using Effect Schema. It categorizes the essential tasks (Jobs) a developer must perform when working with schemas and maps them to specific implementation patterns.

    Use this as a checklist to ensure your schema implementation covers necessary requirements such as primitive validation, object composition, transformations, async validation, and error handling.

  8. Overview of Effect Patterns

    main
    Effect Patterns is a curated collection of over 700 Effect-TS patterns and best practices designed for real-world use cases. The project is organized by skill level (Beginner, Intermediate, Advanced) and provides full test coverage including type checking and runtime validation. Patterns are stored and searchable via a PostgreSQL database.
  9. Overview of Effect Learning Modules

    main

    The roadmap is organized into the following modules, categorized by difficulty and topic:

    ModuleTopicLevel
    Module 1FoundationBeginner-Intermediate
    Module 2Web ServerIntermediate
    Module 3Data PipelinesIntermediate-Advanced
    Module 4ResourcesIntermediate-Advanced
    Module 5CombinatorsIntermediate
    Module 6ConstructorsBeginner-Intermediate
    Module 7Pattern MatchingIntermediate
    Module 8Branded TypesIntermediate
    Module 9ObservabilityIntermediate-Advanced
    Module 10Data TypesBeginner-Advanced
    RecipesProduction PatternsAdvanced
  10. Overview of the Effect Patterns Hub

    main

    The Effect Patterns Hub is a community-driven knowledge base providing practical, goal-oriented patterns for building robust applications using Effect-TS. It focuses on architectural strategies and the reasoning behind specific code implementations.

    For an interactive experience, you can use EffectTalk.dev, which allows you to browse over 300 patterns, take guided learning tours, and run code examples directly in your browser.

  11. Use TUIService, Logger, Display, and Execution

    main

    The package provides four primary services:

    • TUI Service: Handles dynamic loading of effect-cli-tui with graceful fallbacks.
    • Logger Service: Provides structured logging with multiple output formats and color support.
    • Display Service: Handles output formatting using the TUI adapter pattern.
    • Execution Service: Manages script execution with TUI spinner support and error handling.
  12. Implement Observability in Effect applications

    main

    Observability in Effect applications is categorized into several functional areas (Jobs). To implement observability, you should follow the patterns established for each category:

    • Getting Started: Basic logging, log levels, and adding context.
    • Structured Logging: Using Effect's built-in structured logging and configuring formats.
    • Debugging: Debugging programs using tap to inspect values and tracing execution flow.
    • Tracing: Adding spans for timing, tracing across services, and OpenTelemetry integration.
    • Metrics: Adding custom metrics like counters, gauges, and histograms.
    • Advanced Observability: Distributed tracing, Prometheus export, dashboard creation, and alerting.

    Refer to the specific pattern documentation (e.g., structured-logging.mdx, spans.mdx, opentelemetry.mdx) to implement these capabilities.