# surya-kf/skyquery-agentic-database-reader architecture

> Architecture diagram of the GitHub repository surya-kf/skyquery-agentic-database-reader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/surya-kf/skyquery-agentic-database-reader
- Repository: https://github.com/surya-kf/skyquery-agentic-database-reader

## Overview

##### Main Components
- User Interface: Represent the frontend that includes various HTML templates (e.g., index, login, admin, add/edit flight forms) along with static assets (CSS/JavaScript). This is where user interactions like chat queries, authentication, and administrative actions occur.
- Flask Application (Backend): Centerpiece of the system including the main app (app.py) that processes HTTP requests, handles routing, and integrates the chatbot, admin, and API endpoints.
- Natural Language Processing (NLP) Module: Indicate the integration with Together AI’s Llama 3.3 70B model for extracting flight information (e.g., flight numbers, destinations) from user queries.
- MongoDB Database: Acts as the data repository (collections like “flights” and “users”) to store real-time flight information and user/admin data.
- API Endpoints: Outline RESTful endpoints that provide data for both the chatbot responses and administrative functions.

##### Relationships and Interactions
- Client-to-Frontend: Show how users interact with the application via web browsers that load HTML templates and static assets.
- Backend-to-NLP Service: Illustrate integration between the Flask backend and the Together AI API for processing natural language queries.
- Backend-to-Database: Indicate how the backend queries and updates flight information stored in MongoDB.
- API Communication: Show that the REST API endpoints are part of the backend that allow both the UI and third-party integrations to access flight data.

##### Architectural Patterns and Design Principles
- MVC-Like Separation: Even though Flask is lightweight, the project separates concerns – static and template files for presentation (view), application logic in app.py (controller), and data management via MongoDB (model).
- Security & Authentication: Clearly mark the authentication module in the backend, since it manages user sessions and enforces role-based access for admins.

##### Relevant Technologies and Frameworks
- Python & Flask: Core backend framework.
- MongoDB (Atlas): Document-based data storage.
- Together AI’s Llama Model: NLP processing.
- HTML/CSS/JavaScript: Frontend technologies for building the UI.
- Deployment Tools: Procfile configuration and Render/Gunicorn for server deployment.

##### Practical Steps for the Engineer
- In the middle layer, detail the Flask application that manages routing, processing chat queries, handling logins, and administrative functions.
- To the side, represent the external NLP module (Together AI’s Llama model), connected via an API call from the Flask backend.
- At the bottom, illustrate the MongoDB database with separate connections for flight and user data.
- Don’t forget to indicate configuration and deployment components like the Procfile (for Render/Gunicorn) if high-level deployment architecture details are desirable.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Presentation Layer"
        Browser["User Browser"]:::client
        Frontend["Frontend - Chat & Admin (HTML, CSS, JS)"]:::presentation
    end

    subgraph "Business Logic Layer"
        FlaskApp["Backend - Flask Application (app.py)"]:::backend
    end

    subgraph "External Services"
        NLP["NLP Module (Together AI's Llama 3.3 70B)"]:::external
    end

    subgraph "Data Storage Layer"
        MongoDB["Database - MongoDB"]:::data
    end

    subgraph "Deployment Layer"
        Deployment["Deployment Config (Procfile)"]:::deployment
    end

    Browser -->|"sends_HTTP_request"| Frontend
    Frontend -->|"submits_data"| FlaskApp
    FlaskApp -->|"invokes_NLP"| NLP
    NLP -->|"returns_NLP_data"| FlaskApp
    FlaskApp -->|"queries/updates"| MongoDB
    FlaskApp -->|"serves_API_response"| Frontend
    Deployment -->|"configures"| FlaskApp

    click Frontend "https://github.com/surya-kf/skyquery-agentic-database-reader/tree/main/templates/"
    click FlaskApp "https://github.com/surya-kf/skyquery-agentic-database-reader/blob/main/app.py"
    click Deployment "https://github.com/surya-kf/skyquery-agentic-database-reader/tree/main/Procfile"

    classDef client fill:#FFE3C9,stroke:#1a1a1a,stroke-width:2px;
    classDef presentation fill:#CDEBFF,stroke:#1a1a1a,stroke-width:2px;
    classDef backend fill:#D2F8D2,stroke:#1a1a1a,stroke-width:2px;
    classDef external fill:#F8D2D2,stroke:#1a1a1a,stroke-width:2px;
    classDef data fill:#F8F1D2,stroke:#1a1a1a,stroke-width:2px;
    classDef deployment fill:#E0D2F8,stroke:#1a1a1a,stroke-width:2px;
```
