# gauthiii/movieagent architecture

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

- Interactive diagram: https://gitdiagram.com/gauthiii/movieagent
- Repository: https://github.com/gauthiii/movieagent

## Overview

##### Project type and purpose
- This is a small full-stack web application called **Movie AI Agent**.
- Purpose: Provide a beautiful frontend UI where users type a movie name, send it to an Express/Node backend, which in turn invokes the Google Gemini API to fetch movie details (synopsis, cast, director, poster, etc.) and returns clean JSON for the frontend to render.

##### File structure
- Top level:
- package.json / package-lock.json – npm dependencies (Express, dotenv, etc.)
- README.md, LICENSE, .gitignore – docs and config.
- /backend
- server.js – Express server, listens (e.g. port 3001), defines POST /leo endpoint, serves static files (likely the frontend).
- gemini.js – wraps the call to Google Gemini AI API, reads API key from .env.
- /frontend
- index.html – single-page UI, includes TailwindCSS and Animate.css.
- script.js – vanilla JS: captures user input, does fetch(POST '/leo'), parses JSON response, manipulates DOM to show cards and images.

##### Additional insights from README
- No internal database—relies exclusively on an external AI service.
- Uses TailwindCSS + Animate.css for styling.
- The backend’s core responsibility is routing and API orchestration (no business logic beyond wrapping Gemini).
- Frontend is purely static, dynamic UI updated via fetch.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        IndexHTML["index.html"]:::frontend
        ScriptJS["script.js"]:::frontend
        Browser["Browser / UI"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        APIServer["Express Server"]:::backend
        subgraph "API Service"
            APIRoute["POST /leo endpoint"]:::backend
        end
        subgraph "Gemini Client"
            GeminiJS["gemini.js"]:::backend
            EnvFile[".env"]:::config
        end
    end

    %% External Service
    GoogleGeminiAPI["Google Gemini API"]:::external

    %% Project Root Config & Docs
    subgraph "Project Root"
        direction TB
        PackageJSON["package.json"]:::config
        Readme["README.md"]:::config
        License["LICENSE"]:::config
    end

    %% Connections - Frontend to Backend
    IndexHTML -->|loads| Browser
    ScriptJS -->|executes| Browser
    Browser -->|"POST /leo (application/json)"| APIRoute

    %% Static file serving
    APIServer -->|"serves static files"| IndexHTML
    APIServer -->|"serves static files"| ScriptJS

    %% Backend internal flow
    APIRoute -->|"calls gemini.js"| GeminiJS
    GeminiJS -->|"loads API_KEY"| EnvFile

    %% External API calls
    GeminiJS -->|"request JSON"| GoogleGeminiAPI
    GoogleGeminiAPI -->|"response JSON"| GeminiJS

    %% Response back to frontend
    APIRoute -->|"response JSON"| Browser

    %% Click Events
    click IndexHTML "https://github.com/gauthiii/movieagent/blob/main/frontend/index.html"
    click ScriptJS "https://github.com/gauthiii/movieagent/blob/main/frontend/script.js"
    click APIServer "https://github.com/gauthiii/movieagent/blob/main/backend/server.js"
    click APIRoute "https://github.com/gauthiii/movieagent/blob/main/backend/server.js"
    click GeminiJS "https://github.com/gauthiii/movieagent/blob/main/backend/gemini.js"
    click EnvFile "https://github.com/gauthiii/movieagent/blob/main/.env"
    click PackageJSON "https://github.com/gauthiii/movieagent/blob/main/package.json"
    click Readme "https://github.com/gauthiii/movieagent/blob/main/README.md"
    click License "https://github.com/gauthiii/movieagent/tree/main/LICENSE"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#D0F0C0,stroke:#228B22,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#FF8C00,stroke-width:1px
    classDef config fill:#F0F0F0,stroke:#888888,stroke-width:1px
```
