# farrow-js/farrow architecture

> Architecture diagram of the GitHub repository farrow-js/farrow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/farrow-js/farrow
- Repository: https://github.com/farrow-js/farrow

## Overview

##### Main Components

a. Core Framework Layer:
- farrow-pipeline (Base middleware system)
- farrow-schema (Type validation and schema system)
- farrow-http (HTTP server foundation)
- farrow-module (Module system)

b. Integration Layer:
- farrow-api (API service layer)
- farrow-api-server (API server implementation)
- farrow-api-client (API client implementation)

c. Framework Adapters:
- farrow-express (Express.js integration)
- farrow-koa (Koa.js integration)
- farrow-next (Next.js integration)
- farrow-vite (Vite integration)

d. Additional Features:
- farrow-cors (CORS middleware)
- farrow-federation (API federation)
- farrow-json-schema (JSON Schema support)

##### Relationship Structure

**[Client Applications]**
- ↑
**[Framework Integrations]**
- (Next.js/Vite)
- ↑
**[API Layer]**
**(API Client/Server)**
- ↑
**[Core HTTP Layer]**
- ↑
**[Pipeline System]**
- ↑
**[Schema System]**

##### Important Details

a. Request Flow:
- How requests flow from client through the pipeline system
- Where schema validation occurs
- How middleware can be integrated

b. Type System:
- Schema validation points
- Type information flow between layers

c. Integration Points:
- How external frameworks can be integrated
- Extension points for custom middleware

##### Key Relationships to Emphasize

- How farrow-pipeline enables middleware composition
- How farrow-schema ensures type safety throughout the application
- How different adapters can be plugged into the core system
- How the API layer interfaces with both client and server

Remember to include a section showing how the framework can be extended and customized, as this is a key feature of the system according to the documentation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Applications"
        Client[Client Applications]
    end

    subgraph "Framework Integrations"
        NextInt["Next.js Integration"]:::adapter
        ViteInt["Vite Integration"]:::adapter
        ExpressAdapter["Express Adapter"]:::adapter
        KoaAdapter["Koa Adapter"]:::adapter
    end

    subgraph "API Layer"
        APIService["API Service"]:::api
        APIServer["API Server"]:::api
        APIClient["API Client"]:::api
        Federation["API Federation"]:::feature
    end

    subgraph "Core HTTP Layer"
        HTTPFoundation["HTTP Foundation"]:::core
        CORS["CORS Middleware"]:::feature
    end

    subgraph "Core Framework"
        Pipeline["Pipeline System"]:::core
        Schema["Schema System"]:::core
        Module["Module System"]:::core
        JSONSchema["JSON Schema Support"]:::feature
    end

    subgraph "Development Tools"
        CreateApp["Create Farrow App"]:::tool
    end

    %% Relationships
    Client --> NextInt & ViteInt
    NextInt & ViteInt --> APIClient
    APIClient --> APIService
    APIService --> APIServer
    APIServer --> HTTPFoundation
    ExpressAdapter & KoaAdapter --> HTTPFoundation
    HTTPFoundation --> Pipeline
    Pipeline --> Schema
    Schema --> JSONSchema
    Module --> Pipeline
    CORS --> HTTPFoundation
    Federation --> APIService

    %% Click Events
    click Pipeline "https://github.com/farrow-js/farrow/blob/master/packages/farrow-pipeline/src/pipeline.ts"
    click Schema "https://github.com/farrow-js/farrow/blob/master/packages/farrow-schema/src/schema.ts"
    click HTTPFoundation "https://github.com/farrow-js/farrow/blob/master/packages/farrow-http/src/http.ts"
    click Module "https://github.com/farrow-js/farrow/blob/master/packages/farrow-module/src/module.ts"
    click APIService "https://github.com/farrow-js/farrow/blob/master/packages/farrow-api/src/api.ts"
    click APIServer "https://github.com/farrow-js/farrow/blob/master/packages/farrow-api-server/src/apiService.ts"
    click APIClient "https://github.com/farrow-js/farrow/blob/master/packages/farrow-api-client/src/farrow-api-client.ts"
    click ExpressAdapter "https://github.com/farrow-js/farrow/blob/master/packages/farrow-express/src/adapter.ts"
    click KoaAdapter "https://github.com/farrow-js/farrow/blob/master/packages/farrow-koa/src/adapter.ts"
    click NextInt "https://github.com/farrow-js/farrow/blob/master/packages/farrow-next/src/index.ts"
    click ViteInt "https://github.com/farrow-js/farrow/blob/master/packages/farrow-vite/src/vite.ts"
    click CORS "https://github.com/farrow-js/farrow/blob/master/packages/farrow-cors/src/index.ts"
    click Federation "https://github.com/farrow-js/farrow/blob/master/packages/farrow-federation/src/federation.ts"
    click JSONSchema "https://github.com/farrow-js/farrow/blob/master/packages/farrow-json-schema/src/farrow-json-schema.ts"
    click CreateApp "https://github.com/farrow-js/farrow/blob/master/packages/create-farrow-app/src/index.ts"

    %% Styling
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef api fill:#48a9a6,stroke:#000,stroke-width:2px,color:#fff
    classDef adapter fill:#e4572e,stroke:#000,stroke-width:2px,color:#fff
    classDef feature fill:#a663cc,stroke:#000,stroke-width:2px,color:#fff
    classDef tool fill:#17bebb,stroke:#000,stroke-width:2px,color:#fff
```
