# coffeefuelbump/actual-backend-app architecture

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

- Interactive diagram: https://gitdiagram.com/coffeefuelbump/actual-backend-app
- Repository: https://github.com/coffeefuelbump/actual-backend-app

## Overview

##### Project type and purpose
- This is a full-stack single-page application (SPA) built with React (in src/) and hosted on Firebase Hosting (public/).
- The backend is entirely serverless, using Firebase services: Authentication, Firestore, Hosting, Cloud Functions (both Node.js and Python).
- Its purpose (per the README) is to “actually learn backend” by building an app’s backend with AI‐powered features (Cursor AI, Claude AI), Firebase, and GitHub integration.

##### File structure
- Top-level config:
- firebase.json, .firebaserc – Firebase hosting and functions configuration
- firestore.rules, firestore.indexes.json – Firestore security rules and indexes
- Frontend:
- public/ – static HTML, manifest, and error pages (served by Firebase Hosting)
- src/ – React application code
– src/App.js, src/index.js, src/firebase.js (initializes Firebase SDK), src/googleAuth.js (OAuth flows)
– src/Auth/ and src/unAuth/ – authenticated vs unauthenticated views
- Backend functions:
- function/ – Node.js Cloud Functions (index.js, testfile.js)
- python_functions/ – Python‐based functions, with main.py, requirements.txt, venv (likely for local dev or Cloud Functions for Firebase using Python)
- CI/CD hints: package.json, package-lock.json, GitHub references in README.

##### README for additional insights
- Expect integration with external AI services (Cursor AI, Claude AI) from within Cloud Functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Pipeline
    CI["CI/CD: package.json & package-lock.json"]:::ci
    FirebaseCLI["Firebase CLI"]:::ci
    CI -->|"deploys via"| FirebaseCLI
    FirebaseCLI -->|"to"| Hosting
    FirebaseCLI -->|"to"| FunctionsBackend

    %% Client and Hosting
    subgraph "Client Side"
        Browser["User Browser"]:::external
        Hosting["Firebase Hosting (public/)"]:::service
        Browser -->|"HTTPS Request"| Hosting
        Hosting -->|"serves SPA"| SPA
    end

    %% Frontend Application
    subgraph "React Frontend" 
        SPA["React SPA (src/)"]:::frontend
        Init["Firebase SDK Init"]:::frontend
        OAuth["Google OAuth Flows"]:::frontend
        AuthViews["Authenticated Views (src/Auth/)"]:::frontend
        UnAuthViews["Unauthenticated Views (src/unAuth/)"]:::frontend
        AuthCtx["AuthContext Provider"]:::frontend
        Assets["UI Assets & Icons"]:::frontend
        Entry["Entry Point & Bootstrapping"]:::frontend
        Testing["React Tests & Tooling"]:::frontend

        SPA --> Init
        SPA --> OAuth
        SPA --> AuthCtx
        Init --> AuthViews
        Init --> UnAuthViews
        SPA --> Assets
        SPA --> Entry
        SPA --> Testing
    end

    click SPA "https://github.com/coffeefuelbump/actual-backend-app/tree/main/src/"
    click Init "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/firebase.js"
    click OAuth "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/googleAuth.js"
    click AuthViews "https://github.com/coffeefuelbump/actual-backend-app/tree/main/src/Auth/"
    click UnAuthViews "https://github.com/coffeefuelbump/actual-backend-app/tree/main/src/unAuth/"
    click AuthCtx "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/AuthContext.js"
    click Assets "https://github.com/coffeefuelbump/actual-backend-app/tree/main/src/assets/"
    click Assets "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/icons.js"
    click Entry "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/index.js"
    click Entry "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/App.js"
    click Testing "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/App.test.js"
    click Testing "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/setupTests.js"
    click Testing "https://github.com/coffeefuelbump/actual-backend-app/blob/main/src/reportWebVitals.js"

    %% Backend Services
    subgraph "Firebase Managed Services"
        AuthService["Firebase Authentication"]:::service
        Firestore["Firestore Database"]:::service
        Security["Security Rules"]:::annotation
        Indexes["Indexes"]:::annotation
        AuthService <-->|"Auth SDK"| SPA
        SPA -->|"Firestore SDK"| Firestore
        Security -.-> Firestore
        Indexes -.-> Firestore
    end

    click Security "https://github.com/coffeefuelbump/actual-backend-app/blob/main/firestore.rules"
    click Indexes "https://github.com/coffeefuelbump/actual-backend-app/blob/main/firestore.indexes.json"

    %% Cloud Functions Backend
    subgraph "Cloud Functions Backend" 
        FunctionsBackend["Functions"]:::backend
        subgraph "Node.js Functions"
            NodeFunctions["Node.js Cloud Functions"]:::backend
            TF1["index.js"]:::backend
            TF2["testfile.js"]:::backend
            NodeDeps["package.json & lock"]:::backend
            NodeFunctions --> TF1
            NodeFunctions --> TF2
            NodeFunctions --> NodeDeps
        end
        subgraph "Python Functions"
            PyFunctions["Python Cloud Functions"]:::backend
            PyMain["main.py"]:::backend
            PyReq["requirements.txt"]:::backend
            PyFunctions --> PyMain
            PyFunctions --> PyReq
        end

        Firestore -->|"onCreate/onUpdate Trigger"| TF1
        TF1 -->|"writes to"| Firestore
        TF2 -->|"HTTP Trigger"| ExternalAI
        PyMain -->|"HTTP Trigger"| ExternalAI
    end

    click TF1 "https://github.com/coffeefuelbump/actual-backend-app/blob/main/function/index.js"
    click TF2 "https://github.com/coffeefuelbump/actual-backend-app/blob/main/function/testfile.js"
    click NodeDeps "https://github.com/coffeefuelbump/actual-backend-app/blob/main/function/package.json"
    click NodeDeps "https://github.com/coffeefuelbump/actual-backend-app/blob/main/function/package-lock.json"
    click PyMain "https://github.com/coffeefuelbump/actual-backend-app/blob/main/python_functions/main.py"
    click PyReq "https://github.com/coffeefuelbump/actual-backend-app/blob/main/python_functions/requirements.txt"

    %% External AI Services
    ExternalAI["External AI Services<br/>(Cursor AI, Claude AI)"]:::external
    ExternalAI -.->|"API Calls"| TF2
    ExternalAI -.->|"API Calls"| PyMain

    %% Deployment Services
    subgraph "Deployment Targets"
        Hosting
        FunctionsBackend
    end

    classDef frontend fill:#D0E8FF,stroke:#0969DA,stroke-width:1px
    classDef backend fill:#DFF8E0,stroke:#1A7F37,stroke-width:1px
    classDef service fill:#FFE8B0,stroke:#D29922,stroke-width:1px
    classDef external fill:#F2E7FE,stroke:#6A1B9A,stroke-width:1px,stroke-dasharray: 5 5
    classDef ci fill:#FFD6E7,stroke:#DB1F48,stroke-width:1px
    classDef annotation fill:none,stroke-dasharray: 2 2,stroke:#888,stroke-width:1px
```
