# b-harisanker/app_proj architecture

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

- Interactive diagram: https://gitdiagram.com/b-harisanker/app_proj
- Repository: https://github.com/b-harisanker/app_proj

## Overview

#### Purpose and Entry Points
This is a small Node.js application for AI-assisted image/signal analysis, with browser-facing pages and Gemini-oriented integration modules. The runtime entry point is `server.js`; primary UI entry points are `public/index.html` and `public/image-detector.html`.

#### HTTP Application Boundary
`server.js` is the backend boundary between browser clients, local application logic, and any external AI service calls. It likely serves the static `public/` assets and exposes server-side operations needed to keep AI credentials or API interactions out of the browser.

#### Browser Workflows
The repository contains two distinct browser surfaces:
- `public/index.html`: main application interface.
- `public/image-detector.html`: specialized image-detection/upload workflow.

These pages are the user-input boundary and should pass requests to the backend rather than directly owning model-service credentials.

#### Gemini / Vision Integration
AI-provider-specific behavior is separated into:
- `Gemini.js`
- `gemini-vision.js`

`Gemini.js` likely handles general Gemini prompting or text/signal interpretation, while `gemini-vision.js` specializes requests involving image content. This separation is an important provider-adapter boundary: UI and server orchestration should depend on these modules rather than embed provider request formats.

#### Signal Classification and Heuristics
`Heuristics.js` represents deterministic, local decision logic that can complement or constrain model output. It is the likely place for rules, thresholds, scoring, or post-processing used to turn raw AI responses and supplied signals into application-level results.

#### Local Data Layer
`data/ai_signals.json` is the repository’s embedded signal dataset. It likely supplies known indicators, labels, examples, or reference metadata to heuristic and/or model-driven analysis. This is a local-data boundary: consumers should treat it as source data rather than hard-code its contents into UI or AI adapters.

#### Primary Flow
The expected control flow is:
1. A user interacts with `public/index.html` or uploads/selects imagery through `public/image-detector.html`.
2. `server.js` receives and validates the request.
3. The server routes text/signal analysis through `Gemini.js`, image analysis through `gemini-vision.js`, and applies local interpretation via `Heuristics.js`.
4. Analysis may reference `data/ai_signals.json`.
5. The server returns a normalized result for browser rendering.

#### Runtime and External Dependencies
The project is JavaScript/Node-based, defined by `package.json` and pinned through `package-lock.json`. Its material external dependency is the Gemini AI ecosystem implied by `Gemini.js` and `gemini-vision.js`; provider access, authentication, request limits, and response failures should remain isolated behind those modules and orchestrated by `server.js`.

