# opennextjs/opennextjs-netlify architecture

> Architecture diagram of the GitHub repository opennextjs/opennextjs-netlify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/opennextjs/opennextjs-netlify
- Repository: https://github.com/opennextjs/opennextjs-netlify

## Overview

##### Main Components

a. Build System Components:
- Build Process Handler (/src/build/)
- Plugin Context Manager
- Content Handlers (Static/Server)
- Function Generators (Edge/Server)
- Image CDN Handler

b. Runtime Components:
- Edge Runtime Environment (/edge-runtime/)
- Headers Management
- Middleware Processing
- Request/Response Handlers
- Routing System

c. Integration Layer:
- Netlify Forms Handler
- Cache Management System
- Regional Blob Store
- Revalidation System

##### Component Relationships

- Build-time flow: Source → Build Process → Generated Functions
- Runtime flow: Request → Edge/Server Functions → Response
- Cache/Revalidation flow: Content Updates → Cache Invalidation → Redeployment

**┌─────────────────────────────────────────────────────────────┐**
- Netlify Platform                        │
- ┬─────────────────────┬───────────────────┤
- Build Process  │  Runtime Environment │  Integration Layer│
- ┌──────────┐   │   ┌──────────────┐  │  ┌────────────┐  │
- Plugin    │   │   │Edge Runtime  │  │  │Forms       │  │
- Context   │   │   │  ┌────────┐  │  │  │Handler    │  │
- ┘   │   │  │Headers │  │  │  └────────────┘  │
- ┌──────────┐   │   │  └────────┘  │  │  ┌────────────┐  │
- Content   │   │   │  ┌────────┐  │  │  │Cache       │  │
- Handlers  │   │   │  │Router  │  │  │  │System      │  │
- ┘   │   │  └────────┘  │  │  └────────────┘  │
- ┌──────────┐   │   └──────────────┘  │  ┌────────────┐  │
- Function  │   │   ┌──────────────┐  │  │Blob Store  │  │
- Generator │   │   │Server Runtime │  │  └────────────┘  │
- ┘   │   └──────────────┘  │                  │
- ┴─────────────────────┴───────────────────┘

##### Important Elements to Highlight
- Version compatibility (Next.js 13.5+)
- Node.js runtime requirements (18+)
- Edge function capabilities
- Cache invalidation paths
- Regional blob storage integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Platform[Netlify Platform]
        subgraph Build[Build Process]
            BPH[Build Process Handler]:::build
            PCM[Plugin Context Manager]:::build
            CH[Content Handlers]:::build
            FG[Function Generators]:::build
            ICDN[Image CDN Handler]:::build
            
            CH --> StaticH[Static Handler]:::build
            CH --> ServerH[Server Handler]:::build
            FG --> EdgeF[Edge Functions]:::build
            FG --> ServerF[Server Functions]:::build
        end

        subgraph Runtime[Runtime Environment]
            ERE[Edge Runtime Environment]:::runtime
            HM[Headers Management]:::runtime
            MP[Middleware Processing]:::runtime
            RH[Request Handler]:::runtime
            ResH[Response Handler]:::runtime
            RS[Routing System]:::runtime
        end

        subgraph Integration[Integration Layer]
            FH[Forms Handler]:::integration
            CMS[Cache Management System]:::integration
            RBS[Regional Blob Store]:::integration
            RevS[Revalidation System]:::integration
        end

        %% Build Process Relationships
        BPH --> PCM
        PCM --> CH
        PCM --> FG
        PCM --> ICDN

        %% Runtime Relationships
        ERE --> HM
        ERE --> MP
        ERE --> RH
        ERE --> ResH
        ERE --> RS

        %% Integration Relationships
        CMS --> RevS
        RevS --> RBS
    end

    %% Styling
    classDef build fill:#2374ab,color:#fff
    classDef runtime fill:#2a9d8f,color:#fff
    classDef integration fill:#e76f51,color:#fff

    %% Click Events
    click BPH "https://github.com/opennextjs/opennextjs-netlify/tree/main/src/build/"
    click PCM "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/build/plugin-context.ts"
    click StaticH "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/build/content/static.ts"
    click ServerH "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/build/content/server.ts"
    click EdgeF "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/build/functions/edge.ts"
    click ServerF "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/build/functions/server.ts"
    click ICDN "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/build/image-cdn.ts"
    click ERE "https://github.com/opennextjs/opennextjs-netlify/tree/main/edge-runtime/"
    click HM "https://github.com/opennextjs/opennextjs-netlify/blob/main/edge-runtime/lib/headers.ts"
    click MP "https://github.com/opennextjs/opennextjs-netlify/blob/main/edge-runtime/lib/middleware.ts"
    click RH "https://github.com/opennextjs/opennextjs-netlify/blob/main/edge-runtime/lib/next-request.ts"
    click ResH "https://github.com/opennextjs/opennextjs-netlify/blob/main/edge-runtime/lib/response.ts"
    click RS "https://github.com/opennextjs/opennextjs-netlify/blob/main/edge-runtime/lib/routing.ts"
    click CMS "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/run/handlers/cache.cts"
    click RBS "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/run/regional-blob-store.cts"
    click RevS "https://github.com/opennextjs/opennextjs-netlify/blob/main/src/run/revalidate.ts"
```
