# no-cash-7970/txnduck architecture

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

- Interactive diagram: https://gitdiagram.com/no-cash-7970/txnduck
- Repository: https://github.com/no-cash-7970/txnduck

## Overview

##### Project Type and Purpose
- This is a full-stack, web-based GUI built on Next.js (using the new App Router) and React. It is designed as a Progressive Web App (PWA) to help end users build, import/export, sign, and send Algorand transactions via a graphical interface.
- There is no traditional “backend” API layer of your own—most business logic lives in React components and utilities on the client, with occasional server‐side rendering by Next.js. Transaction submission and query happen against an Algorand node (Algod) configured via environment variables.

##### File Structure Analysis
- Top-level: Dockerfile, docker-compose.yml, CI/CD workflow definitions (.github/workflows), next.config.ts, middleware.ts, .env.* for multiple environments.
- src/app: Next.js App Router directory, with dynamic language subfolders ([lang]) holding pages (page.tsx), components, layouts, error pages.
- src/app/components & nested: Reusable UI atoms/molecules for forms, navbars, dialogs, loading placeholders, theming, notifications.
- src/app/lib: Utility modules for app settings, node configuration, transaction data processing and validation, wallet helper, i18n client setup, and mock/testing helpers.
- src/e2e, jest.config.mjs, playwright.config.ts: End-to-end (Playwright) and unit (Jest) tests.
- Public assets (public/) and static global CSS (globals.css).
- CI/CD: GitHub Actions for build, test, Docker image releases; lefthook.yml for local Git hooks.

##### Key Architectural Patterns
- Client-Server separation via Next.js: server-side rendering of React pages, client-side hydration for interactivity.
- Component-based UI (React) with atomic design principles (form fields, dialogs, steps, etc.).
- Global state management via Jotai atoms.
- Internationalization using i18next.
- Environment-driven configuration (Algod endpoint, chain parameters).
- PWA features (manifest, service worker via Next.js middleware).

##### Main System Components
- Browser / PWA Shell
- Next.js–rendered pages (SSR/SSG)
- React components—UI, form builders, dialogs.
- Jotai state store and i18next client for multilingual support.
- algosdk (or REST calls) to Algod node.
- File input/output for import/export of txn files.
- Next.js Application
- App Router (routes under src/app/[lang]).
- Server components for SSR of static and dynamic pages.
- Middleware for PWA caching, internationalization routing.
- Build pipeline (Gulp, PostCSS, Tailwind CSS).
- External Services
- Algorand Node (Algod REST API) – configurable endpoint via ENV.
- Optional indexer or other blockchain explorers (if extended).
- DevOps / CI
- GitHub Actions workflows for testing, building, and publishing Docker images.
- Docker Compose for local development (simulating Algod and hosting).
- Testing Frameworks
- Jest for unit/component tests.
- Playwright for end-to-end flow testing.