Main entry points: [`server.js`](https://github.com/b-harisanker/app_proj/blob/main/server.js) (HTTP server), [`public/index.html`](https://github.com/b-harisanker/app_proj/blob/main/public/index.html) (Main interface), [`public/image-detector.html`](https://github.com/b-harisanker/app_proj/blob/main/public/image-detector.html) (Image detector), [`Heuristics.js`](https://github.com/b-harisanker/app_proj/blob/main/Heuristics.js) (Signal heuristics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser UI"]
  node_main_ui["Main interface<br/>HTML page<br/>[index.html]"]
  node_image_ui["Image detector<br/>HTML page"]
end

subgraph group_backend["Node Backend"]
  node_server["HTTP server<br/>Node entry point<br/>[server.js]"]
  node_heuristics["Signal heuristics<br/>Local rules<br/>[Heuristics.js]"]
  node_signals_data[("AI signals dataset<br/>JSON data<br/>[ai_signals.json]")]
end

subgraph group_ai["AI Integration"]
  node_gemini["Gemini adapter<br/>Provider adapter<br/>[Gemini.js]"]
  node_vision["Gemini Vision adapter<br/>Provider adapter<br/>[gemini-vision.js]"]
  node_gemini_api{{"Gemini AI service<br/>External AI API"}}
end

node_package["Node dependencies<br/>Package manifest<br/>[package.json]"]
node_lockfile["Locked dependencies<br/>Lockfile<br/>[package-lock.json]"]

node_main_ui -->|"analysis request"| node_server
node_image_ui -->|"image request"| node_server
node_server -->|"normalized result"| node_main_ui
node_server -->|"normalized result"| node_image_ui
node_server -->|"text/signal analysis"| node_gemini
node_server -->|"image analysis"| node_vision
node_server -->|"local interpretation"| node_heuristics
node_heuristics -->|"reference signals"| node_signals_data
node_gemini -->|"provider request"| node_gemini_api
node_vision -->|"vision request"| node_gemini_api
node_package -.->|"runtime definition"| node_server
node_lockfile -.->|"pins dependencies"| node_package

click node_main_ui "https://github.com/b-harisanker/app_proj/blob/main/public/index.html"
click node_image_ui "https://github.com/b-harisanker/app_proj/blob/main/public/image-detector.html"
click node_server "https://github.com/b-harisanker/app_proj/blob/main/server.js"
click node_heuristics "https://github.com/b-harisanker/app_proj/blob/main/Heuristics.js"
click node_signals_data "https://github.com/b-harisanker/app_proj/blob/main/data/ai_signals.json"
click node_gemini "https://github.com/b-harisanker/app_proj/blob/main/Gemini.js"
click node_vision "https://github.com/b-harisanker/app_proj/blob/main/gemini-vision.js"
click node_package "https://github.com/b-harisanker/app_proj/blob/main/package.json"
click node_lockfile "https://github.com/b-harisanker/app_proj/blob/main/package-lock.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_ui,node_image_ui toneBlue
class node_server,node_heuristics,node_signals_data toneAmber
class node_gemini,node_vision,node_gemini_api toneMint
class node_package,node_lockfile toneNeutral
```

## Components

### Browser UI

- [Main interface](https://github.com/b-harisanker/app_proj/blob/main/public/index.html): HTML page · `public/index.html`
- [Image detector](https://github.com/b-harisanker/app_proj/blob/main/public/image-detector.html): HTML page · Image upload and detection workflow. · `public/image-detector.html`

### Node Backend

- [HTTP server](https://github.com/b-harisanker/app_proj/blob/main/server.js): Node entry point · Serves browser assets and orchestrates analysis. · `server.js`
- [Signal heuristics](https://github.com/b-harisanker/app_proj/blob/main/Heuristics.js): Local rules · Converts analysis inputs and outputs into application results. · `Heuristics.js`
- [AI signals dataset](https://github.com/b-harisanker/app_proj/blob/main/data/ai_signals.json): JSON data · Embedded signal indicators and reference metadata. · `data/ai_signals.json`

### AI Integration

- [Gemini adapter](https://github.com/b-harisanker/app_proj/blob/main/Gemini.js): Provider adapter · General text and signal interpretation integration. · `Gemini.js`
- [Gemini Vision adapter](https://github.com/b-harisanker/app_proj/blob/main/gemini-vision.js): Provider adapter · Image-content analysis integration. · `gemini-vision.js`
- **Gemini AI service**: External AI API

### Other components

- [Node dependencies](https://github.com/b-harisanker/app_proj/blob/main/package.json): Package manifest · `package.json`
- [Locked dependencies](https://github.com/b-harisanker/app_proj/blob/main/package-lock.json): Lockfile · `package-lock.json`

## Connections

- Main interface → HTTP server: analysis request
- Image detector → HTTP server: image request
- HTTP server → Main interface: normalized result
- HTTP server → Image detector: normalized result
- HTTP server → Gemini adapter: text/signal analysis
- HTTP server → Gemini Vision adapter: image analysis
- HTTP server → Signal heuristics: local interpretation
- Signal heuristics → AI signals dataset: reference signals
- Gemini adapter → Gemini AI service: provider request
- Gemini Vision adapter → Gemini AI service: vision request
- Node dependencies → HTTP server: runtime definition
- Locked dependencies → Node dependencies: pins dependencies
