# mu3uf/finalmovieai architecture

> Architecture diagram of the GitHub repository mu3uf/finalmovieai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mu3uf/finalmovieai
- Repository: https://github.com/mu3uf/finalmovieai

## Overview

This is a movie recommendation assistant with a browser UI, FastAPI API, authenticated user features, and an AI chat workflow. A user sends a request through chat; the API authenticates the user, passes the request and user context to the agent, and the agent selects movie-search, trending, or unwatched recommendations. Tool results return through chat as movie cards and a concise response. Separate movie endpoints support trending and user likes/watched actions. Source excerpts show the backend relationships; frontend-to-API behavior and the role of the TMDB service are not established, so those links are omitted or marked unverified.

Main entry points: [`app/agent/agent.py`](https://github.com/mu3uf/finalmovieai/blob/main/app/agent/agent.py) (AI Agent), [`app/api/movies.py`](https://github.com/mu3uf/finalmovieai/blob/main/app/api/movies.py) (Movie Endpoints), [`app/main.py`](https://github.com/mu3uf/finalmovieai/blob/main/app/main.py) (FastAPI Application), [`app/api/chat.py`](https://github.com/mu3uf/finalmovieai/blob/main/app/api/chat.py) (Chat Endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_frontend["Web Interface<br/>[app.js]"]
end

subgraph group_api["API and Identity"]
  node_server["FastAPI Application<br/>[main.py]"]
  node_chat_api["Chat Endpoint<br/>[chat.py]"]
  node_auth_api["Auth Endpoints<br/>[auth.py]"]
  node_movies_api["Movie Endpoints<br/>[movies.py]"]
  node_auth_service["User Verification<br/>[auth.py]"]
end

subgraph group_assistant["Assistant and Discovery"]
  node_agent["AI Agent<br/>[agent.py]"]
  node_prompt["Routing Instructions<br/>[prompts.py]"]
  node_search["Movie Search<br/>[search_movie.py]"]
  node_trending["Trending Movies<br/>[trending_movies.py]"]
  node_unwatched["Unwatched Picks"]
end

subgraph group_integrations["Data Integrations"]
  node_tmdb_service["TMDB Service<br/>[tmdb.py]"]
  node_supabase_client["Supabase Client<br/>[supabase.py]"]
  node_supabase[("Supabase")]
  node_tmdb["TMDB API"]
  node_gemini["Gemini Model"]
end

node_user(("Movie Seeker"))

node_user -.->|"uses"| node_frontend
node_frontend -.->|"requests"| node_server
node_server -->|"routes"| node_chat_api
node_server -->|"routes"| node_auth_api
node_server -->|"routes"| node_movies_api
node_chat_api -->|"verifies user"| node_auth_service
node_auth_api -->|"verifies user"| node_auth_service
node_auth_service -->|"validates token"| node_supabase_client
node_auth_api -->|"signs in users"| node_supabase
node_chat_api -->|"invokes"| node_agent
node_chat_api -->|"sets user context"| node_unwatched
node_agent -->|"uses instructions"| node_prompt
node_agent -->|"queries model"| node_gemini
node_agent -->|"dispatches"| node_search
node_agent -->|"dispatches"| node_trending
node_agent -->|"dispatches"| node_unwatched
node_movies_api -->|"verifies user"| node_auth_service
node_movies_api -->|"invokes"| node_trending
node_movies_api -->|"gets poster"| node_search
node_movies_api -->|"reads and writes"| node_supabase_client
node_search -->|"queries movies"| node_supabase_client
node_search -->|"looks up posters"| node_tmdb
node_unwatched -->|"filters watched movies"| node_supabase
node_unwatched -->|"looks up posters"| node_tmdb
node_trending -->|"fetches trending"| node_tmdb
node_supabase_client -->|"connects"| node_supabase

click node_frontend "https://github.com/mu3uf/finalmovieai/blob/main/frontend/js/app.js"
click node_server "https://github.com/mu3uf/finalmovieai/blob/main/app/main.py"
click node_chat_api "https://github.com/mu3uf/finalmovieai/blob/main/app/api/chat.py"
click node_auth_api "https://github.com/mu3uf/finalmovieai/blob/main/app/api/auth.py"
click node_movies_api "https://github.com/mu3uf/finalmovieai/blob/main/app/api/movies.py"
click node_auth_service "https://github.com/mu3uf/finalmovieai/blob/main/app/services/auth.py"
click node_agent "https://github.com/mu3uf/finalmovieai/blob/main/app/agent/agent.py"
click node_prompt "https://github.com/mu3uf/finalmovieai/blob/main/app/agent/prompts.py"
click node_search "https://github.com/mu3uf/finalmovieai/blob/main/app/tools/search_movie.py"
click node_trending "https://github.com/mu3uf/finalmovieai/blob/main/app/tools/trending_movies.py"
click node_unwatched "https://github.com/mu3uf/finalmovieai/blob/main/app/tools/recommend_unwatched_movies.py"
click node_tmdb_service "https://github.com/mu3uf/finalmovieai/blob/main/app/services/tmdb.py"
click node_supabase_client "https://github.com/mu3uf/finalmovieai/blob/main/app/services/supabase.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend toneBlue
class node_server,node_chat_api,node_auth_api,node_movies_api,node_auth_service toneAmber
class node_agent,node_prompt,node_search,node_trending,node_unwatched toneMint
class node_tmdb_service,node_supabase_client,node_supabase,node_tmdb,node_gemini toneRose
class node_user toneIndigo
```

## Components

### User Interface

- [Web Interface](https://github.com/mu3uf/finalmovieai/blob/main/frontend/js/app.js): `frontend/js/app.js`

### API and Identity

- [FastAPI Application](https://github.com/mu3uf/finalmovieai/blob/main/app/main.py): `app/main.py`
- [Chat Endpoint](https://github.com/mu3uf/finalmovieai/blob/main/app/api/chat.py): `app/api/chat.py`
- [Auth Endpoints](https://github.com/mu3uf/finalmovieai/blob/main/app/api/auth.py): `app/api/auth.py`
- [Movie Endpoints](https://github.com/mu3uf/finalmovieai/blob/main/app/api/movies.py): `app/api/movies.py`
- [User Verification](https://github.com/mu3uf/finalmovieai/blob/main/app/services/auth.py): `app/services/auth.py`

### Assistant and Discovery

- [AI Agent](https://github.com/mu3uf/finalmovieai/blob/main/app/agent/agent.py): `app/agent/agent.py`
- [Routing Instructions](https://github.com/mu3uf/finalmovieai/blob/main/app/agent/prompts.py): `app/agent/prompts.py`
- [Movie Search](https://github.com/mu3uf/finalmovieai/blob/main/app/tools/search_movie.py): `app/tools/search_movie.py`
- [Trending Movies](https://github.com/mu3uf/finalmovieai/blob/main/app/tools/trending_movies.py): `app/tools/trending_movies.py`
- [Unwatched Picks](https://github.com/mu3uf/finalmovieai/blob/main/app/tools/recommend_unwatched_movies.py): `app/tools/recommend_unwatched_movies.py`

### Data Integrations

- [TMDB Service](https://github.com/mu3uf/finalmovieai/blob/main/app/services/tmdb.py): `app/services/tmdb.py`
- [Supabase Client](https://github.com/mu3uf/finalmovieai/blob/main/app/services/supabase.py): `app/services/supabase.py`
- **Supabase**
- **TMDB API**
- **Gemini Model**

### Other components

- **Movie Seeker**

## Connections

- Movie Seeker → Web Interface: uses
- Web Interface → FastAPI Application: requests
- FastAPI Application → Chat Endpoint: routes (evidence: `app/main.py`)
- FastAPI Application → Auth Endpoints: routes (evidence: `app/main.py`)
- FastAPI Application → Movie Endpoints: routes (evidence: `app/main.py`)
- Chat Endpoint → User Verification: verifies user (evidence: `app/api/chat.py`)
- Auth Endpoints → User Verification: verifies user (evidence: `app/api/auth.py`)
- User Verification → Supabase Client: validates token (evidence: `app/services/auth.py`)
- Auth Endpoints → Supabase: signs in users (evidence: `app/api/auth.py`)
- Chat Endpoint → AI Agent: invokes (evidence: `app/api/chat.py`)
- Chat Endpoint → Unwatched Picks: sets user context (evidence: `app/api/chat.py`)
- AI Agent → Routing Instructions: uses instructions (evidence: `app/agent/agent.py`)
- AI Agent → Gemini Model: queries model (evidence: `app/agent/agent.py`)
- AI Agent → Movie Search: dispatches (evidence: `app/agent/agent.py`)
- AI Agent → Trending Movies: dispatches (evidence: `app/agent/agent.py`)
- AI Agent → Unwatched Picks: dispatches (evidence: `app/agent/agent.py`)
- Movie Endpoints → User Verification: verifies user (evidence: `app/api/movies.py`)
- Movie Endpoints → Trending Movies: invokes (evidence: `app/api/movies.py`)
- Movie Endpoints → Movie Search: gets poster (evidence: `app/api/movies.py`)
- Movie Endpoints → Supabase Client: reads and writes (evidence: `app/api/movies.py`)
- Movie Search → Supabase Client: queries movies (evidence: `app/tools/search_movie.py`)
- Movie Search → TMDB API: looks up posters (evidence: `app/tools/search_movie.py`)
- Unwatched Picks → Supabase: filters watched movies (evidence: `app/tools/recommend_unwatched_movies.py`)
- Unwatched Picks → TMDB API: looks up posters (evidence: `app/tools/recommend_unwatched_movies.py`)
- Trending Movies → TMDB API: fetches trending (evidence: `app/tools/trending_movies.py`)
- Supabase Client → Supabase: connects (evidence: `app/services/supabase.py`)
