# kanishkp2906/amz_backend architecture

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

- Interactive diagram: https://gitdiagram.com/kanishkp2906/amz_backend
- Repository: https://github.com/kanishkp2906/amz_backend

## Overview

This repository appears to implement an Amazon price-tracking API: users can submit products for tracking, with product, price-history, and user data represented in separate schemas. Scraping, email delivery, request middleware, and supporting utilities are distinct runtime capabilities. The README is empty and the main API, database, and alerting implementations were not excerpted, so their interactions cannot be confirmed; the graph shows only relationships supported by the available excerpts or source index.

Main entry points: [`config.py`](https://github.com/kanishkp2906/amz_backend/blob/main/config.py) (Runtime config), [`scrape_script.py`](https://github.com/kanishkp2906/amz_backend/blob/main/scrape_script.py) (Amazon scraper), [`utils/send_email.py`](https://github.com/kanishkp2906/amz_backend/blob/main/utils/send_email.py) (SMTP sender), [`middleware/rate_limiter.py`](https://github.com/kanishkp2906/amz_backend/blob/main/middleware/rate_limiter.py) (Rate limiter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and schemas"]
  node_routes["API routes<br/>[routes.py]"]
  node_main["App entry<br/>[main.py]"]
  node_product_schema["Product schema<br/>[products.py]"]
  node_tracking_schema["Tracking schema<br/>[tracking.py]"]
  node_history_schema["History schema<br/>[price_history.py]"]
  node_user_schema["User schema<br/>[users.py]"]
end

subgraph group_tracking["Price tracking"]
  node_database["Database access<br/>[database.py]"]
  node_models["Domain models<br/>[models.py]"]
  node_scraper["Amazon scraper<br/>[scrape_script.py]"]
end

subgraph group_integrations["External integrations"]
  node_email_alert["Email alerts<br/>[email_alert.py]"]
  node_email_sender["SMTP sender<br/>[send_email.py]"]
end

subgraph group_support["Runtime support"]
  node_config["Runtime config<br/>[config.py]"]
  node_cors["CORS middleware<br/>[app_cors.py]"]
  node_rate_limiter["Rate limiter<br/>[rate_limiter.py]"]
  node_clock["Time utility<br/>[current_time.py]"]
  node_url_shortener["URL shortener<br/>[url_shortener.py]"]
end

node_user(("API user"))
node_amazon(("Amazon pages"))
node_scrapingant["ScrapingAnt API"]
node_smtp["SMTP service"]
node_redis[("Redis")]

node_user -.->|"requests"| node_routes
node_scraper -->|"fetches pages"| node_scrapingant
node_scraper -.->|"scrapes products"| node_amazon
node_email_sender -->|"sends mail"| node_smtp
node_email_sender -->|"reads settings"| node_config
node_rate_limiter -->|"reads Redis URL"| node_config
node_rate_limiter -->|"counts requests"| node_redis
node_cors -->|"reads origins"| node_config
node_tracking_schema -->|"embeds product"| node_product_schema

click node_routes "https://github.com/kanishkp2906/amz_backend/blob/main/routes.py"
click node_main "https://github.com/kanishkp2906/amz_backend/blob/main/main.py"
click node_product_schema "https://github.com/kanishkp2906/amz_backend/blob/main/schemas/products.py"
click node_tracking_schema "https://github.com/kanishkp2906/amz_backend/blob/main/schemas/tracking.py"
click node_history_schema "https://github.com/kanishkp2906/amz_backend/blob/main/schemas/price_history.py"
click node_user_schema "https://github.com/kanishkp2906/amz_backend/blob/main/schemas/users.py"
click node_database "https://github.com/kanishkp2906/amz_backend/blob/main/database.py"
click node_models "https://github.com/kanishkp2906/amz_backend/blob/main/models.py"
click node_scraper "https://github.com/kanishkp2906/amz_backend/blob/main/scrape_script.py"
click node_email_alert "https://github.com/kanishkp2906/amz_backend/blob/main/utils/email_alert.py"
click node_email_sender "https://github.com/kanishkp2906/amz_backend/blob/main/utils/send_email.py"
click node_config "https://github.com/kanishkp2906/amz_backend/blob/main/config.py"
click node_cors "https://github.com/kanishkp2906/amz_backend/blob/main/middleware/app_cors.py"
click node_rate_limiter "https://github.com/kanishkp2906/amz_backend/blob/main/middleware/rate_limiter.py"
click node_clock "https://github.com/kanishkp2906/amz_backend/blob/main/utils/current_time.py"
click node_url_shortener "https://github.com/kanishkp2906/amz_backend/blob/main/utils/url_shortener.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_routes,node_main,node_product_schema,node_tracking_schema,node_history_schema,node_user_schema,node_user toneBlue
class node_database,node_models,node_scraper,node_redis toneAmber
class node_email_alert,node_email_sender,node_scrapingant toneMint
class node_config,node_cors,node_rate_limiter,node_clock,node_url_shortener toneRose
class node_amazon,node_smtp toneIndigo
```

## Components

### API and schemas

- [API routes](https://github.com/kanishkp2906/amz_backend/blob/main/routes.py): `routes.py`
- [App entry](https://github.com/kanishkp2906/amz_backend/blob/main/main.py): `main.py`
- [Product schema](https://github.com/kanishkp2906/amz_backend/blob/main/schemas/products.py): `schemas/products.py`
- [Tracking schema](https://github.com/kanishkp2906/amz_backend/blob/main/schemas/tracking.py): `schemas/tracking.py`
- [History schema](https://github.com/kanishkp2906/amz_backend/blob/main/schemas/price_history.py): `schemas/price_history.py`
- [User schema](https://github.com/kanishkp2906/amz_backend/blob/main/schemas/users.py): `schemas/users.py`

### Price tracking

- [Database access](https://github.com/kanishkp2906/amz_backend/blob/main/database.py): `database.py`
- [Domain models](https://github.com/kanishkp2906/amz_backend/blob/main/models.py): `models.py`
- [Amazon scraper](https://github.com/kanishkp2906/amz_backend/blob/main/scrape_script.py): `scrape_script.py`

### External integrations

- [Email alerts](https://github.com/kanishkp2906/amz_backend/blob/main/utils/email_alert.py): `utils/email_alert.py`
- [SMTP sender](https://github.com/kanishkp2906/amz_backend/blob/main/utils/send_email.py): `utils/send_email.py`

### Runtime support

- [Runtime config](https://github.com/kanishkp2906/amz_backend/blob/main/config.py): `config.py`
- [CORS middleware](https://github.com/kanishkp2906/amz_backend/blob/main/middleware/app_cors.py): `middleware/app_cors.py`
- [Rate limiter](https://github.com/kanishkp2906/amz_backend/blob/main/middleware/rate_limiter.py): `middleware/rate_limiter.py`
- [Time utility](https://github.com/kanishkp2906/amz_backend/blob/main/utils/current_time.py): `utils/current_time.py`
- [URL shortener](https://github.com/kanishkp2906/amz_backend/blob/main/utils/url_shortener.py): `utils/url_shortener.py`

### Other components

- **API user**
- **Amazon pages**
- **ScrapingAnt API**
- **SMTP service**
- **Redis**

## Connections

- API user → API routes: requests
- Amazon scraper → ScrapingAnt API: fetches pages (evidence: `scrape_script.py`)
- Amazon scraper → Amazon pages: scrapes products
- SMTP sender → SMTP service: sends mail (evidence: `utils/send_email.py`)
- SMTP sender → Runtime config: reads settings (evidence: `utils/send_email.py`)
- Rate limiter → Runtime config: reads Redis URL (evidence: `middleware/rate_limiter.py`)
- Rate limiter → Redis: counts requests (evidence: `middleware/rate_limiter.py`)
- CORS middleware → Runtime config: reads origins (evidence: `middleware/app_cors.py`)
- Tracking schema → Product schema: embeds product (evidence: `schemas/tracking.py`)
