# promptslab/promptchat architecture

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

- Interactive diagram: https://gitdiagram.com/promptslab/promptchat
- Repository: https://github.com/promptslab/promptchat

## Overview

##### Project type and purpose
- From the README and file tree, PromptChat is a single‐page React/TypeScript application (with a webpack build) that delivers “uninterrupted access to ChatGPT.”
- There is no proprietary backend directory; instead the app lives entirely in `src/` and `public/`, and calls out to an external ChatGPT/OpenAI API.
- The presence of `webpack.extension.js` suggests it can also be packaged as a browser extension, but its core is a frontend SPA.

##### File structure
- Top‐level files
- .babelrc, tsconfig.json, package.json, webpack.config.js → build and transpile configuration
- config/ (paths, presets, dev/prod/extension webpack configs) → controls how code is bundled for different targets
- public/ (static HTML, images, styles) → assets served directly
- src/
- App.tsx, index.tsx → entry points for the React application
- pages/ (GptChatBot.tsx + SCSS) → primary UI views
- utilities/ (Api.tsx, common.service.tsx, dialog.service.tsx, etc.) → abstractions for making HTTP calls, showing alerts/dialogs, formatting data

##### README for additional insights
- The README emphasizes uptime and unlimited requests but relies on external ChatGPT endpoints.

##### Diagramming recommendations
- Rectangles for system components (Developer Machine, CI Server, Hosting, Browser)
- Code push → Build → Deploy → Fetch → API call → UI update
- Critical technologies next to each component.
- Related items in clouds or containers (e.g., “Frontend Build” cluster containing Babel, TS compiler, webpack).

