# sanchet237/astrobot-space_trivia architecture

> Architecture diagram of the GitHub repository sanchet237/astrobot-space_trivia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sanchet237/astrobot-space_trivia
- Repository: https://github.com/sanchet237/astrobot-space_trivia

## Overview

##### Project Type and Purpose
- Astro Bot is a full-stack web application (Flask backend + static frontend) whose purpose is to serve a space-themed chatbot. It retrieves real-time data from NASA Open Data and processes user queries via the Gemini API for NLP.

##### File Structure
- Top-level files:
- server.py – Flask application entry point and HTTP routes
- llm.py – Dedicated module for natural language processing and external API integration
- templates/index.html – Single-page UI shell
- templates/static/ – Static assets (CSS, JS, images)
- requirements.txt – Python dependencies
- No separate “src” or “app” directories means everything is centrally managed under server.py and a small module.

##### README for Additional Insights
- Backend uses Python + Flask
- Frontend uses vanilla HTML/CSS/JS
- Two major external API integrations: NASA Open Data and Gemini API (for NLP)
- The “How It Works” section confirms the dataflow: user → Flask → llm.py → external APIs → Flask → browser

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client"
        Browser["Browser"]:::frontend
        Index["index.html"]:::frontend
        Static["Static Assets"]:::frontend
    end

    %% Server Layer
    subgraph "Server"
        Flask["Flask Server\n(server.py)"]:::backend
        NLP["NLP Module\n(llm.py)"]:::service
    end

    %% External Services
    subgraph "External Services"
        NASA["NASA Open Data API"]:::external
        Gemini["Gemini API"]:::external
    end

    %% Documentation
    subgraph "Documentation"
        Req["requirements.txt"]:::docs
        Readme["Readme.md"]:::docs
    end

    %% Data Flow
    Browser -->|"GET /"| Flask
    Flask -->|"render index.html"| Index
    Index -->|"load assets"| Static

    Browser -->|"POST /chat (AJAX)"| Flask
    Flask -->|"function call"| NLP

    NLP -->|"REST API (JSON)"| NASA
    NASA -->|"JSON response"| NLP

    NLP -->|"REST API (JSON)"| Gemini
    Gemini -->|"JSON response"| NLP

    NLP -->|"processed answer"| Flask
    Flask -->|"JSON response"| Browser

    %% Click Events
    click Index "https://github.com/sanchet237/astrobot-space_trivia/blob/main/templates/index.html"
    click Static "https://github.com/sanchet237/astrobot-space_trivia/tree/main/templates/static/"
    click Flask "https://github.com/sanchet237/astrobot-space_trivia/blob/main/server.py"
    click NLP "https://github.com/sanchet237/astrobot-space_trivia/blob/main/llm.py"
    click Req "https://github.com/sanchet237/astrobot-space_trivia/blob/main/requirements.txt"
    click Readme "https://github.com/sanchet237/astrobot-space_trivia/blob/main/Readme.md"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#d4edda,stroke:#28a745,color:#155724;
    classDef service fill:#d4edda,stroke:#28a745,color:#155724;
    classDef external fill:#fff3cd,stroke:#d39e00,color:#856404;
    classDef docs fill:#e2e3e5,stroke:#6c757d,color:#343a40;
```
