# benomads/ortaqzan architecture

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

- Interactive diagram: https://gitdiagram.com/benomads/ortaqzan
- Repository: https://github.com/benomads/ortaqzan

## Overview

OrtaqZan is a Spring Boot legal-assistance service. A user submits a message and memory ID to the assistant endpoint; the service streams tokens from a LangChain4j assistant. Configuration defines document ingestion, embeddings, retrieval, and chat memory, while Elasticsearch is configured as the embedding store. The README also advertises contract analysis and multilingual guidance, though sampled code does not show a separate contract-analysis workflow. The graph follows shown calls and configuration; uncertain framework wiring is omitted or marked dashed.

Main entry points: [`src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java) (Assistant configuration), [`src/main/resources/data`](https://github.com/benomads/ortaqzan/tree/main/src/main/resources/data) (Legal document corpus), [`src/main/java/benomads/ortaq_zan/assistant/AssistantController.java`](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantController.java) (Assistant endpoint), [`src/main/java/benomads/ortaq_zan/service/AssistantService.java`](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/service/AssistantService.java) (Streaming service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and streaming"]
  node_controller["Assistant endpoint"]
  node_service["Streaming service"]
  node_application["Application entry point"]
end

subgraph group_assistant["Assistant runtime"]
  node_assistant["Legal assistant<br/>[Assistant.java]"]
  node_assistant_config["Assistant configuration"]
  node_memory["Chat memory"]
end

subgraph group_knowledge["Legal knowledge"]
  node_embedding_model["Embedding model"]
  node_retriever["Content retriever"]
  node_ingestion["Document ingestion"]
  node_corpus["Legal document corpus"]
  node_store_config["Elasticsearch store config"]
  node_document_loader["Document loader"]
  node_loader_examples["Loader examples"]
end

subgraph group_domain["User domain"]
  node_user_entity["User entity<br/>[User.java]"]
end

node_user(("User"))
node_elastic[("Elasticsearch")]

node_user -->|"submits message"| node_controller
node_controller -->|"forwards request"| node_service
node_service -->|"starts token stream"| node_assistant
node_assistant -.->|"streams legal guidance"| node_user
node_assistant_config -->|"creates"| node_embedding_model
node_assistant_config -->|"configures"| node_retriever
node_assistant_config -->|"provides"| node_memory
node_assistant_config -->|"runs ingestion"| node_ingestion
node_ingestion -->|"loads documents"| node_corpus
node_retriever -->|"embeds queries"| node_embedding_model
node_retriever -.->|"searches embeddings"| node_elastic
node_ingestion -.->|"stores embeddings"| node_elastic
node_store_config -->|"configures connection"| node_elastic
node_document_loader -->|"loads documents"| node_corpus
node_loader_examples -->|"demonstrates loading"| node_corpus

click node_controller "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantController.java"
click node_service "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/service/AssistantService.java"
click node_assistant "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/Assistant.java"
click node_assistant_config "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java"
click node_memory "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java"
click node_embedding_model "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java"
click node_retriever "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java"
click node_ingestion "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java"
click node_corpus "https://github.com/benomads/ortaqzan/tree/main/src/main/resources/data"
click node_store_config "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/vectordb/ElasticEmbeddingStoreConfig.java"
click node_document_loader "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/service/DocumentLoader.java"
click node_loader_examples "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/service/DocumentLoaderExamples.java"
click node_user_entity "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/entity/User.java"
click node_application "https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/OrtaqZanApplication.java"

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_controller,node_service,node_application,node_user toneBlue
class node_assistant,node_assistant_config,node_memory,node_elastic toneAmber
class node_embedding_model,node_retriever,node_ingestion,node_corpus,node_store_config,node_document_loader,node_loader_examples toneMint
class node_user_entity toneRose
```

## Components

### API and streaming

- [Assistant endpoint](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantController.java): `src/main/java/benomads/ortaq_zan/assistant/AssistantController.java`
- [Streaming service](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/service/AssistantService.java): `src/main/java/benomads/ortaq_zan/service/AssistantService.java`
- [Application entry point](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/OrtaqZanApplication.java): `src/main/java/benomads/ortaq_zan/OrtaqZanApplication.java`

### Assistant runtime

- [Legal assistant](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/Assistant.java): `src/main/java/benomads/ortaq_zan/assistant/Assistant.java`
- [Assistant configuration](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java): `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`
- [Chat memory](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java): `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`

### Legal knowledge

- [Embedding model](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java): `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`
- [Content retriever](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java): `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`
- [Document ingestion](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java): `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`
- [Legal document corpus](https://github.com/benomads/ortaqzan/tree/main/src/main/resources/data): `src/main/resources/data`
- [Elasticsearch store config](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/vectordb/ElasticEmbeddingStoreConfig.java): `src/main/java/benomads/ortaq_zan/vectordb/ElasticEmbeddingStoreConfig.java`
- [Document loader](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/service/DocumentLoader.java): `src/main/java/benomads/ortaq_zan/service/DocumentLoader.java`
- [Loader examples](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/service/DocumentLoaderExamples.java): `src/main/java/benomads/ortaq_zan/service/DocumentLoaderExamples.java`

### User domain

- [User entity](https://github.com/benomads/ortaqzan/blob/main/src/main/java/benomads/ortaq_zan/entity/User.java): `src/main/java/benomads/ortaq_zan/entity/User.java`

### Other components

- **User**
- **Elasticsearch**

## Connections

- User → Assistant endpoint: submits message (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantController.java`)
- Assistant endpoint → Streaming service: forwards request (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantController.java`)
- Streaming service → Legal assistant: starts token stream (evidence: `src/main/java/benomads/ortaq_zan/service/AssistantService.java`)
- Legal assistant → User: streams legal guidance (evidence: `README.md`)
- Assistant configuration → Embedding model: creates (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`)
- Assistant configuration → Content retriever: configures (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`)
- Assistant configuration → Chat memory: provides (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`)
- Assistant configuration → Document ingestion: runs ingestion (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`)
- Document ingestion → Legal document corpus: loads documents (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`)
- Content retriever → Embedding model: embeds queries (evidence: `src/main/java/benomads/ortaq_zan/assistant/AssistantConfig.java`)
- Content retriever → Elasticsearch: searches embeddings
- Document ingestion → Elasticsearch: stores embeddings
- Elasticsearch store config → Elasticsearch: configures connection (evidence: `src/main/java/benomads/ortaq_zan/vectordb/ElasticEmbeddingStoreConfig.java`)
- Document loader → Legal document corpus: loads documents (evidence: `src/main/java/benomads/ortaq_zan/service/DocumentLoader.java`)
- Loader examples → Legal document corpus: demonstrates loading (evidence: `src/main/java/benomads/ortaq_zan/service/DocumentLoaderExamples.java`)
