# anurag07-crypto/ai_pokedex architecture

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

- Interactive diagram: https://gitdiagram.com/anurag07-crypto/ai_pokedex
- Repository: https://github.com/anurag07-crypto/ai_pokedex

## Overview

AI Pokedex identifies an uploaded Pokémon image, displays its predicted label and confidence, then retrieves structured Pokémon details for presentation. The frontend performs image cleanup and classification, calls the FastAPI service for search-backed details, and formats the returned information with a separate Groq service. The backend and `Work_dir/main_pipeline.py` also expose agent workflows, though the sampled frontend calls prediction and backend endpoints directly rather than using that pipeline. Source excerpts do not establish model-weight loading or saved prediction behavior.

Main entry points: [`Frontend/front_server.py`](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Frontend/front_server.py) (Streamlit app), [`Work_dir/pokedex_agent.py`](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/pokedex_agent.py) (Pokédex agent), [`Backend/back_server.py`](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Backend/back_server.py) (FastAPI endpoint), [`Work_dir/main_pipeline.py`](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/main_pipeline.py) (Workflow pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_frontend["Streamlit app<br/>[front_server.py]"]
  node_cleanup["Background removal<br/>[services.py]"]
  node_formatter["Response formatter<br/>[services.py]"]
end

subgraph group_inference["Image inference"]
  node_cnn["CNN classifier<br/>[Cnn_model.py]"]
  node_workflow["Workflow pipeline<br/>[main_pipeline.py]"]
end

subgraph group_api["Details API"]
  node_backend["FastAPI endpoint<br/>[back_server.py]"]
end

subgraph group_agent["Knowledge agent"]
  node_agent["Pokédex agent<br/>[pokedex_agent.py]"]
  node_schema["Pokémon schema<br/>[pokedex_agent.py]"]
end

node_user(("Image uploader"))
node_search["Tavily search"]
node_groq["Groq LLM"]
node_logs[("Application logs")]

node_user -->|"uploads image"| node_frontend
node_frontend -->|"cleans image"| node_cleanup
node_frontend -->|"classifies image"| node_cnn
node_frontend -->|"posts label"| node_backend
node_backend -->|"requests details"| node_agent
node_agent -->|"searches context"| node_search
node_agent -->|"structures results"| node_groq
node_agent -->|"formats fields"| node_schema
node_backend -->|"returns details"| node_frontend
node_frontend -->|"formats details"| node_formatter
node_formatter -->|"invokes model"| node_groq
node_workflow -->|"classifies image"| node_cnn
node_workflow -->|"requests details"| node_agent

click node_frontend "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Frontend/front_server.py"
click node_cleanup "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Frontend/services.py"
click node_formatter "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Frontend/services.py"
click node_cnn "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/Cnn_model.py"
click node_workflow "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/main_pipeline.py"
click node_backend "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Backend/back_server.py"
click node_agent "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/pokedex_agent.py"
click node_schema "https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/pokedex_agent.py"
click node_logs "https://github.com/anurag07-crypto/ai_pokedex/tree/main/logs"

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,node_cleanup,node_formatter toneBlue
class node_cnn,node_workflow,node_logs toneAmber
class node_backend toneMint
class node_agent,node_schema toneRose
class node_user,node_search,node_groq toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Frontend/front_server.py): `Frontend/front_server.py`
- [Background removal](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Frontend/services.py): `Frontend/services.py`
- [Response formatter](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Frontend/services.py): `Frontend/services.py`

### Image inference

- [CNN classifier](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/Cnn_model.py): `Work_dir/Cnn_model.py`
- [Workflow pipeline](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/main_pipeline.py): `Work_dir/main_pipeline.py`

### Details API

- [FastAPI endpoint](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Backend/back_server.py): `Backend/back_server.py`

### Knowledge agent

- [Pokédex agent](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/pokedex_agent.py): `Work_dir/pokedex_agent.py`
- [Pokémon schema](https://github.com/anurag07-crypto/ai_pokedex/blob/main/Work_dir/pokedex_agent.py): `Work_dir/pokedex_agent.py`

### Other components

- **Image uploader**
- **Tavily search**
- **Groq LLM**
- [Application logs](https://github.com/anurag07-crypto/ai_pokedex/tree/main/logs): `logs`

## Connections

- Image uploader → Streamlit app: uploads image
- Streamlit app → Background removal: cleans image
- Streamlit app → CNN classifier: classifies image
- Streamlit app → FastAPI endpoint: posts label
- FastAPI endpoint → Pokédex agent: requests details
- Pokédex agent → Tavily search: searches context
- Pokédex agent → Groq LLM: structures results
- Pokédex agent → Pokémon schema: formats fields
- FastAPI endpoint → Streamlit app: returns details
- Streamlit app → Response formatter: formats details
- Response formatter → Groq LLM: invokes model
- Workflow pipeline → CNN classifier: classifies image
- Workflow pipeline → Pokédex agent: requests details
