# mrgrose/pillstore architecture

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

- Interactive diagram: https://gitdiagram.com/mrgrose/pillstore
- Repository: https://github.com/mrgrose/pillstore

## Overview

PillStore is a FastAPI e-commerce application for supplements, with a separate Telegram bot and Mini App integration. The main customer journey is account access, product discovery, cart management, and order placement; seller/admin tools, favorites, stock management, and iHerb import are additional product capabilities. The graph follows documented API registration and sampled service dependencies. Several route-to-service and persistence details are unsampled, so those links are omitted or marked unverified rather than inferred as certain.

Main entry points: [`pillstore/app/main.py`](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/main.py) (FastAPI app), [`pillstore/app/db_crud/products_crud.py`](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/products_crud.py) (Product persistence), [`pillstore/app/db_crud/category_crud.py`](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/category_crud.py) (Category persistence), [`pillstore/app/services/order_service.py`](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/order_service.py) (Order service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_fastapi["FastAPI app<br/>[main.py]"]
end

subgraph group_identity["Identity and access"]
  node_v2auth["Auth API<br/>[auth.py]"]
  node_usersvc["User service<br/>[user_service.py]"]
  node_usercrud["User persistence<br/>[user_crud.py]"]
  node_usermodel["User records<br/>[users.py]"]
end

subgraph group_catalog["Catalog and import"]
  node_productapi["Product API<br/>[products.py]"]
  node_categoryapi["Category API<br/>[categories.py]"]
  node_productsvc["Product service<br/>[product_service.py]"]
  node_categorysvc["Category service"]
  node_productcrud["Product persistence<br/>[products_crud.py]"]
  node_categorycrud["Category persistence<br/>[category_crud.py]"]
  node_productmodel["Product records<br/>[products.py]"]
  node_scraper["iHerb importer<br/>[iherb_scraper.py]"]
end

subgraph group_commerce["Shopping and orders"]
  node_cartapi["Cart API<br/>[cart.py]"]
  node_cartservice["Cart service<br/>[cart_service.py]"]
  node_cartcrud["Cart persistence<br/>[cart_crud.py]"]
  node_ordersapi["Orders API<br/>[orders.py]"]
  node_ordersvc["Order service<br/>[order_service.py]"]
  node_ordercrud["Order persistence<br/>[order_crud.py]"]
  node_ordermodel["Order records<br/>[orders.py]"]
  node_favorites["Favorites API<br/>[favorites.py]"]
end

subgraph group_operations["Admin and integrations"]
  node_adminapi["Admin API<br/>[admin.py]"]
  node_adminsvc["Admin service<br/>[admin_service.py]"]
  node_bot["Telegram bot<br/>[main.py]"]
  node_bothandlers["Bot handlers<br/>[handlers.py]"]
  node_botclient["Bot API client<br/>[api_client.py]"]
end

node_customer(("Shopper"))
node_adminuser(("Administrator"))
node_api{{"PillStore HTTP API"}}
node_postgres[("PostgreSQL")]

node_customer -->|"shops at"| node_fastapi
node_adminuser -->|"manages via"| node_fastapi
node_fastapi -->|"registers"| node_v2auth
node_fastapi -->|"registers"| node_productapi
node_fastapi -->|"registers"| node_categoryapi
node_fastapi -->|"registers"| node_cartapi
node_fastapi -->|"registers"| node_ordersapi
node_fastapi -->|"registers"| node_favorites
node_fastapi -->|"registers"| node_adminapi
node_v2auth -->|"calls"| node_usersvc
node_usersvc -->|"uses"| node_usercrud
node_productsvc -->|"uses"| node_productcrud
node_productsvc -->|"uses"| node_categorycrud
node_categorysvc -->|"uses"| node_categorycrud
node_ordersvc -->|"uses"| node_cartcrud
node_ordersvc -->|"uses"| node_ordercrud
node_ordersvc -->|"uses"| node_productcrud
node_adminsvc -->|"uses"| node_productcrud
node_adminsvc -->|"uses"| node_categorycrud
node_bot -->|"registers handlers"| node_bothandlers
node_bothandlers -->|"calls"| node_botclient
node_botclient -->|"requests"| node_api
node_scraper -.->|"imports products"| node_productsvc
node_usercrud -.->|"persists users"| node_postgres
node_productcrud -.->|"persists products"| node_postgres
node_categorycrud -.->|"persists categories"| node_postgres
node_cartcrud -.->|"persists cart"| node_postgres
node_ordercrud -.->|"persists orders"| node_postgres

click node_fastapi "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/main.py"
click node_v2auth "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/auth.py"
click node_usersvc "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/user_service.py"
click node_usercrud "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/user_crud.py"
click node_usermodel "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/models/users.py"
click node_productapi "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/products.py"
click node_categoryapi "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/categories.py"
click node_productsvc "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/product_service.py"
click node_categorysvc "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/category_service.py"
click node_productcrud "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/products_crud.py"
click node_categorycrud "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/category_crud.py"
click node_productmodel "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/models/products.py"
click node_scraper "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/utils/iherb_scraper.py"
click node_cartapi "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/cart.py"
click node_cartservice "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/cart_service.py"
click node_cartcrud "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/cart_crud.py"
click node_ordersapi "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/orders.py"
click node_ordersvc "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/order_service.py"
click node_ordercrud "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/order_crud.py"
click node_ordermodel "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/models/orders.py"
click node_favorites "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/favorites.py"
click node_adminapi "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/admin.py"
click node_adminsvc "https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/admin_service.py"
click node_bot "https://github.com/mrgrose/pillstore/blob/main/pillstore/bot/main.py"
click node_bothandlers "https://github.com/mrgrose/pillstore/blob/main/pillstore/bot/handlers.py"
click node_botclient "https://github.com/mrgrose/pillstore/blob/main/pillstore/bot/api_client.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_fastapi toneBlue
class node_v2auth,node_usersvc,node_usercrud,node_usermodel,node_postgres toneAmber
class node_productapi,node_categoryapi,node_productsvc,node_categorysvc,node_productcrud,node_categorycrud,node_productmodel,node_scraper,node_api toneMint
class node_cartapi,node_cartservice,node_cartcrud,node_ordersapi,node_ordersvc,node_ordercrud,node_ordermodel,node_favorites toneRose
class node_adminapi,node_adminsvc,node_bot,node_bothandlers,node_botclient,node_customer,node_adminuser toneIndigo
```

## Components

### Application entry

- [FastAPI app](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/main.py): `pillstore/app/main.py`

### Identity and access

- [Auth API](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/auth.py): `pillstore/app/api/v2/auth.py`
- [User service](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/user_service.py): `pillstore/app/services/user_service.py`
- [User persistence](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/user_crud.py): `pillstore/app/db_crud/user_crud.py`
- [User records](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/models/users.py): `pillstore/app/models/users.py`

### Catalog and import

- [Product API](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/products.py): `pillstore/app/api/v2/products.py`
- [Category API](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/categories.py): `pillstore/app/api/v2/categories.py`
- [Product service](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/product_service.py): `pillstore/app/services/product_service.py`
- [Category service](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/category_service.py): `pillstore/app/services/category_service.py`
- [Product persistence](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/products_crud.py): `pillstore/app/db_crud/products_crud.py`
- [Category persistence](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/category_crud.py): `pillstore/app/db_crud/category_crud.py`
- [Product records](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/models/products.py): `pillstore/app/models/products.py`
- [iHerb importer](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/utils/iherb_scraper.py): `pillstore/app/utils/iherb_scraper.py`

### Shopping and orders

- [Cart API](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/cart.py): `pillstore/app/api/v2/cart.py`
- [Cart service](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/cart_service.py): `pillstore/app/services/cart_service.py`
- [Cart persistence](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/cart_crud.py): `pillstore/app/db_crud/cart_crud.py`
- [Orders API](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/orders.py): `pillstore/app/api/v2/orders.py`
- [Order service](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/order_service.py): `pillstore/app/services/order_service.py`
- [Order persistence](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/db_crud/order_crud.py): `pillstore/app/db_crud/order_crud.py`
- [Order records](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/models/orders.py): `pillstore/app/models/orders.py`
- [Favorites API](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/favorites.py): `pillstore/app/api/v2/favorites.py`

### Admin and integrations

- [Admin API](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/api/v2/admin.py): `pillstore/app/api/v2/admin.py`
- [Admin service](https://github.com/mrgrose/pillstore/blob/main/pillstore/app/services/admin_service.py): `pillstore/app/services/admin_service.py`
- [Telegram bot](https://github.com/mrgrose/pillstore/blob/main/pillstore/bot/main.py): `pillstore/bot/main.py`
- [Bot handlers](https://github.com/mrgrose/pillstore/blob/main/pillstore/bot/handlers.py): `pillstore/bot/handlers.py`
- [Bot API client](https://github.com/mrgrose/pillstore/blob/main/pillstore/bot/api_client.py): `pillstore/bot/api_client.py`

### Other components

- **Shopper**
- **Administrator**
- **PillStore HTTP API**
- **PostgreSQL**

## Connections

- Shopper → FastAPI app: shops at
- Administrator → FastAPI app: manages via
- FastAPI app → Auth API: registers (evidence: `pillstore/app/main.py`)
- FastAPI app → Product API: registers (evidence: `pillstore/app/main.py`)
- FastAPI app → Category API: registers (evidence: `pillstore/app/main.py`)
- FastAPI app → Cart API: registers (evidence: `pillstore/app/main.py`)
- FastAPI app → Orders API: registers (evidence: `pillstore/app/main.py`)
- FastAPI app → Favorites API: registers (evidence: `pillstore/app/main.py`)
- FastAPI app → Admin API: registers (evidence: `pillstore/app/main.py`)
- Auth API → User service: calls (evidence: `pillstore/app/api/v2/auth.py`)
- User service → User persistence: uses (evidence: `pillstore/app/services/user_service.py`)
- Product service → Product persistence: uses (evidence: `pillstore/app/services/product_service.py`)
- Product service → Category persistence: uses (evidence: `pillstore/app/services/product_service.py`)
- Category service → Category persistence: uses (evidence: `pillstore/app/services/category_service.py`)
- Order service → Cart persistence: uses (evidence: `pillstore/app/services/order_service.py`)
- Order service → Order persistence: uses (evidence: `pillstore/app/services/order_service.py`)
- Order service → Product persistence: uses (evidence: `pillstore/app/services/order_service.py`)
- Admin service → Product persistence: uses (evidence: `pillstore/app/services/admin_service.py`)
- Admin service → Category persistence: uses (evidence: `pillstore/app/services/admin_service.py`)
- Telegram bot → Bot handlers: registers handlers (evidence: `pillstore/bot/main.py`)
- Bot handlers → Bot API client: calls (evidence: `pillstore/bot/handlers.py`)
- Bot API client → PillStore HTTP API: requests
- iHerb importer → Product service: imports products (evidence: `pillstore/app/services/product_service.py`)
- User persistence → PostgreSQL: persists users
- Product persistence → PostgreSQL: persists products
- Category persistence → PostgreSQL: persists categories
- Cart persistence → PostgreSQL: persists cart
- Order persistence → PostgreSQL: persists orders
