# openreview/openreview-web architecture

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

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

## Overview

##### Main Components
- Next.js Frontend Server: The “pages” directory along with Next.js configuration (next.config.js) shows that server-side rendering and routing are managed by Next.js. This is the central part that handles incoming web requests.
- React Components Library: The “components” folder contains numerous reusable UI widgets (e.g., Nav, Editor Components, Forum components, Profiles, Webfield, etc.). These components form the building blocks of the UI.
- Legacy Client & Handlebars Templates: The “client” folder (especially the “client/templates” subdirectory with .hbs files) represents the legacy system that still provides some middleware or page rendering behavior tied to Handlebars.
- API Communication & Utility Libraries: The “lib” folder (with files like api-client.js, auth.js, etc.) encapsulates functions for interfacing with the OpenReview API and performing other utility tasks.
- Hooks and State Management: The “hooks” directory shows custom React hooks that manage everything from authentication (useUser, useLoginRedirect) to interval-based polling, enhancing frontend reactivity.
- Testing Infrastructure: The presence of “tests” and “unitTests” directories, along with configuration files for Jest and TestCafe, indicates both unit testing and integration testing components for quality assurance.
- Deployment & Continuous Integration: The .github/workflows and other config files (.env.example, eslint, prettier) indicate automated build, deployment, and linting steps.

##### Component Relationships and Interactions
- The Next.js server (pages) renders the overall application and delegates rendering to React components. It also handles routing.
- React components (from “components” and “client”) are assembled to form the user interface. These components pull in data via API calls made through the “lib/api-client.js” and related modules.
- Custom React hooks (in “hooks”) facilitate state management and external interactions (e.g., socket, query, local storage) and are used by various components.
- The legacy Handlebars templates (compiled via “npm run templates” to generate client/templates.js) are used in parts of the system that haven’t migrated fully to React.
- The external OpenReview API (hosted separately) is the backend service that provides persistence, security, and data. Data flows bidirectionally between the frontend and this API.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project cleanly separates view components (React UI), page-level routing (Next.js “pages”), API handling (lib), and legacy template handling (client/templates).
- Component-based Design: The highly modular “components” directory, which further divides into specialized subdirectories (form elements, forum components, editor components, etc.), is a clear indicator of this.
- Integration of Legacy and Modern Approaches: The coexistence of Handlebars templates (legacy) with modern React components/Next.js pages requires careful mapping to show how data is shared and rendered.
- Automated Testing and CI/CD: The integration of Jest, TestCafe, and GitHub actions emphasizes testing and automated deployment pipelines.

##### Relevant Technologies, Frameworks, and Libraries
- Next.js and React: The core frameworks for frontend development.
- Handlebars: Used in legacy template rendering.
- Testing Tools: Jest for unit testing and TestCafe for end-to-end testing.
- ESLint and Prettier: For code quality and formatting.
- GitHub Workflows: For continuous integration and deployment.
- Custom Hooks and API libraries: For state management and backend API integration.

## Diagram (Mermaid)

```mermaid
graph TD
    U("User"):::user

    subgraph "Logic Layer"
        NFS("Next.js Frontend Server (pages)"):::server
        HC("Hooks and State Management"):::hooks
        AC("API Communication & Utility Libraries"):::lib
    end

    subgraph "Presentation Layer"
        RC("React Components Library"):::react
        LC("Legacy Client & Handlebars Templates"):::legacy
    end

    subgraph "External Integration"
        ORAPI("External OpenReview API"):::external
    end

    TI("Testing Infrastructure"):::testing
    CI("Deployment & Continuous Integration"):::ci

    U -->|"requests"| NFS
    NFS -->|"renders"| RC
    NFS -->|"renders"| LC
    RC -->|"uses"| HC
    HC -->|"handles"| AC
    AC -->|"calls"| ORAPI

    CI -->|"deploys"| NFS
    CI -->|"deploys"| RC
    CI -->|"deploys"| LC
    CI -->|"deploys"| AC
    CI -->|"deploys"| HC

    TI -->|"tests"| NFS
    TI -->|"tests"| RC
    TI -->|"tests"| LC
    TI -->|"tests"| AC
    TI -->|"tests"| HC

    %% Click Events
    click NFS "https://github.com/openreview/openreview-web/tree/master/pages"
    click RC "https://github.com/openreview/openreview-web/tree/master/components"
    click LC "https://github.com/openreview/openreview-web/tree/master/client/templates"
    click AC "https://github.com/openreview/openreview-web/tree/master/lib"
    click HC "https://github.com/openreview/openreview-web/tree/master/hooks"
    click TI "https://github.com/openreview/openreview-web/tree/master/tests"
    click CI "https://github.com/openreview/openreview-web/tree/master/.github/workflows"

    %% Styles
    classDef server fill:#FFE0E0,stroke:#CC0000,stroke-width:2px
    classDef react fill:#E0F7FF,stroke:#0077CC,stroke-width:2px
    classDef legacy fill:#FFF3E0,stroke:#FF8800,stroke-width:2px
    classDef lib fill:#FFF9C4,stroke:#F9A825,stroke-width:2px
    classDef hooks fill:#E8F5E9,stroke:#388E3C,stroke-width:2px
    classDef testing fill:#FCE4EC,stroke:#D81B60,stroke-width:2px
    classDef ci fill:#E3F2FD,stroke:#1976D2,stroke-width:2px
    classDef external fill:#E8F5E9,stroke:#388E3C,stroke-width:2px
    classDef user fill:#F3F3F3,stroke:#999999,stroke-width:2px
```