##### Detailed capture of essential elements
- You do not omit the webpack presets folder and its role in producing different bundles.
- SCSS partials feeding into the final `theme.scss` and ultimately into the styles shipped with the app.
- `utilities/Api.tsx` as the single source of truth for all HTTP interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Developer Workstation"
    BABEL[".babelrc"]:::dev
    TSCONFIG["tsconfig.json"]:::dev
    PKG["package.json"]:::dev
    WEBPACKCFG["webpack.config.js"]:::dev
  end

  subgraph "CI / Build Pipeline"
    subgraph "config"
      DEV1["webpack.development.js"]:::pipeline
      PROD1["webpack.production.js"]:::pipeline
      EXT1["webpack.extension.js"]:::pipeline
      PATHS["paths.js"]:::pipeline
      subgraph "presets"
        ANLZ["webpack.analyze.js"]:::pipeline
        LOADP["loadPreset.js"]:::pipeline
      end
    end
    PRESets["Webpack Presets"]:::pipeline
  end

  subgraph "Hosting / CDN"
    HTML["index.html"]:::hosting
    IMAGES["images/"]:::hosting
    FONTS["_fonts.scss"]:::hosting
    VARS["_variables.scss"]:::hosting
    THEME["theme.scss"]:::hosting
  end

  subgraph "Client Browser Runtime"
    IDX["src/index.tsx"]:::frontend
    APP["src/App.tsx"]:::frontend
    APPSC["src/App.scss"]:::frontend
    FOOT["src/Footer.tsx"]:::frontend
    subgraph "Pages"
      GPT["src/pages/GptChatBot.tsx"]:::frontend
      GPTSC["src/pages/GptChatBot.scss"]:::frontend
    end
    subgraph "Utilities"
      API["src/utilities/Api.tsx"]:::util
      COMMON["src/utilities/common.service.tsx"]:::util
      DIALOG["src/utilities/dialog.service.tsx"]:::util
      ALERT["src/utilities/alert.tsx"]:::util
      COPY["src/utilities/CopyContent.tsx"]:::util
      CONST["src/utilities/Constant.tsx"]:::util
      FMT["src/utilities/formatCurrency.ts"]:::util
    end
  end

  CHATAPI[(ChatGPT / OpenAI API)]:::external
  EXT_BROWSER["Browser Extension Runtime"]:::frontend

  BABEL -->|push code| PRESets
  TSCONFIG -->|push code| PRESets
  PKG -->|push code| PRESets
  WEBPACKCFG -->|push code| PRESets

  DEV1 --> PRESets
  PROD1 --> PRESets
  EXT1 --> PRESets
  ANLZ --> PRESets
  LOADP --> PRESets
  PATHS --> PRESets

  PRESets --> HTML
  PRESets --> IMAGES
  PRESets --> FONTS
  PRESets --> VARS
  PRESets --> THEME

  HTML --> IDX
  IMAGES --> IDX
  THEME --> APPSC

  IDX --> APP
  APP --> GPT
  GPT --> API
  API --> CHATAPI
  CHATAPI --> API
  API --> DIALOG
  DIALOG --> APP

  EXT1 --> EXT_BROWSER

  classDef dev fill:#f9f,stroke:#333,stroke-width:1px
  classDef pipeline fill:#ff9,stroke:#333,stroke-width:1px
  classDef hosting fill:#9f9,stroke:#333,stroke-width:1px
  classDef frontend fill:#9cf,stroke:#333,stroke-width:1px
  classDef util fill:#fcc,stroke:#333,stroke-width:1px
  classDef external fill:#ccc,stroke:#333,stroke-width:1px

  click BABEL "https://github.com/promptslab/promptchat/blob/main/.babelrc"
  click TSCONFIG "https://github.com/promptslab/promptchat/blob/main/tsconfig.json"
  click PKG "https://github.com/promptslab/promptchat/blob/main/package.json"
  click WEBPACKCFG "https://github.com/promptslab/promptchat/blob/main/webpack.config.js"
  click DEV1 "https://github.com/promptslab/promptchat/blob/main/config/webpack.development.js"
  click PROD1 "https://github.com/promptslab/promptchat/blob/main/config/webpack.production.js"
  click EXT1 "https://github.com/promptslab/promptchat/blob/main/config/webpack.extension.js"
  click ANLZ "https://github.com/promptslab/promptchat/blob/main/config/presets/webpack.analyze.js"
  click LOADP "https://github.com/promptslab/promptchat/blob/main/config/presets/loadPreset.js"
  click PATHS "https://github.com/promptslab/promptchat/blob/main/config/paths.js"
  click HTML "https://github.com/promptslab/promptchat/blob/main/public/index.html"
  click IMAGES "https://github.com/promptslab/promptchat/tree/main/public/images/"
  click FONTS "https://github.com/promptslab/promptchat/blob/main/public/styles/_fonts.scss"
  click VARS "https://github.com/promptslab/promptchat/blob/main/public/styles/_variables.scss"
  click THEME "https://github.com/promptslab/promptchat/blob/main/public/styles/theme.scss"
  click IDX "https://github.com/promptslab/promptchat/blob/main/src/index.tsx"
  click APP "https://github.com/promptslab/promptchat/blob/main/src/App.tsx"
  click APPSC "https://github.com/promptslab/promptchat/blob/main/src/App.scss"
  click FOOT "https://github.com/promptslab/promptchat/blob/main/src/Footer.tsx"
  click GPT "https://github.com/promptslab/promptchat/blob/main/src/pages/GptChatBot.tsx"
  click GPTSC "https://github.com/promptslab/promptchat/blob/main/src/pages/GptChatBot.scss"
  click API "https://github.com/promptslab/promptchat/blob/main/src/utilities/Api.tsx"
  click COMMON "https://github.com/promptslab/promptchat/blob/main/src/utilities/common.service.tsx"
  click DIALOG "https://github.com/promptslab/promptchat/blob/main/src/utilities/dialog.service.tsx"
  click ALERT "https://github.com/promptslab/promptchat/blob/main/src/utilities/alert.tsx"
  click COPY "https://github.com/promptslab/promptchat/blob/main/src/utilities/CopyContent.tsx"
  click CONST "https://github.com/promptslab/promptchat/blob/main/src/utilities/Constant.tsx"
  click FMT "https://github.com/promptslab/promptchat/blob/main/src/utilities/formatCurrency.ts"
```
