# andrlime/newdebateapp architecture

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

- Interactive diagram: https://gitdiagram.com/andrlime/newdebateapp
- Repository: https://github.com/andrlime/newdebateapp

## Overview

##### Project type and purpose
- This is a full-stack web application called NewDebateApp.
- Frontend: Next.js + React + Mantine, providing UI for creating evaluations, generating pairings, managing judges and users, etc.
- Backend: A Rust microservice (currently) exposing REST endpoints for data persistence and business logic.
- Serverless: Two Python AWS Lambda handlers (CSV and OO processing) for specialized batch or on-demand tasks.

##### File structure
- Top-level directories:
- frontend – Next.js pages, UI components, client-side store (Redux-style slices)
- backend – Rust service with Cargo config, Dockerfile, source modules for DB, models, routes
- lambda – standalone Python scripts for AWS Lambda handlers
- Config/deployment: Dockerfiles in both frontend and backend; Rust’s Cargo.toml; Node’s package.json; tsconfig.json
- No infra as code repo here, but the presence of Dockerfiles implies containerized deployment

##### README for additional insights
- Technology choices: Next.js (no Tailwind) on frontend, Rust on backend, planned rewrite to Java/Kotlin Spring
- Improving maintainability, so clean separation of concerns is key

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client (Browser) - React/Next.js UI"
        direction TB
        subgraph "Components"
            direction TB
            CE["CreateEvaluation"]:::frontend
            Shell["DLCAppShell"]:::frontend
            Header["DLCHeader"]:::frontend
            NavBar["DLCNavBar"]:::frontend
            Inbox["InboxView"]:::frontend
            UserIcon["UserIcon"]:::frontend
        end
        subgraph "Pages (SSR/SPA)"
            direction TB
            Home["Home (index.tsx)"]:::frontend
            Signup["Sign Up"]:::frontend
            Login["Login"]:::frontend
            Evaluate["Evaluations"]:::frontend
            Pair["Pairings"]:::frontend
            Pairoo["Pair OO"]:::frontend
            Awards["Awards"]:::frontend
            Judges["Judges"]:::frontend
            Users["Users"]:::frontend
            NotFound["404"]:::frontend
        end
    end

    subgraph "Next.js Server/API Layer"
        direction TB
        API["API Route: /api/get"]:::api
        subgraph "State Management"
            direction TB
            AuthSlice["Auth Slice"]:::frontend
            EnvSlice["Environment Slice"]:::frontend
            TournSlice["Tournament Slice"]:::frontend
        end
        subgraph "Roots"
            direction TB
            EJ["Evaluate Judges"]:::frontend
            GA["Generate Awards"]:::frontend
            GP["Generate Pairings"]:::frontend
            GSP["Generate Speech Pairings"]:::frontend
            IU["Invite Users"]:::frontend
            JD["Judge Database"]:::frontend
            VP["View Paradigms"]:::frontend
        end
    end

    subgraph "Rust Backend Service"
        direction TB
        Main["main.rs"]:::backend
        Routes["routes.rs"]:::backend
        DBmod["db.rs"]:::backend
        subgraph "Models"
            direction TB
            ModMod["mod.rs"]:::backend
            Req["requests.rs"]:::backend
            Interfaces["interfaces.rs"]:::backend
        end
    end

    DB["PostgreSQL Database"]:::database

    subgraph "AWS Lambda (Serverless)"
        direction TB
        CSV["CSV Processing Handler"]:::lambda
        OO["OO Processing Handler"]:::lambda
    end

    %% Connections
    Home -->|"HTTP Request"| API
    Signup -->|"HTTP Request"| API
    Login -->|"HTTP Request"| API
    Evaluate -->|"HTTP Request"| API
    Pair -->|"HTTP Request"| API
    Pairoo -->|"HTTP Request"| API
    Awards -->|"HTTP Request"| API
    Judges -->|"HTTP Request"| API
    Users -->|"HTTP Request"| API

    API -->|"forwards to"| Main
    Main -->|"uses routes"| Routes
    Routes -->|"calls"| DBmod
    DBmod -->|"reads/writes"| DB

    Main -->|"invokes"| CSV
    Main -->|"invokes"| OO

    %% Click Events for frontend components
    click CE "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/components/CreateEvaluation.tsx"
    click Shell "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/components/DLCAppShell.tsx"
    click Header "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/components/DLCHeader.tsx"
    click NavBar "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/components/DLCNavBar.tsx"
    click Inbox "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/components/InboxView.tsx"
    click UserIcon "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/components/UserIcon.tsx"

    click Home "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/index.tsx"
    click Signup "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/signup.tsx"
    click Login "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/login.tsx"
    click Evaluate "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/evaluate.tsx"
    click Pair "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/pair.tsx"
    click Pairoo "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/pairoo.tsx"
    click Awards "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/awards.tsx"
    click Judges "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/judges.tsx"
    click Users "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/users.tsx"
    click NotFound "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/404.tsx"

    click API "https://github.com/andrlime/newdebateapp/blob/main/frontend/pages/api/get.ts"

    click AuthSlice "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/store/slices/auth.ts"
    click EnvSlice "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/store/slices/env.ts"
    click TournSlice "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/store/slices/tourn.ts"

    click EJ "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/roots/EvaluateJudges.tsx"
    click GA "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/roots/GenerateAwards.tsx"
    click GP "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/roots/GeneratePairings.tsx"
    click GSP "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/roots/GenerateSpeechPairings.tsx"
    click IU "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/roots/InviteUsers.tsx"
    click JD "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/roots/JudgeDatabase.tsx"
    click VP "https://github.com/andrlime/newdebateapp/blob/main/frontend/lib/roots/ViewParadigms.tsx"

    click Main "https://github.com/andrlime/newdebateapp/blob/main/backend/src/main.rs"
    click Routes "https://github.com/andrlime/newdebateapp/blob/main/backend/src/routes.rs"
    click DBmod "https://github.com/andrlime/newdebateapp/blob/main/backend/src/db.rs"
    click ModMod "https://github.com/andrlime/newdebateapp/blob/main/backend/src/models/mod.rs"
    click Req "https://github.com/andrlime/newdebateapp/blob/main/backend/src/models/requests.rs"
    click Interfaces "https://github.com/andrlime/newdebateapp/blob/main/backend/src/models/interfaces.rs"

    click CSV "https://github.com/andrlime/newdebateapp/blob/main/lambda/csv_lambda_handler.py"
    click OO "https://github.com/andrlime/newdebateapp/blob/main/lambda/oo_lambda_handler.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#5B8FF9,color:#000
    classDef api fill:#A0D911,stroke:#237804,color:#fff
    classDef backend fill:#D9F7BE,stroke:#389E0D,color:#000
    classDef database fill:#FFF1B8,stroke:#D48806,shape: cylinder
    classDef lambda fill:#FFE7BA,stroke:#FA8C16,color:#000
```
