# forkzen/crisisboard architecture

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

- Interactive diagram: https://gitdiagram.com/forkzen/crisisboard
- Repository: https://github.com/forkzen/crisisboard

## Overview

##### Project type and purpose
- From the README and file tree, this is a **full-stack, serverless web application** called “CrisisBoard.”
- Purpose: let college students submit anonymous (or identified) complaints, auto-categorize them via AI, email them to the correct department, and store them in a safe database.

##### File structure
- Top-level files:
- `.firebaserc`, `firebase.json` → Firebase Hosting & configuration
- `index.html` (root) + `public/` → static front-end assets (React bundle, Firebase config)
- `build/` → packaged artifacts (e.g., JAR) – possibly legacy or CI output
- `.idx/dev.nix`, `.vscode/` → development environment setups
- No explicit `functions/` folder present, but README indicates Firebase Cloud Functions handle backend logic.

##### README for additional insights
- Backend tech: Firebase Authentication, Firestore (NoSQL DB), Cloud Functions (business logic), Gemini API (AI categorizer), SendGrid/Nodemailer (email delivery)

- Client (Web Browser)
- Firebase Hosting (serves `index.html` + `public/app.js`)
- React SPA (UI layer)
- Firebase Authentication (login gate)
- Firestore Database (complaint storage)
- Firebase Cloud Functions (serverless business logic)
- Google Gemini API (AI categorization)
- Email Service (SendGrid or SMTP via Nodemailer)
1. User → Firebase Hosting → React SPA
2. React SPA ↔ Firebase Auth (login session)
3. On complaint submit:
- React SPA → Cloud Function (invoke via HTTPS or callable)
- Cloud Function → Gemini API (get category)
- Cloud Function → Firestore (save complaint + metadata)
- Cloud Function → Email Service (send to appropriate department)
4. React SPA → Firestore (read list of past complaints)
5. React SPA → Cloud Function (delete complaint)
c. Architectural patterns & principles:
- Serverless/event-driven (Cloud Functions trigger on HTTPS calls or DB writes)
- SPA on the client, thin backend layer
- Externalization of AI logic (Gemini API)
- Secure, role-based access via Firebase Auth
d. Key technologies to annotate:
- React (browser)
- Tailwind CSS & Framer Motion (UI styling & animation)
- Firebase Hosting, Auth, Firestore, Functions
- Google Gemini API
- SendGrid/Nodemailer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend"
        direction TB
        Browser["Web Browser"]:::client
        FirebaseHosting["Firebase Hosting"]:::hosting
        RootIndex["index.html"]:::frontend
        PublicIndex["public/index.html"]:::frontend
        AppJS["public/app.js"]:::frontend
        FirebaseConfigJS["public/firebase-config.js"]:::frontend
        subgraph "Firebase Hosting & Config"
            direction TB
            HostingConfig1["firebase.json"]:::config
            HostingConfig2[".firebaserc"]:::config
        end
    end

    %% Backend Layer
    subgraph "Backend (Firebase)"
        direction TB
        FirebaseAuth["Firebase Authentication"]:::auth
        CloudFunctions["Cloud Functions"]:::compute
        Firestore["Firestore Database"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        GeminiAPI["Google Gemini API"]:::external
        EmailService["SendGrid / SMTP (Nodemailer)"]:::external
    end

    %% Development Environment
    subgraph "Development Environment"
        direction TB
        DevNix[".idx/dev.nix"]:::dev
        VSCodeDir[".vscode/"]:::dev
    end

    %% Build Artifacts
    subgraph "Build Artifacts / Legacy Output"
        direction TB
        BuildDir["build/"]:::build
        JarFile["build/libs/project.jar"]:::build
    end

    %% Connections
    Browser --> FirebaseHosting
    FirebaseHosting --> RootIndex
    FirebaseHosting --> PublicIndex
    PublicIndex --> AppJS
    AppJS <--> FirebaseAuth
    AppJS --> CloudFunctions
    AppJS --> Firestore
    CloudFunctions --> GeminiAPI
    CloudFunctions --> Firestore
    CloudFunctions --> EmailService
    Firestore --> AppJS

    %% Click Events
    click RootIndex "https://github.com/forkzen/crisisboard/blob/main/index.html"
    click PublicIndex "https://github.com/forkzen/crisisboard/blob/main/public/index.html"
    click AppJS "https://github.com/forkzen/crisisboard/blob/main/public/app.js"
    click FirebaseConfigJS "https://github.com/forkzen/crisisboard/blob/main/public/firebase-config.js"
    click HostingConfig1 "https://github.com/forkzen/crisisboard/blob/main/firebase.json"
    click HostingConfig2 "https://github.com/forkzen/crisisboard/blob/main/.firebaserc"
    click BuildDir "https://github.com/forkzen/crisisboard/tree/main/build/"
    click JarFile "https://github.com/forkzen/crisisboard/blob/main/build/libs/project.jar"
    click DevNix "https://github.com/forkzen/crisisboard/blob/main/.idx/dev.nix"
    click VSCodeDir "https://github.com/forkzen/crisisboard/tree/main/.vscode/"

    %% Styles
    classDef client fill:#ccffcc,stroke:#006600,stroke-width:2px
    classDef hosting fill:#cce5ff,stroke:#004080,stroke-width:2px
    classDef frontend fill:#e6f7ff,stroke:#0059b3,stroke-width:1px
    classDef auth fill:#fff2cc,stroke:#b37700,stroke-width:2px
    classDef compute fill:#ffffcc,stroke:#999900,stroke-width:2px
    classDef db fill:#ffe6cc,stroke:#cc5200,stroke-width:2px
    classDef external fill:#f2f2f2,stroke:#666666,stroke-width:2px,stroke-dasharray: 5 5
    classDef config fill:#e0e0e0,stroke:#808080,stroke-width:1px
    classDef dev fill:#ffe6f2,stroke:#b3005c,stroke-width:1px
    classDef build fill:#f9e6ff,stroke:#800080,stroke-width:1px
```
