# 0xmerso/tycho-orderbook-web architecture

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

- Interactive diagram: https://gitdiagram.com/0xmerso/tycho-orderbook-web
- Repository: https://github.com/0xmerso/tycho-orderbook-web

## Overview

- Frontend: Represent the open‐source NextJS frontend which handles user interactions and visualization. Label it clearly as “Frontend (NextJS)”.
- Backend: Represent the Rust API built with Axum. Label it “Backend API (Rust, Axum)”.
- Shared Backend Modules: Within the backend, break out internal modules (as seen in the “back/src/shared” folder) such as “data”, “getters”, “helpers”, “misc”, “types”, and the “axum” entry point. These modules encapsulate business logic and helper functionalities.

- Within the backend, show the interdependency between the main API entry point (axum.rs) and the shared modules. This highlights that the API logic is built upon these modular components.

##### Architectural patterns and design principles
- Separation of Concerns: Demonstrated by splitting the project into a frontend and backend.
- Modular Design: In the backend, emphasize the shared library (various helper and utility modules) which promotes code reuse and maintainability.
- Containerization & Automation: The presence of Docker files and shell scripts indicates that the application is meant to be easily deployable and tested in a controlled environment.

##### Relevant technologies and frameworks
- Frontend: NextJS which facilitates server-side rendering and a rich UI experience.
- Backend: Rust language with the Axum framework, emphasizing high-performance API handling.
- Docker: Containerization and orchestration via docker-compose for integration and testing.
- Additional tooling: Rust configuration files (Cargo.toml, rustfmt.toml) that emphasize code style and package management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE["Frontend (NextJS)"]:::ui
    end

    subgraph "Backend Layer"
        BA["Backend API (Rust, Axum)"]:::api
        subgraph "Shared Modules"
            SM["Data / Getters / Helpers / Misc / Types"]:::shared
        end
        BA -->|"uses"| SM
        BA -->|"fetches onchain"| EO["External Onchain Services (Tycho)"]:::external
    end

    subgraph "Deployment & Ops"
        DO["Deployment & Ops (Docker Compose, Scripts)"]:::ops
    end

    FE -->|"HTTP requests"| BA
    DO -->|"containerizes"| FE
    DO -->|"containerizes"| BA

    click FE "https://github.com/0xmerso/tycho-orderbook-web/tree/main/front/"
    click BA "https://github.com/0xmerso/tycho-orderbook-web/blob/main/back/src/axum.rs"
    click SM "https://github.com/0xmerso/tycho-orderbook-web/tree/main/back/src/shared/"
    click DO "https://github.com/0xmerso/tycho-orderbook-web/tree/main/back/ops/"

    classDef ui fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef api fill:#aed6f1,stroke:#1b4f72,stroke-width:2px;
    classDef shared fill:#d5f5e3,stroke:#1e8449,stroke-width:2px;
    classDef external fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef ops fill:#ffe6cc,stroke:#e67e22,stroke-width:2px;
```