##### Relationships and Data Flows
- User interacts with PWA/UI → triggers React components → updates Jotai state.
- UI compiles transaction parameters → sends REST calls to Algod node directly from the browser or via Next.js server.
- Server-side rendering uses .env settings to prefetch any necessary configuration (e.g., default node URLs).
- Transaction export downloads a .txn.msgpack file; import reads and hydrates state.
- CI pipelines watch code changes, run Jest/Playwright, then build and deploy Docker image to Vercel (or other host).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Runtime
    subgraph "Client Runtime" 
        direction TB
        Browser["Browser / PWA Shell"]:::frontend
        UI["UI Components (Atomic Design)"]:::frontend
        Compose["Transaction Compose Module"]:::frontend
        Sign["Transaction Sign Module"]:::frontend
        Send["Transaction Send Module"]:::frontend
        State["Jotai State Store"]:::state
        I18n["i18next Client"]:::state
        AlgodCall["Algod REST API Calls"]:::external
        FileIO["File Import/Export"]:::frontend
    end

    %% Server Runtime
    subgraph "Server Runtime"
        direction TB
        NextApp["Next.js App Router"]:::frontend
        Middleware["Middleware (PWA Caching & Locale)"]:::config
        Env["Environment Config (.env)"]:::config
        Build["Build Pipeline (Gulp/PostCSS/Tailwind)"]:::config
    end

    %% External Services
    subgraph "External Dependencies"
        direction TB
        AlgodNode["Algod Node (Algod REST API)"]:::external
        Indexer["Optional Indexer/Explorer"]:::external
    end

    %% DevOps & CI/CD
    subgraph "DevOps / CI"
        direction TB
        DockerCompose["Docker Compose & Dockerfile"]:::devops
        CI["GitHub Actions Workflows"]:::devops
    end

    %% Testing
    subgraph "Testing"
        direction TB
        UnitTest["Unit Testing (Jest)"]:::testing
        E2E["End-to-End Testing (Playwright)"]:::testing
    end

    %% Connections
    Browser -->|"renders SSR/SSG"| NextApp
    NextApp -->|"serves assets"| Browser
    Browser -->|"updates"| State
    UI --> State
    Compose --> State
    Sign --> State
    Send --> State
    Browser -->|REST calls| AlgodNode
    State -->|reads/writes| FileIO
    Middleware --> NextApp
    Env --> NextApp
    Build --> NextApp
    CI --> DockerCompose
    DockerCompose --> AlgodNode
    CI --> NextApp
    UnitTest --> NextApp
    UnitTest --> UI
    E2E --> Browser

    %% Detailed Flows
    Browser --> I18n
    Middleware --> I18n
    Browser --> UI
    UI --> Compose
    Compose --> AlgodCall
    Sign --> AlgodCall
    Send --> AlgodCall

    %% Click Events
    click NextApp "https://github.com/no-cash-7970/txnduck/tree/main/src/app/[lang]"
    click UI "https://github.com/no-cash-7970/txnduck/tree/main/src/app/[lang]/components"
    click Compose "https://github.com/no-cash-7970/txnduck/tree/main/src/app/[lang]/txn/compose"
    click Sign "https://github.com/no-cash-7970/txnduck/tree/main/src/app/[lang]/txn/sign"
    click Send "https://github.com/no-cash-7970/txnduck/tree/main/src/app/[lang]/txn/send"
    click State "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/txn-data/atoms.ts"
    click State "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/txn-data/constants.ts"
    click State "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/txn-data/index.ts"
    click I18n "https://github.com/no-cash-7970/txnduck/blob/main/src/app/i18n/client.ts"
    click I18n "https://github.com/no-cash-7970/txnduck/blob/main/src/app/i18n/index.ts"
    click I18n "https://github.com/no-cash-7970/txnduck/tree/main/src/app/i18n/locales"
    click Env "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/node-config.ts"
    click Env "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/app-settings.ts"
    click FileIO "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/utils.ts"
    click FileIO "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/txn-data/processor.ts"
    click FileIO "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/validation-set-locale.ts"
    click Middleware "https://github.com/no-cash-7970/txnduck/blob/main/middleware.ts"
    click Build "https://github.com/no-cash-7970/txnduck/blob/main/gulpfile.mjs"
    click Build "https://github.com/no-cash-7970/txnduck/blob/main/postcss.config.js"
    click Build "https://github.com/no-cash-7970/txnduck/blob/main/next.config.ts"
    click Env "https://github.com/no-cash-7970/txnduck/blob/main/.env"
    click Env "https://github.com/no-cash-7970/txnduck/blob/main/.env.development"
    click Env "https://github.com/no-cash-7970/txnduck/blob/main/.env.production"
    click Env "https://github.com/no-cash-7970/txnduck/blob/main/.env.test"
    click DockerCompose "https://github.com/no-cash-7970/txnduck/tree/main/Dockerfile"
    click DockerCompose "https://github.com/no-cash-7970/txnduck/blob/main/docker-compose.yml"
    click CI "https://github.com/no-cash-7970/txnduck/blob/main/.github/workflows/ci_checks.yml"
    click CI "https://github.com/no-cash-7970/txnduck/blob/main/.github/workflows/release_docker_image.yml"
    click CI "https://github.com/no-cash-7970/txnduck/blob/main/.github/workflows/release_standalone.yml"
    click UnitTest "https://github.com/no-cash-7970/txnduck/blob/main/jest.config.mjs"
    click UnitTest "https://github.com/no-cash-7970/txnduck/blob/main/src/app/[lang]/**/*.test.tsx"
    click UnitTest "https://github.com/no-cash-7970/txnduck/blob/main/src/app/lib/**/*.test.ts"
    click E2E "https://github.com/no-cash-7970/txnduck/blob/main/playwright.config.ts"
    click E2E "https://github.com/no-cash-7970/txnduck/tree/main/src/e2e"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
    classDef state fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20
    classDef external fill:#eeeeee,stroke:#424242,color:#424242
    classDef devops fill:#ffe0b2,stroke:#e65100,color:#e65100
    classDef testing fill:#e1bee7,stroke:#6a1b9a,color:#6a1b9a
    classDef config fill:#fff9c4,stroke:#f57f17,color:#f57f17
```
