# fabyrizky/ai-smart-ecotourism-app architecture

> Architecture diagram of the GitHub repository fabyrizky/ai-smart-ecotourism-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fabyrizky/ai-smart-ecotourism-app
- Repository: https://github.com/fabyrizky/ai-smart-ecotourism-app

## Overview

##### Project type and purpose
- This is a single‐page, Python‐based “full-stack” application built on Streamlit.
- Purpose: An AI-driven platform for sustainable tourism management, deployed to Streamlit Cloud.

##### File structure
- `.github/workflows/deploy.yml` – CI/CD pipeline that builds and deploys to Streamlit Cloud on push.
- `.streamlit/config.toml` + `.streamlit/secrets.toml` – Streamlit configuration and API keys (e.g., OpenAI, map services).
- `main-app.py` – The single entry point combining UI definitions, interaction logic, and AI calls.
- `requirements.txt` + `runtime.txt` – Python dependencies and runtime version for the cloud environment.
- `README.md` – High-level description, deployment instructions.

##### README for additional insights
- Confirms Streamlit as the hosting framework.
- Shows two deployment methods: Streamlit Cloud and manual clone & deploy.
- Implies reliance on external AI services (via secrets) and no on-prem database.

##### Main components
a. Client (Web Browser)
b. Streamlit Cloud Hosting
– Streamlit Server executing `main-app.py`
– Dependency environment (Python runtime + libs from `requirements.txt`)
c. Configuration Store
– Secrets and config loaded by Streamlit (.streamlit/secrets.toml)
d. External AI Service(s)
– OpenAI or custom ML endpoints called from `main-app.py`
e. CI/CD Pipeline
– GitHub repository + GitHub Actions workflow → Automated deploy to Streamlit Cloud

##### Interactions and data flows
- Client ↔ Streamlit Server: HTTP requests (render UI, submit prompts, receive results)
- Streamlit Server → AI Service: HTTPS API calls (pass user inputs, retrieve AI responses)
- GitHub → GitHub Actions → Streamlit Cloud: Git push triggers build & deploy

##### Architectural patterns & design principles
- Thin-client architecture: all business logic (UI + data orchestration) lives in `main-app.py`.
- Serverless deployment on Streamlit Cloud: no managed servers or databases.
- Externalize secrets for credentials/config (12-factor app principle).
- CI/CD for zero-downtime, automated delivery.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Layer
    subgraph "CI/CD Pipeline" 
        direction TB
        GHRepo["GitHub Repository"]:::ci
        Actions["GitHub Actions Workflow"]:::ci
    end

    %% Deployment Trigger
    GHRepo -->|"git push event"| Actions
    Actions -->|"deploy artifact"| StreamlitCloud

    %% Deployment & Hosting
    subgraph "Streamlit Cloud Hosting" 
        direction TB
        StreamlitServer["Streamlit Server"]:::infra
        Dependencies["Python Runtime + Libraries"]:::infra
        Config["Config Store"]:::infra
        Secrets["Secrets Store"]:::infra
        App["main-app.py"]:::infra
        Requirements["requirements.txt"]:::infra
        RuntimeVer["runtime.txt"]:::infra
        Config -->|loads| ConfigFile
        Secrets -->|loads| SecretsFile
        Dependencies -->|installs| Requirements
        Dependencies -->|uses| RuntimeVer
        StreamlitServer -->|executes| App
    end

    %% Configuration files nodes for click events
    ConfigFile[".streamlit/config.toml"]:::infra
    SecretsFile[".streamlit/secrets.toml"]:::infra

    %% Client Interaction
    Browser["Web Browser (Client)"]:::ui
    Browser -->|"HTTP request / UI interaction"| StreamlitServer
    StreamlitServer -->|"HTTP response / UI render"| Browser

    %% External AI Services
    AIService["External AI Service"]:::external
    StreamlitServer -->|"HTTPS API call"| AIService
    AIService -->|"API response"| StreamlitServer

    %% Documentation
    Docs["README.md"]:::ci

    %% Click Events
    click App "https://github.com/fabyrizky/ai-smart-ecotourism-app/blob/main/main-app.py"
    click ConfigFile "https://github.com/fabyrizky/ai-smart-ecotourism-app/blob/main/.streamlit/config.toml"
    click SecretsFile "https://github.com/fabyrizky/ai-smart-ecotourism-app/blob/main/.streamlit/secrets.toml"
    click Requirements "https://github.com/fabyrizky/ai-smart-ecotourism-app/blob/main/requirements.txt"
    click RuntimeVer "https://github.com/fabyrizky/ai-smart-ecotourism-app/blob/main/runtime.txt"
    click Actions "https://github.com/fabyrizky/ai-smart-ecotourism-app/blob/main/.github/workflows/deploy.yml"
    click Docs "https://github.com/fabyrizky/ai-smart-ecotourism-app/blob/main/README.md"

    %% Styles
    classDef ui fill:#a8d0e6,stroke:#333,stroke-width:1px;
    classDef infra fill:#f8b500,stroke:#333,stroke-width:1px;
    classDef external fill:#8ac926,stroke:#333,stroke-width:1px;
    classDef ci fill:#ff6f59,stroke:#333,stroke-width:1px;
```
