# cranish07/lad architecture

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

- Interactive diagram: https://gitdiagram.com/cranish07/lad
- Repository: https://github.com/cranish07/lad

## Overview

LAD collects live logs, buffers them through Fluentd, then tails the buffer and uses vector similarity plus a retrieval-augmented prompt to assess each line. It also supports ingesting sample logs into a searchable collection. The graph includes the documented daemon role and major runtime stages; daemon internals and the RAG-chain implementation were not sampled, so their detailed links are omitted or marked unverified.

Main entry points: [`scripts/main.py`](https://github.com/cranish07/lad/blob/main/scripts/main.py) (Live Log Reader), [`scripts/log_ingestion.py`](https://github.com/cranish07/lad/blob/main/scripts/log_ingestion.py) (Log Ingestion), [`scripts/client.py`](https://github.com/cranish07/lad/blob/main/scripts/client.py) (Qdrant Setup), [`scripts/vectorstore.py`](https://github.com/cranish07/lad/blob/main/scripts/vectorstore.py) (Vector Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Log Collection"]
  node_fluentd["Fluentd Collector<br/>[fluent.conf]"]
  node_buffer[("Fluentd Buffer")]
  node_daemon["Log Daemon<br/>[daemon.py]"]
end

subgraph group_analysis["Anomaly Analysis"]
  node_live_reader["Live Log Reader<br/>[main.py]"]
  node_retrieval["Similarity Retrieval<br/>[main.py]"]
  node_context["Context Builder<br/>[text_utils.py]"]
  node_rag["RAG Classifier<br/>[rag_chain.py]"]
end

subgraph group_storage["Embedding and Storage"]
  node_client["Qdrant Setup<br/>[client.py]"]
  node_vectorstore["Vector Store<br/>[vectorstore.py]"]
  node_qdrant[("Qdrant")]
end

subgraph group_ingestion["Historical Ingestion"]
  node_sample_logs["Sample Logs"]
  node_ingestor["Log Ingestion<br/>[log_ingestion.py]"]
  node_chunker["Text Chunker<br/>[text_utils.py]"]
end

node_sources(("Log Sources"))
node_gemini{{"Google Gemini"}}

node_sources -->|"collects"| node_fluentd
node_fluentd -->|"buffers"| node_buffer
node_daemon -.->|"tails or forwards"| node_buffer
node_buffer -->|"reads"| node_live_reader
node_live_reader -->|"initializes"| node_client
node_live_reader -->|"searches"| node_vectorstore
node_live_reader -->|"formats results"| node_context
node_live_reader -->|"invokes"| node_rag
node_client -->|"connects and creates collection"| node_qdrant
node_vectorstore -->|"queries collection"| node_qdrant
node_client -->|"embeds test query"| node_gemini
node_vectorstore -->|"embeds text"| node_gemini
node_sample_logs -->|"reads"| node_ingestor
node_ingestor -->|"initializes collection"| node_client
node_ingestor -->|"chunks logs"| node_chunker
node_ingestor -->|"stores chunks"| node_vectorstore

click node_fluentd "https://github.com/cranish07/lad/blob/main/daemon/fluent.conf"
click node_buffer "https://github.com/cranish07/lad/tree/main/daemon/logs"
click node_daemon "https://github.com/cranish07/lad/blob/main/daemon/daemon.py"
click node_live_reader "https://github.com/cranish07/lad/blob/main/scripts/main.py"
click node_retrieval "https://github.com/cranish07/lad/blob/main/scripts/main.py"
click node_context "https://github.com/cranish07/lad/blob/main/scripts/text_utils.py"
click node_rag "https://github.com/cranish07/lad/blob/main/scripts/rag_chain.py"
click node_client "https://github.com/cranish07/lad/blob/main/scripts/client.py"
click node_vectorstore "https://github.com/cranish07/lad/blob/main/scripts/vectorstore.py"
click node_sample_logs "https://github.com/cranish07/lad/tree/main/data/sample_logs"
click node_ingestor "https://github.com/cranish07/lad/blob/main/scripts/log_ingestion.py"
click node_chunker "https://github.com/cranish07/lad/blob/main/scripts/text_utils.py"

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_fluentd,node_buffer,node_daemon toneBlue
class node_live_reader,node_retrieval,node_context,node_rag toneAmber
class node_client,node_vectorstore,node_qdrant toneMint
class node_sample_logs,node_ingestor,node_chunker toneRose
class node_sources,node_gemini toneIndigo
```

## Components

### Log Collection

- [Fluentd Collector](https://github.com/cranish07/lad/blob/main/daemon/fluent.conf): `daemon/fluent.conf`
- [Fluentd Buffer](https://github.com/cranish07/lad/tree/main/daemon/logs): `daemon/logs`
- [Log Daemon](https://github.com/cranish07/lad/blob/main/daemon/daemon.py): `daemon/daemon.py`

### Anomaly Analysis

- [Live Log Reader](https://github.com/cranish07/lad/blob/main/scripts/main.py): `scripts/main.py`
- [Similarity Retrieval](https://github.com/cranish07/lad/blob/main/scripts/main.py): `scripts/main.py`
- [Context Builder](https://github.com/cranish07/lad/blob/main/scripts/text_utils.py): `scripts/text_utils.py`
- [RAG Classifier](https://github.com/cranish07/lad/blob/main/scripts/rag_chain.py): `scripts/rag_chain.py`

### Embedding and Storage

- [Qdrant Setup](https://github.com/cranish07/lad/blob/main/scripts/client.py): `scripts/client.py`
- [Vector Store](https://github.com/cranish07/lad/blob/main/scripts/vectorstore.py): `scripts/vectorstore.py`
- **Qdrant**

### Historical Ingestion

- [Sample Logs](https://github.com/cranish07/lad/tree/main/data/sample_logs): `data/sample_logs`
- [Log Ingestion](https://github.com/cranish07/lad/blob/main/scripts/log_ingestion.py): `scripts/log_ingestion.py`
- [Text Chunker](https://github.com/cranish07/lad/blob/main/scripts/text_utils.py): `scripts/text_utils.py`

### Other components

- **Log Sources**
- **Google Gemini**

## Connections

- Log Sources → Fluentd Collector: collects (evidence: `README.md`)
- Fluentd Collector → Fluentd Buffer: buffers (evidence: `README.md`)
- Log Daemon → Fluentd Buffer: tails or forwards
- Fluentd Buffer → Live Log Reader: reads (evidence: `scripts/main.py`)
- Live Log Reader → Qdrant Setup: initializes (evidence: `scripts/main.py`)
- Live Log Reader → Vector Store: searches (evidence: `scripts/main.py`)
- Live Log Reader → Context Builder: formats results (evidence: `scripts/main.py`)
- Live Log Reader → RAG Classifier: invokes (evidence: `scripts/main.py`)
- Qdrant Setup → Qdrant: connects and creates collection (evidence: `scripts/client.py`)
- Vector Store → Qdrant: queries collection (evidence: `scripts/vectorstore.py`)
- Qdrant Setup → Google Gemini: embeds test query (evidence: `scripts/client.py`)
- Vector Store → Google Gemini: embeds text (evidence: `scripts/vectorstore.py`)
- Sample Logs → Log Ingestion: reads (evidence: `scripts/log_ingestion.py`)
- Log Ingestion → Qdrant Setup: initializes collection (evidence: `scripts/log_ingestion.py`)
- Log Ingestion → Text Chunker: chunks logs (evidence: `scripts/log_ingestion.py`)
- Log Ingestion → Vector Store: stores chunks (evidence: `scripts/log_ingestion.py`)
