# joshmerlino/insomnia-viewer architecture

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

- Interactive diagram: https://gitdiagram.com/joshmerlino/insomnia-viewer
- Repository: https://github.com/joshmerlino/insomnia-viewer

## Overview

##### Main Components

a. Frontend Layer (Web Application)
- React Components (from web/ts/components/)
- Static Assets (from web/static/)
- Styles (LESS files from web/styles/)
- Runtime Utilities

b. Backend Layer (Server)
- Express.js Server (src/server.ts)
- Middleware Stack (src/middleware/)
- Runtime Handlers (src/runtime/)

##### Component Relationships

- Client Browser → Frontend Layer
- Frontend Layer → Backend Layer (API requests)
- Backend Layer → Documentation Storage/Processing
- Middleware Chain Flow (showing the sequence of middleware components)

##### Specific Implementation Details

Frontend Section:
**┌─────────────────────────────────────┐**
- Frontend (React Application)        │
- ┌─────────────┐ ┌────────────────┐ │
- Components  │ │ Runtime Utils   │ │
- App       │ │ - ErrorBoundary │ │
- Docs      │ │ - Offline      │ │
- Search    │ │ Installation   │ │
- ┘ └────────────────┘ │
- ┌─────────────┐                    │
- Styles      │                    │
- (LESS)      │                    │
- ┘                    │
- ┘

Backend Section:
**┌─────────────────────────────────────┐**
- Backend (Express.js)                │
- ┌─────────────┐ ┌────────────────┐ │
- Middleware  │ │ Runtime        │ │
- Body      │ │ - Docs         │ │
- Cookie    │ │ - Static       │ │
- CORS      │ │                │ │
- SSL       │ │                │ │
- Gzip      │ │                │ │
- ┘ └────────────────┘ │
- ┘

##### Additional Elements

- Build/Deploy Pipeline:
- Webpack Configuration
- Docker Container
- GitHub Actions Workflows

- Blue: Frontend components
- Green: Backend components
- Orange: Build/Deploy tools
- Gray: External services/dependencies

##### Important Architectural Patterns to Highlight

- Component-based architecture (React)
- Middleware pattern (Express.js)
- Static file serving
- Documentation processing pipeline

##### Technical Stack Indicators

- TypeScript
- React
- Express.js
- Docker
- Webpack
- LESS

##### Flow Directions

- User request flow
- Documentation processing flow
- API communication paths
- Build/deployment pipeline

Remember to:
- Use consistent styling
- Version information
- Document all major integration points
- Security boundaries (if applicable)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Frontend["Frontend Layer"]
        direction TB
        Components["React Components"]
        StaticAssets["Static Assets"]
        Styles["Styles (LESS)"]
        RuntimeUtils["Runtime Utilities"]

        subgraph Components
            App["App Component"]
            Docs["Documentation Component"]
            Search["Search Component"]
        end

        subgraph RuntimeUtils
            ErrorBoundary["Error Boundary"]
            OfflineInstall["Offline Installation"]
        end

        subgraph Styles
            MainStyles["Main Styles"]
            MarkdownStyles["Markdown Styles"]
        end
    end

    subgraph Backend["Backend Layer"]
        direction TB
        Server["Express.js Server"]
        
        subgraph Middleware["Middleware Stack"]
            BodyParser["Body Parser"]
            CookieParser["Cookie Parser"]
            CORS["CORS"]
            SSL["SSL Force"]
            Gzip["Gzip"]
        end

        subgraph RuntimeHandlers["Runtime Handlers"]
            DocsHandler["Documentation Handler"]
            StaticHandler["Static Files Handler"]
        end
    end

    subgraph BuildDeploy["Build & Deploy"]
        Docker["Docker Container"]
        Webpack["Webpack"]
        GithubActions["GitHub Actions"]
    end

    %% Relationships
    Browser --> Components
    Components --> Server
    Server --> Middleware
    Middleware --> RuntimeHandlers

    %% Click events
    click App "https://github.com/joshMerlino/insomnia-viewer/blob/master/web/ts/components/App.tsx"
    click Docs "https://github.com/joshMerlino/insomnia-viewer/blob/master/web/ts/components/InsomniaDocs.tsx"
    click Search "https://github.com/joshMerlino/insomnia-viewer/blob/master/web/ts/components/InsomniaSearch.tsx"
    click Components "https://github.com/joshMerlino/insomnia-viewer/tree/master/web/ts/components/"
    click MainStyles "https://github.com/joshMerlino/insomnia-viewer/blob/master/web/styles/main.less"
    click MarkdownStyles "https://github.com/joshMerlino/insomnia-viewer/blob/master/web/styles/markdown.less"
    click Styles "https://github.com/joshMerlino/insomnia-viewer/tree/master/web/styles/"
    click ErrorBoundary "https://github.com/joshMerlino/insomnia-viewer/blob/master/web/ts/runtime/ErrorBoundry.tsx"
    click OfflineInstall "https://github.com/joshMerlino/insomnia-viewer/blob/master/web/ts/runtime/util/offlineInstaller.tsx"
    click Server "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/server.ts"
    click Middleware "https://github.com/joshMerlino/insomnia-viewer/tree/master/src/middleware/"
    click BodyParser "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/middleware/bodyParser.ts"
    click CookieParser "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/middleware/cookieParser.ts"
    click CORS "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/middleware/cors.ts"
    click SSL "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/middleware/forceSsl.ts"
    click Gzip "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/middleware/gzip.ts"
    click DocsHandler "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/runtime/docs.ts"
    click StaticHandler "https://github.com/joshMerlino/insomnia-viewer/blob/master/src/runtime/static.ts"
    click Docker "https://github.com/joshMerlino/insomnia-viewer/tree/master/Dockerfile"
    click Webpack "https://github.com/joshMerlino/insomnia-viewer/blob/master/webpack.conf.ts"
    click GithubActions "https://github.com/joshMerlino/insomnia-viewer/tree/master/.github/workflows/"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef build fill:#e67e22,stroke:#d35400,color:white
    classDef client fill:#95a5a6,stroke:#7f8c8d,color:white

    class Browser client
    class Components,App,Docs,Search,StaticAssets,Styles,RuntimeUtils,ErrorBoundary,OfflineInstall,MainStyles,MarkdownStyles frontend
    class Server,Middleware,BodyParser,CookieParser,CORS,SSL,Gzip,RuntimeHandlers,DocsHandler,StaticHandler backend
    class Docker,Webpack,GithubActions build
```
