# montmor/letmeask architecture

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

- Interactive diagram: https://gitdiagram.com/montmor/letmeask
- Repository: https://github.com/montmor/letmeask

## Overview

##### Overall Project Type and Purpose
- This is a full-stack (client-side heavy) application built in ReactJS with TypeScript. It enables users to create “rooms”, ask questions in live sessions, upvote (or “like”) questions, and view prioritized questions. It also has an administrative area for handling room management and moderating questions.
- Firebase plays a major role in backend services including authentication, database (Realtime Database or Firestore as inferred from the rules and firebase.json), and hosting.

##### File Structure
- Top-level folders include:
- /public: Contains static assets such as HTML, manifest, and robots.txt. This is the public entry point for the app.
- /src: Contains all the React application source code. Inside /src, dedicated subdirectories include:
▸ /components: For reusable UI elements (e.g., Button, Question, RoomCode).
▸ /pages: For application views (AdminRoom, Home, NewRoom, Room) aligning with routing.
▸ /contexts: To setup React Contexts (AuthContext) for state management – likely used for user authentication.
▸ /hooks: Custom hooks (useAuth, useRoom) managing specialized logic.
▸ /services/firebase: Wraps Firebase logic/initialization, likely handling communication with Firebase’s APIs.
▸ /styles and other configuration files (e.g., tsconfig.json) along with testing files.
- There are also CI/CD and hosting setups provided in:
- .github/workflows: For GitHub actions that deploy to Firebase hosting.
- Firebase configuration files (.firebaserc, firebase.json, database.rules.json), pointing to a backend based on Firebase.

##### Important Architectural Components
a. Frontend Application:
- The React UI with TypeScript, split into Views (pages) and Reusable Components.
- The use of contexts (AuthContext) and hooks (useAuth, useRoom) to manage application state, authentication, and live room data.
b. Firebase Backend:
- Firebase is used for authentication, real-time database operations, and hosting.
- Security rules in database.rules.json and configuration in firebase.json indicate that database security and hosting settings are managed on Firebase.
c. CI/CD Pipeline:
- GitHub workflows are set up to automate deployment to Firebase.
d. Static Assets:
- The public folder provides the entry HTML and manifests, supporting progressive web app features.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI/Client Layer
    subgraph "UI/Client Layer"
        ReactIndex["React Index"]:::frontend
        ReactApp["React App"]:::frontend
        subgraph "React Pages"
            HomePage["Home Page"]:::frontend
            RoomPage["Room Page"]:::frontend
            NewRoomPage["New Room Page"]:::frontend
            AdminRoomPage["Admin Room Page"]:::frontend
        end
        subgraph "UI Components"
            Button["Button"]:::frontend
            Question["Question"]:::frontend
            RoomCode["Room Code"]:::frontend
        end
    end

    %% Business Logic & State Management
    subgraph "Business Logic & State Management"
        AuthContext["Auth Context"]:::logic
        useAuth["useAuth Hook"]:::logic
        useRoom["useRoom Hook"]:::logic
    end

    %% Data Layer & Backend
    subgraph "Data Layer & Backend"
        FirebaseServices["Firebase Services"]:::backend
        subgraph "Firebase Config"
            FirebaseJSON["firebase.json"]:::backend
            DatabaseRules["database.rules.json"]:::backend
            Firebaserc[".firebaserc"]:::backend
        end
    end

    %% Deployment & CI/CD
    subgraph "Deployment & CI/CD"
        GitHubActions["GitHub Actions"]:::deployment
        MergeWorkflow["Merge Workflow"]:::deployment
        PRWorkflow["Pull Request Workflow"]:::deployment
    end

    %% Static Assets
    subgraph "Static Assets"
        PublicAssets["Public Assets"]:::assets
        IndexHTML["index.html"]:::assets
        Manifest["manifest.json"]:::assets
        Robots["robots.txt"]:::assets
    end

    %% Relationships
    PublicAssets -- "serves" --> ReactApp
    ReactIndex -- "bootstraps" --> ReactApp
    ReactApp -- "routes" --> HomePage
    ReactApp -- "routes" --> RoomPage
    ReactApp -- "routes" --> NewRoomPage
    ReactApp -- "routes" --> AdminRoomPage

    ReactApp -- "uses" --> AuthContext
    ReactApp -- "uses" --> useAuth
    ReactApp -- "uses" --> useRoom

    AuthContext -- "authenticates" --> FirebaseServices
    useAuth -- "calls" --> FirebaseServices
    useRoom -- "retrieves" --> FirebaseServices

    AdminRoomPage -- "manages" --> FirebaseServices

    HomePage -- "renders" --> Button
    HomePage -- "renders" --> Question
    HomePage -- "renders" --> RoomCode

    GitHubActions -- "deploys" --> FirebaseServices
    GitHubActions -- "includes" --> MergeWorkflow
    GitHubActions -- "includes" --> PRWorkflow

    %% Click Events for Frontend Client
    click ReactApp "https://github.com/montmor/letmeask/blob/master/src/App.tsx"
    click ReactIndex "https://github.com/montmor/letmeask/blob/master/src/index.tsx"

    %% Click Events for UI Components
    click Button "https://github.com/montmor/letmeask/tree/master/src/components/Button"
    click Question "https://github.com/montmor/letmeask/tree/master/src/components/Question"
    click RoomCode "https://github.com/montmor/letmeask/tree/master/src/components/RoomCode"

    %% Click Events for React Pages
    click HomePage "https://github.com/montmor/letmeask/tree/master/src/pages/Home"
    click RoomPage "https://github.com/montmor/letmeask/tree/master/src/pages/Room"
    click NewRoomPage "https://github.com/montmor/letmeask/tree/master/src/pages/NewRoom"
    click AdminRoomPage "https://github.com/montmor/letmeask/tree/master/src/pages/AdminRoom"

    %% Click Events for Business Logic & State Management
    click AuthContext "https://github.com/montmor/letmeask/blob/master/src/contexts/Auth/AuthContext.tsx"
    click useAuth "https://github.com/montmor/letmeask/blob/master/src/hooks/useAuth.ts"
    click useRoom "https://github.com/montmor/letmeask/blob/master/src/hooks/useRoom.ts"

    %% Click Events for Firebase Services
    click FirebaseServices "https://github.com/montmor/letmeask/blob/master/src/services/firebase/index.ts"
    click FirebaseJSON "https://github.com/montmor/letmeask/blob/master/firebase.json"
    click DatabaseRules "https://github.com/montmor/letmeask/blob/master/database.rules.json"
    click Firebaserc "https://github.com/montmor/letmeask/blob/master/.firebaserc"

    %% Click Events for CI/CD Pipeline
    click MergeWorkflow "https://github.com/montmor/letmeask/blob/master/.github/workflows/firebase-hosting-merge.yml"
    click PRWorkflow "https://github.com/montmor/letmeask/blob/master/.github/workflows/firebase-hosting-pull-request.yml"

    %% Click Events for Static Assets
    click PublicAssets "https://github.com/montmor/letmeask/tree/master/public"
    click IndexHTML "https://github.com/montmor/letmeask/blob/master/public/index.html"
    click Manifest "https://github.com/montmor/letmeask/blob/master/public/manifest.json"
    click Robots "https://github.com/montmor/letmeask/blob/master/public/robots.txt"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef logic fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef deployment fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef assets fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
