# nazmulhassan2024-png/cedarline-brain architecture

> Architecture diagram of the GitHub repository nazmulhassan2024-png/cedarline-brain, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nazmulhassan2024-png/cedarline-brain
- Repository: https://github.com/nazmulhassan2024-png/cedarline-brain

## Overview

Cedarline Company Brain is a small, access-controlled knowledge assistant. A user asks a question in the browser; the ask endpoint loads fresh group membership, then calls the engine, which filters documents before retrieval and ranks matches by relevance and trust status before returning cited results. Administrators manage memberships through a separate groups endpoint, with changes persisted in Netlify Blobs. The README also describes sign-in and a reviewer view, but the supplied tree and excerpts do not show their runtime implementation, so those are not mapped as separate components.

Main entry points: [`netlify/functions/ask.mjs`](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/functions/ask.mjs) (Ask endpoint), [`netlify/lib/data.mjs`](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/lib/data.mjs) (Users and document records), [`public/index.html`](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/public/index.html) (Chat and admin UI), [`netlify/functions/groups.mjs`](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/functions/groups.mjs) (Groups endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_browser["Chat and admin UI<br/>[index.html]"]
  node_ask["Ask endpoint<br/>[ask.mjs]"]
  node_groups_api["Groups endpoint<br/>[groups.mjs]"]
end

subgraph group_knowledge["Knowledge answering"]
  node_engine["Filter and answer engine<br/>[engine.mjs]"]
  node_user_docs["Users and document records<br/>[data.mjs]"]
  node_source_docs["Source documents"]
end

subgraph group_access["Access management"]
  node_group_state["Group membership state<br/>[state.mjs]"]
  node_blob_store[("Netlify Blobs")]
end

node_user(("Company user"))

node_user -->|"asks or manages"| node_browser
node_browser -->|"sends question"| node_ask
node_ask -->|"loads fresh groups"| node_group_state
node_ask -->|"calls answer"| node_engine
node_ask -->|"looks up user"| node_user_docs
node_engine -->|"filters and searches"| node_user_docs
node_source_docs -.->|"represented in records"| node_user_docs
node_browser -->|"requests group changes"| node_groups_api
node_groups_api -->|"looks up users"| node_user_docs
node_groups_api -->|"reads and saves groups"| node_group_state
node_group_state -->|"reads and writes"| node_blob_store

click node_browser "https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/public/index.html"
click node_ask "https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/functions/ask.mjs"
click node_groups_api "https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/functions/groups.mjs"
click node_engine "https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/lib/engine.mjs"
click node_user_docs "https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/lib/data.mjs"
click node_source_docs "https://github.com/nazmulhassan2024-png/cedarline-brain/tree/main/data/documents"
click node_group_state "https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/lib/state.mjs"

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_browser,node_ask,node_groups_api,node_user toneBlue
class node_engine,node_user_docs,node_source_docs toneAmber
class node_group_state,node_blob_store toneMint
```

## Components

### User interaction

- [Chat and admin UI](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/public/index.html): `public/index.html`
- [Ask endpoint](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/functions/ask.mjs): `netlify/functions/ask.mjs`
- [Groups endpoint](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/functions/groups.mjs): `netlify/functions/groups.mjs`

### Knowledge answering

- [Filter and answer engine](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/lib/engine.mjs): `netlify/lib/engine.mjs`
- [Users and document records](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/lib/data.mjs): `netlify/lib/data.mjs`
- [Source documents](https://github.com/nazmulhassan2024-png/cedarline-brain/tree/main/data/documents): `data/documents`

### Access management

- [Group membership state](https://github.com/nazmulhassan2024-png/cedarline-brain/blob/main/netlify/lib/state.mjs): `netlify/lib/state.mjs`
- **Netlify Blobs**

### Other components

- **Company user**

## Connections

- Company user → Chat and admin UI: asks or manages (evidence: `README.md`)
- Chat and admin UI → Ask endpoint: sends question (evidence: `README.md`)
- Ask endpoint → Group membership state: loads fresh groups (evidence: `netlify/functions/ask.mjs`)
- Ask endpoint → Filter and answer engine: calls answer (evidence: `netlify/functions/ask.mjs`)
- Ask endpoint → Users and document records: looks up user (evidence: `netlify/functions/ask.mjs`)
- Filter and answer engine → Users and document records: filters and searches (evidence: `netlify/lib/engine.mjs`)
- Source documents → Users and document records: represented in records (evidence: `README.md`)
- Chat and admin UI → Groups endpoint: requests group changes (evidence: `README.md`)
- Groups endpoint → Users and document records: looks up users (evidence: `netlify/functions/groups.mjs`)
- Groups endpoint → Group membership state: reads and saves groups (evidence: `netlify/functions/groups.mjs`)
- Group membership state → Netlify Blobs: reads and writes (evidence: `netlify/lib/state.mjs`)
