> For the complete documentation index, see [llms.txt](https://pmse.gitbook.io/pmse-dhdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pmse.gitbook.io/pmse-dhdk/2.-software-requirement-specification/2.4-system-architecture/2.4.2-system-architecture-diagram.md).

# 2.4.2 System architecture diagram

The system architecture for the demo version includes a user interface (UI) layer, which serves as the point of interaction for users. This UI communicates with the backend, which processes the user’s input, retrieves data from the Geoportale knowledge base, feeds this relevant retrieved information into Mistral LLM, generate augmented output, and delivers responses back to the user.

<div data-full-width="true"><figure><img src="/files/WPU5aMwNlcqE3FWPmBcz" alt=""><figcaption><p>System architecture diagram of the prototype version.</p></figcaption></figure></div>

#### **Key Functionalities:**

1. **Dataset Loading and Chunking**:
   * The script can load a CSV dataset, validate its structure, and split its content into manageable "chunks" for easier processing and retrieval.
   * These chunks are enriched with metadata (e.g., title, description, URL) for better context during retrieval.
2. **Vector Store Management**:
   * A **FAISS-based vector store** is used to index the chunks of text. This allows efficient semantic search and retrieval.
   * If the vector store does not already exist, it is created from the dataset. Otherwise, it is loaded for use.
3. **Conversational AI Integration**:
   * A **Mistral AI language model** is integrated for text generation.
   * A conversation chain is created using **ConversationalRetrievalChain**, which combines retrieval (from the vector store) with conversational abilities.
4. **Retry Mechanism for API Calls**:
   * Handles network issues or API rate limits gracefully with a retry mechanism for API calls.
5. **Streamlit Interface**:

   * Provides a simple and interactive UI for users to ask questions and view responses.
   * The conversation history is styled and displayed, distinguishing between user inputs and AI responses.

   <figure><img src="/files/Z7tMpbmG4Mxz7IpvZRre" alt=""><figcaption><p>Streamlit User Interface proposal.</p></figcaption></figure>
6. **Error Handling and Debugging**:
   * Comprehensive error handling ensures smooth operation, even in the presence of issues like missing API keys, invalid data, or failed API calls.
   * Logs and warnings are printed for easier debugging.

<div data-full-width="true"><figure><img src="/files/GmkJQd5SPQ3KAqJVTNGH" alt=""><figcaption><p>Entity-relationship (ER) diagram of the prototype.</p></figcaption></figure></div>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://pmse.gitbook.io/pmse-dhdk/2.-software-requirement-specification/2.4-system-architecture/2.4.2-system-architecture-diagram.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
