# bv-brc/bv-brc-web architecture

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

- Interactive diagram: https://gitdiagram.com/bv-brc/bv-brc-web
- Repository: https://github.com/bv-brc/bv-brc-web

## Overview

##### Main Architecture Components

The system appears to be a full-stack web application with the following key components:

a. Frontend Layer:
- Client-side application built with Dojo framework (evident from /public/js/dojo directory)
- Multiple widgets and viewers for different functionalities (/public/js/p3/widget/)
- Specialized visualization components for genomics data
- Multiple search interfaces (/public/js/p3/widget/search/)

b. Backend Layer:
- Node.js server application (app.js as entry point)
- Express.js framework (evident from routes directory)
- RESTful API routes (/routes directory)

c. Services Layer:
- Worker services (/public/worker/)
- Data stores (/public/js/p3/store/)
- Authentication services (evident from login-related components)

##### Key Architectural Patterns to Highlight

a. MVC Pattern:
- Models: Store implementations in /public/js/p3/store/
- Views: Widget implementations in /public/js/p3/widget/
- Controllers: Route handlers in /routes/

b. Modular Widget System:
- Base widgets with inheritance
- Specialized viewers for different data types
- Reusable components

- Client Layer              |

- Widgets  |  |     Viewers     |  |

- Stores    |  |     Search      |  |

- Server Layer               |

- Routes    |  |  Controllers    |  |

- Workers   |  |   Services      |  |

- Data Layer                |

- Models    |  |     Storage     |  |

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        App["Client Application"]:::client
        Widgets["Widget System"]:::client
        Viewers["Specialized Viewers"]:::client
        Search["Search Interfaces"]:::client
        Stores["Data Stores"]:::client
        Charts["Visualization Components"]:::client
        
        App --> Widgets
        App --> Viewers
        App --> Search
        App --> Stores
        App --> Charts
    end

    subgraph Server
        ServerApp["Server Application"]:::server
        Routes["Routes"]:::server
        APIRoutes["API Routes"]:::server
        AuthRoutes["Auth Routes"]:::server
        WorkspaceRoutes["Workspace Routes"]:::server
        
        ServerApp --> Routes
        Routes --> APIRoutes
        Routes --> AuthRoutes
        Routes --> WorkspaceRoutes
    end

    subgraph Services
        Workers["Worker Services"]:::service
        PathwayWorker["Pathway Service"]:::service
        ProteinWorker["Protein Families Service"]:::service
        
        Workers --> PathwayWorker
        Workers --> ProteinWorker
    end

    subgraph Views
        Templates["View Templates"]:::view
        PageTemplates["Page Templates"]:::view
        ErrorTemplates["Error Templates"]:::view
        
        Templates --> PageTemplates
        Templates --> ErrorTemplates
    end

    subgraph Resources
        CSS["CSS Resources"]:::resource
        Images["Images"]:::resource
    end

    Stores --> APIRoutes
    Workers --> APIRoutes
    Routes --> Templates
    App --> Routes

    classDef client fill:#3498db
    classDef server fill:#2ecc71
    classDef service fill:#9b59b6
    classDef view fill:#f1c40f
    classDef resource fill:#e74c3c

    click App "https://github.com/BV-BRC/BV-BRC-Web/blob/master/public/js/p3/app/p3app.js"
    click Widgets "https://github.com/BV-BRC/BV-BRC-Web/tree/master/public/js/p3/widget"
    click Viewers "https://github.com/BV-BRC/BV-BRC-Web/tree/master/public/js/p3/widget/viewer"
    click Search "https://github.com/BV-BRC/BV-BRC-Web/tree/master/public/js/p3/widget/search"
    click Stores "https://github.com/BV-BRC/BV-BRC-Web/tree/master/public/js/p3/store"
    click Charts "https://github.com/BV-BRC/BV-BRC-Web/blob/master/public/js/p3/widget/D3BarChartRace.js"
    click ServerApp "https://github.com/BV-BRC/BV-BRC-Web/blob/master/app.js"
    click Routes "https://github.com/BV-BRC/BV-BRC-Web/tree/master/routes"
    click APIRoutes "https://github.com/BV-BRC/BV-BRC-Web/blob/master/routes/api.js"
    click AuthRoutes "https://github.com/BV-BRC/BV-BRC-Web/blob/master/routes/users.js"
    click WorkspaceRoutes "https://github.com/BV-BRC/BV-BRC-Web/blob/master/routes/workspace.js"
    click Workers "https://github.com/BV-BRC/BV-BRC-Web/tree/master/public/worker"
    click PathwayWorker "https://github.com/BV-BRC/BV-BRC-Web/blob/master/public/worker/PathwayServiceWorker.js"
    click ProteinWorker "https://github.com/BV-BRC/BV-BRC-Web/blob/master/public/worker/ProteinFamiliesServiceWorker.js"
    click Templates "https://github.com/BV-BRC/BV-BRC-Web/tree/master/views"
    click PageTemplates "https://github.com/BV-BRC/BV-BRC-Web/tree/master/views/pages"
    click ErrorTemplates "https://github.com/BV-BRC/BV-BRC-Web/blob/master/views/error.ejs"
    click CSS "https://github.com/BV-BRC/BV-BRC-Web/tree/master/public/js/p3/resources"
    click Images "https://github.com/BV-BRC/BV-BRC-Web/tree/master/public/patric/images"
```
