# v3dant21/grpc-todo architecture

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

- Interactive diagram: https://gitdiagram.com/v3dant21/grpc-todo
- Repository: https://github.com/v3dant21/grpc-todo

## Overview

##### Project type and purpose
- This is a Rust-based full-stack To-Do web application.
- Frontend: HTMX + Warp (serves HTML & handles HTMX requests).
- Backend: gRPC API (CRUD operations on todos).
- Persistence: SQLite with SQL migrations.
- Orchestration: Cargo workspaces + Cargo-Make to build/run both services.

##### File structure
- Workspace root
- Cargo.toml (defines both workspace members)
- makefile.toml (Cargo-Make tasks: run frontend, backend, migrations)
- grpc-todo (gRPC backend service)
- proto/todo.proto → gRPC service & message definitions
- build.rs → generates Rust code from .proto
- src/main.rs → CLI entry point (e.g. migrate, server)
- src/server.rs → sets up the gRPC server
- src/db.rs, migrations/*.sql → database setup & query layer
- htmx-warp (Frontend + HTTP→gRPC client)
- proto/todo.proto → shared definitions (client stubs)
- build.rs → generates client code
- src/index.html → HTMX-powered UI
- src/main.rs → Warp routes that serve index.html and proxy HTMX calls to gRPC backend
- SQLite files (todo.db, -shm, -wal) in workspace root

##### README for additional insights
- Tech stack: gRPC, HTMX, Warp, SQLite, Cargo workspaces/make
- Features: real-time UI via HTMX, modular crates, one-command run
- Setup: run migrations then “cargo make run-both” to start both services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestration Layer
    subgraph "Orchestration Layer"
        CM("Cargo-Make (run-both)"):::orchestration
        CT["Cargo.toml"]:::orchestration
        MF["makefile.toml"]:::orchestration
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        FW("Warp + HTMX Service"):::frontend
        F_main["main.rs"]:::frontend
        F_index["index.html"]:::frontend
        F_build["build.rs"]:::frontend
        F_proto["todo.proto"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BW("gRPC Todo Service"):::backend
        B_main["main.rs"]:::backend
        B_server["server.rs"]:::backend
        B_db["db.rs"]:::backend
        B_config["config.rs"]:::backend
        B_build["build.rs"]:::backend
        B_proto["todo.proto"]:::backend
        subgraph "Migrations"
            MIG["20250407170735_create_todos.sql"]:::migrations
            MIG2["20250415165109_init.sql"]:::migrations
        end
    end

    %% Database
    DB("SQLite Database"):::database

    %% External Browser
    Browser("User's Web Browser"):::external

    %% Connections
    CM -->|"runs migrations"| MIG
    CM -->|"runs migrations"| MIG2
    CM -->|"starts services"| FW
    CM -->|"starts services"| BW

    Browser -->|"HTMX & HTTP requests"| FW
    FW -->|"gRPC client calls"| BW
    BW -->|"executes SQL"| DB
    DB -->|"returns data"| BW
    BW -->|"gRPC responses"| FW
    FW -->|"renders HTML"| Browser

    F_proto --- B_proto

    %% Click Events
    click F_main "https://github.com/v3dant21/grpc-todo/blob/main/htmx-warp/src/main.rs"
    click F_index "https://github.com/v3dant21/grpc-todo/blob/main/htmx-warp/src/index.html"
    click F_build "https://github.com/v3dant21/grpc-todo/blob/main/htmx-warp/build.rs"
    click F_proto "https://github.com/v3dant21/grpc-todo/blob/main/htmx-warp/proto/todo.proto"
    click B_main "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/src/main.rs"
    click B_server "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/src/server.rs"
    click B_db "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/src/db.rs"
    click B_config "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/src/config.rs"
    click B_build "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/build.rs"
    click B_proto "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/proto/todo.proto"
    click MIG "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/migrations/20250407170735_create_todos.sql"
    click MIG2 "https://github.com/v3dant21/grpc-todo/blob/main/grpc-todo/migrations/20250415165109_init.sql"
    click CT "https://github.com/v3dant21/grpc-todo/blob/main/Cargo.toml"
    click MF "https://github.com/v3dant21/grpc-todo/blob/main/makefile.toml"
    click DB "https://github.com/v3dant21/grpc-todo/blob/main/todo.db"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000;
    classDef backend fill:#90EE90,stroke:#000;
    classDef database fill:#F4A460,stroke:#000;
    classDef migrations fill:#FFA500,stroke:#000,stroke-dasharray:5 5;
    classDef orchestration fill:#D3D3D3,stroke:#000;
    classDef external fill:#E0E0E0,stroke:#000;
```
