# siryancealot-enterprises/rust-react-app-hello-world architecture

> Architecture diagram of the GitHub repository siryancealot-enterprises/rust-react-app-hello-world, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/siryancealot-enterprises/rust-react-app-hello-world
- Repository: https://github.com/siryancealot-enterprises/rust-react-app-hello-world

## Overview

##### Project type and purpose
- This is a full-stack “Rust + React” SPA application. The Rust server (using Axum) hosts both:
- a set of HTTP JSON APIs
- the static React artifacts (built by Node)
- At runtime it also interacts with two backing services:
- Postgres (via sqlx)
- Meilisearch (via the Meilisearch Rust SDK)
- Docker Compose automates the local startup of Postgres and Meilisearch.

##### File structure
- Top-level folders:
- my-react-ts-app/  → the React SPA (TypeScript, built by npm)
- src/              → Rust code (main.rs, lib.rs, API modules, service modules)
- migrations/       → SQLX database migration scripts
- .cargo/, .sqlx/   → configuration for Rust build & query caching
- compose.yaml      → Docker Compose spec for storefront of DB + search
- Rust services are organized under src/services (app_server, db, search, configs, tracing).
- API endpoints and resource definitions live in src/api.
- Binaries for utility tasks (init_dev_repo, docker_utils) under src/bin.

##### README
- Confirms Axum, sqlx + Postgres, Meilisearch integration.
- Describes how the Rust server is the only runtime serving both APIs and static SPA.
- Docker Compose is used to bring up Postgres and Meilisearch automatically.

##### Detail but avoid unnecessary sub-splitting
- How data and requests flow end-to-end.
- Essential external dependencies (Node build, Docker Compose services).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build-Time
    subgraph "Build Time" 
        direction TB
        NPM["Node.js (npm build)"]:::build
        StaticAssets["Static Assets"]:::backend
        NPM -->|builds| StaticAssets
    end

    %% Runtime
    subgraph "Runtime"
        direction TB
        Browser["Browser (React SPA)"]:::frontend
        AxumServer["Axum Server: Static + API"]:::backend
        DockerCompose["Docker Compose"]:::orchestration
        Postgres["Postgres DB"]:::db
        Meili["Meilisearch"]:::db

        Browser -->|HTTP GET/POST| AxumServer
        AxumServer -->|SQL queries| Postgres
        AxumServer -->|Search queries| Meili
        DockerCompose --> Postgres
        DockerCompose --> Meili
    end

    %% Axum Server Internals
    subgraph "Axum Server Internals"
        direction TB
        Main["main.rs"]:::backend
        Lib["lib.rs"]:::backend
        StaticHandler["Static-file Handler"]:::backend
        APILayer["API Layer"]:::backend
        ServiceLayer["Service Layer"]:::backend
        ConfigLayer["Config & Env"]:::backend
        TracingLayer["Logging/Tracing"]:::backend

        Main --> Lib
        Lib --> StaticHandler
        Lib --> APILayer
        APILayer --> ServiceLayer
        ServiceLayer --> ConfigLayer
        ServiceLayer --> TracingLayer
    end

    %% Modules inside API Layer
    subgraph "API Modules"
        direction TB
        API_rs["api.rs"]:::backend
        Endpoints_rs["endpoints.rs"]:::backend
        Resources_rs["resources.rs"]:::backend
        APILayer --> API_rs
        APILayer --> Endpoints_rs
        APILayer --> Resources_rs
    end

    %% Modules inside Service Layer
    subgraph "Service Modules"
        direction TB
        DB_rs["db.rs"]:::backend
        Search_rs["search.rs"]:::backend
        Configs_rs["configs.rs"]:::backend
        Tracing_rs["tracing.rs"]:::backend
        ServiceLayer --> DB_rs
        ServiceLayer --> Search_rs
        ServiceLayer --> Configs_rs
        ServiceLayer --> Tracing_rs
    end

    %% Environment & Utils
    subgraph "Config & Utils"
        direction TB
        EnvUtils["environment_utils.rs"]:::backend
        DevUtils["dev_and_test_utils.rs"]:::backend
        Migrations["migrations/"]:::db
        SQLOps[".sqlx/"]:::db
        EnvUtils --> DevUtils
    end

    %% Binaries & Tests
    subgraph "Utilities & Tests"
        direction TB
        InitDev["init_dev_repo.rs"]:::backend
        DockerUtils["docker_utils.rs"]:::backend
        CopyConfigs["copy_configs_for_debugger.rs"]:::backend
        TestsInt["tests/api_integration_tests.rs"]:::backend
        TestUtils["tests/test_utils/mod.rs"]:::backend
    end

    %% Orchestration & Config
    DockerCompose -->|orchestrates| Migrations
    DockerCompose -->|uses| SQLOps

    %% Legend (as nodes)
    classDef frontend fill:#D0E6A5,stroke:#4F772D,color:#4F772D;
    classDef backend fill:#A0C4FF,stroke:#3366A1,color:#3366A1;
    classDef db fill:#FFD6A5,stroke:#B56303,color:#B56303;
    classDef orchestration fill:#E2E2E2,stroke:#8F8F8F,color:#8F8F8F;
    classDef build fill:#FFADAD,stroke:#D00000,color:#D00000;

    %% Click Events
    click NPM "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/tree/main/my-react-ts-app/"
    click StaticHandler "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/services/app_server.rs"
    click API_rs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/api.rs"
    click Endpoints_rs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/api/endpoints.rs"
    click Resources_rs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/api/resources.rs"
    click DB_rs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/services/db.rs"
    click Search_rs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/services/search.rs"
    click Configs_rs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/services/configs.rs"
    click Tracing_rs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/services/tracing.rs"
    click Main "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/main.rs"
    click Lib "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/lib.rs"
    click EnvUtils "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/environment_utils.rs"
    click DevUtils "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/environment_utils/dev_and_test_utils.rs"
    click Migrations "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/tree/main/migrations/"
    click SQLOps "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/tree/main/.sqlx/"
    click DockerCompose "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/compose.yaml"
    click InitDev "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/bin/init_dev_repo.rs"
    click DockerUtils "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/bin/docker_utils.rs"
    click CopyConfigs "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/src/bin/copy_configs_for_debugger.rs"
    click TestsInt "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/tests/api_integration_tests.rs"
    click TestUtils "https://github.com/siryancealot-enterprises/rust-react-app-hello-world/blob/main/tests/test_utils/mod.rs"
```
