# trosdan/todoapp-frontend architecture

> Architecture diagram of the GitHub repository trosdan/todoapp-frontend, 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/trosdan/todoapp-frontend
- Repository: https://github.com/trosdan/todoapp-frontend

## Overview

##### Project type and purpose
- This is a full-stack ToDo application:
- Frontend: React Single-Page App (SPA)
- Backend: NodeJS functions hosted on Firebase (REST API)
- Persistence & Auth: Firebase Realtime Database and Firebase Auth

##### File structure
- Top-level: config files (.env.example, .firebaserc, firebase.json), CI workflows, package.json
- public/: static HTML, manifest, images → served by Firebase Hosting
- src/
- App.js, index.js → SPA bootstrap
- components/ → reusable UI (CardTodo, ModalTodo)
- pages/ → route-level views (home, login)
- routes/ → React Router setup
- services/ → API client (api.js), history.js, REST module (services/rest/todo)
- styles/ → global styles (styled-components)
- assets_readme/ → documentation images

##### README insights
- Hosted entirely on Firebase: Hosting (React) + Functions (Node.js back end)
- Uses environment variables for Firebase config & REACT_APP_BASE_URL → local dev at http://localhost:3333
- No on-premise server; all deployed to Google Cloud via Firebase

##### Main components & their relationships
A. Browser (User Agent)
- Loads React SPA (index.html + JS/CSS) from Firebase Hosting
- Renders UI components/pages, handles client-side routing (React Router)
- Invokes REST API via Axios (services/api.js)
B. Firebase Hosting (CDN)
- Serves static assets (public/ and build/)
C. React Frontend
- UI Layers: pages → components → styles
- Client-side Router: /login, /home
- Service Layer:
– services/api.js configures base URL
– services/rest/todo calls HTTP endpoints to create, read, update, delete todos
D. Firebase Functions (Node.js Backend)
- Exposes REST endpoints on REACT_APP_BASE_URL (e.g. /todo)
- Implements business logic: authenticate user, validate payload, read/write to DB
E. Firebase Realtime Database
- Stores user todos, authentication state, user profiles
F. Firebase Auth (External Service)
- Manages user sign-in/sign-up flows
G. (Optional) Firebase Storage if used for attachments/images

##### Architectural patterns & design principles
- Single-Page App (SPA) pattern: client heavy, server provides only APIs & static files
- Layered architecture:
- Presentation (React components)
- Application (React pages + service layer)
- Infrastructure (Firebase Hosting, Functions, DB)
- Separation of concerns: UI vs. API vs. data layer
- Client-side routing decoupled from server routing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client Side" 
        direction TB
        Browser["Browser (User Agent)"]:::client
        ReactSPA["React SPA"]:::client
        Router["React Router\n(routes)"]:::client
        Pages["Pages\n(home, login)"]:::client
        Components["UI Components\n(CardTodo, ModalTodo)"]:::client
        Services["Service Layer\n(api.js, history.js, todo REST)"]:::client
        Styles["Global Styles\n(global.js)"]:::client

        Browser -->|"loads index.html & JS"| ReactSPA
        ReactSPA -->|"/"| Router
        Router -->|"renders"| Pages
        Pages -->|"uses"| Components
        ReactSPA -->|"injects styles"| Styles
        ReactSPA -->|"calls REST"| Services
    end

    %% Google Cloud / Firebase
    subgraph "Google Cloud / Firebase"
        direction TB
        Hosting["Firebase Hosting\n(static assets)"]:::compute
        Functions["Firebase Functions\nREST API"]:::compute
        Database["Realtime Database"]:::data
        Auth["Firebase Auth"]:::external

        ReactSPA -->|HTTPS 443| Hosting
        Hosting -->|serves| ReactSPA
        Services -->|HTTPS 443| Functions
        Functions -->|read/write| Database
        Functions -->|verify token| Auth
    end

    %% CI/CD
    subgraph "CI/CD Pipelines"
        direction TB
        GH_Actions["GitHub Actions\ndeploy to Firebase"]:::misc
        GitLab_CI["GitLab CI\ndeploy config"]:::misc

        GH_Actions -->|deploy| Hosting
        GitLab_CI -->|deploy| Hosting
    end

    %% Legend
    subgraph "Legend"
        direction LR
        Client["Client/UI"]:::client
        Compute["Compute/Functions"]:::compute
        Data["Datastore"]:::data
        External["External Service"]:::external
        Misc["Misc/CI"]:::misc
    end

    %% Click Events - Client Side
    click ReactSPA "https://github.com/trosdan/todoapp-frontend/blob/master/src/index.js"
    click ReactSPA "https://github.com/trosdan/todoapp-frontend/blob/master/src/App.js"
    click Components "https://github.com/trosdan/todoapp-frontend/blob/master/src/components/CardTodo/index.js"
    click Components "https://github.com/trosdan/todoapp-frontend/blob/master/src/components/CardTodo/styles.js"
    click Components "https://github.com/trosdan/todoapp-frontend/blob/master/src/components/ModalTodo/index.js"
    click Components "https://github.com/trosdan/todoapp-frontend/blob/master/src/components/ModalTodo/styles.js"
    click Pages "https://github.com/trosdan/todoapp-frontend/blob/master/src/pages/home/index.js"
    click Pages "https://github.com/trosdan/todoapp-frontend/blob/master/src/pages/home/styles.js"
    click Pages "https://github.com/trosdan/todoapp-frontend/blob/master/src/pages/login/index.js"
    click Pages "https://github.com/trosdan/todoapp-frontend/blob/master/src/pages/login/styles.js"
    click Router "https://github.com/trosdan/todoapp-frontend/blob/master/src/routes/Route.js"
    click Router "https://github.com/trosdan/todoapp-frontend/blob/master/src/routes/index.js"
    click Services "https://github.com/trosdan/todoapp-frontend/blob/master/src/services/api.js"
    click Services "https://github.com/trosdan/todoapp-frontend/blob/master/src/services/history.js"
    click Services "https://github.com/trosdan/todoapp-frontend/blob/master/src/services/rest/todo/index.js"
    click Styles "https://github.com/trosdan/todoapp-frontend/blob/master/src/styles/global.js"

    %% Click Events - Hosting & Config
    click Hosting "https://github.com/trosdan/todoapp-frontend/tree/master/public/"
    click Hosting "https://github.com/trosdan/todoapp-frontend/blob/master/firebase.json"
    click Hosting "https://github.com/trosdan/todoapp-frontend/blob/master/.firebaserc"
    click EnvConfig "https://github.com/trosdan/todoapp-frontend/blob/master/.env.example"

    %% Click Events - Package
    click Package "https://github.com/trosdan/todoapp-frontend/blob/master/package.json"

    %% Click Events - CI/CD
    click GH_Actions "https://github.com/trosdan/todoapp-frontend/blob/master/.github/workflows/main.yml"
    click GitLab_CI "https://github.com/trosdan/todoapp-frontend/blob/master/.gitlab-ci.yml"

    %% Additional Clicks
    click EnvConfig "https://github.com/trosdan/todoapp-frontend/blob/master/.env.example"
    click Package "https://github.com/trosdan/todoapp-frontend/blob/master/package.json"

    classDef client fill:#DDEEFF,stroke:#333,stroke-width:1px
    classDef compute fill:#DDFFDD,stroke:#333,stroke-width:1px
    classDef data fill:#FFEEDD,stroke:#333,stroke-width:1px
    classDef external fill:#EEDDFF,stroke:#333,stroke-width:1px
    classDef misc fill:#F0F0F0,stroke:#333,stroke-width:1px
```
