# judoshka/stepik_fastapi_basics architecture

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

- Interactive diagram: https://gitdiagram.com/judoshka/stepik_fastapi_basics
- Repository: https://github.com/judoshka/stepik_fastapi_basics

## Overview

This repository is a FastAPI e-commerce API. Users browse and search products, register or authenticate, manage carts, and check out into orders; sellers manage products, while buyers can leave reviews that update product ratings. The graph reflects the README’s documented API capabilities and sampled route behavior; category and cart implementations were not sampled, so their internal wiring is shown only where supported by the application structure.

Main entry points: [`app/main.py`](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/main.py) (FastAPI app), [`app/db_depends.py`](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/db_depends.py) (Session dependency), [`app/models`](https://github.com/judoshka/stepik_fastapi_basics/tree/main/app/models) (ORM models), [`app/routers/products.py`](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/products.py) (Product routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_app["FastAPI app<br/>[main.py]"]
  node_schemas["Request validation<br/>[schemas.py]"]
end

subgraph group_commerce["Commerce domains"]
  node_products["Product routes<br/>[products.py]"]
  node_categories["Category routes<br/>[categories.py]"]
  node_cart["Cart routes<br/>[cart.py]"]
  node_orders["Order routes<br/>[orders.py]"]
  node_reviews["Review routes<br/>[reviews.py]"]
  node_rating["Rating service<br/>[services.py]"]
  node_media[("Product images")]
end

subgraph group_identity["Identity and access"]
  node_users["User routes<br/>[users.py]"]
  node_auth["Authentication<br/>[auth.py]"]
end

subgraph group_persistence["Persistence"]
  node_dbdep["Session dependency<br/>[db_depends.py]"]
  node_models["ORM models"]
  node_database[("SQL database<br/>[database.py]")]
end

node_client(("Buyer or seller"))

node_client -->|"sends requests"| node_app
node_app -->|"dispatches"| node_products
node_app -->|"dispatches"| node_categories
node_app -->|"dispatches"| node_cart
node_app -->|"dispatches"| node_orders
node_app -->|"dispatches"| node_reviews
node_app -->|"dispatches"| node_users
node_products -->|"validates with"| node_schemas
node_categories -->|"validates with"| node_schemas
node_cart -->|"validates with"| node_schemas
node_orders -->|"validates with"| node_schemas
node_reviews -->|"validates with"| node_schemas
node_users -->|"validates with"| node_schemas
node_products -->|"obtains sessions"| node_dbdep
node_categories -->|"obtains sessions"| node_dbdep
node_cart -->|"obtains sessions"| node_dbdep
node_orders -->|"obtains sessions"| node_dbdep
node_reviews -->|"obtains sessions"| node_dbdep
node_users -->|"obtains sessions"| node_dbdep
node_dbdep -->|"opens sessions"| node_database
node_products -->|"queries and updates"| node_models
node_categories -->|"queries and updates"| node_models
node_cart -->|"queries and updates"| node_models
node_orders -->|"queries and updates"| node_models
node_reviews -->|"queries and updates"| node_models
node_users -->|"queries and updates"| node_models
node_models -->|"persists records"| node_database
node_products -->|"stores and removes images"| node_media
node_app -->|"serves static files"| node_media
node_users -->|"creates tokens"| node_auth
node_products -->|"checks seller role"| node_auth
node_reviews -->|"checks buyer or user"| node_auth
node_cart -->|"authenticates requests"| node_auth
node_orders -->|"authenticates requests"| node_auth
node_auth -->|"loads current user"| node_dbdep
node_reviews -->|"recalculates rating"| node_rating
node_rating -->|"reads reviews; updates product"| node_database

click node_app "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/main.py"
click node_products "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/products.py"
click node_categories "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/categories.py"
click node_cart "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/cart.py"
click node_orders "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/orders.py"
click node_reviews "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/reviews.py"
click node_users "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/users.py"
click node_auth "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/auth.py"
click node_rating "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/services.py"
click node_schemas "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/schemas.py"
click node_dbdep "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/db_depends.py"
click node_models "https://github.com/judoshka/stepik_fastapi_basics/tree/main/app/models"
click node_database "https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/database.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_app,node_schemas toneBlue
class node_products,node_categories,node_cart,node_orders,node_reviews,node_rating,node_media toneAmber
class node_users,node_auth toneMint
class node_dbdep,node_models,node_database toneRose
class node_client toneIndigo
```

## Components

### API routing

- [FastAPI app](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/main.py): `app/main.py`
- [Request validation](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/schemas.py): `app/schemas.py`

### Commerce domains

- [Product routes](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/products.py): `app/routers/products.py`
- [Category routes](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/categories.py): `app/routers/categories.py`
- [Cart routes](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/cart.py): `app/routers/cart.py`
- [Order routes](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/orders.py): `app/routers/orders.py`
- [Review routes](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/reviews.py): `app/routers/reviews.py`
- [Rating service](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/services.py): `app/services.py`
- **Product images**

### Identity and access

- [User routes](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/routers/users.py): `app/routers/users.py`
- [Authentication](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/auth.py): `app/auth.py`

### Persistence

- [Session dependency](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/db_depends.py): `app/db_depends.py`
- [ORM models](https://github.com/judoshka/stepik_fastapi_basics/tree/main/app/models): `app/models`
- [SQL database](https://github.com/judoshka/stepik_fastapi_basics/blob/main/app/database.py): `app/database.py`

### Other components

- **Buyer or seller**

## Connections

- Buyer or seller → FastAPI app: sends requests
- FastAPI app → Product routes: dispatches
- FastAPI app → Category routes: dispatches
- FastAPI app → Cart routes: dispatches
- FastAPI app → Order routes: dispatches
- FastAPI app → Review routes: dispatches
- FastAPI app → User routes: dispatches
- Product routes → Request validation: validates with
- Category routes → Request validation: validates with
- Cart routes → Request validation: validates with
- Order routes → Request validation: validates with
- Review routes → Request validation: validates with
- User routes → Request validation: validates with
- Product routes → Session dependency: obtains sessions
- Category routes → Session dependency: obtains sessions
- Cart routes → Session dependency: obtains sessions
- Order routes → Session dependency: obtains sessions
- Review routes → Session dependency: obtains sessions
- User routes → Session dependency: obtains sessions
- Session dependency → SQL database: opens sessions
- Product routes → ORM models: queries and updates
- Category routes → ORM models: queries and updates
- Cart routes → ORM models: queries and updates
- Order routes → ORM models: queries and updates
- Review routes → ORM models: queries and updates
- User routes → ORM models: queries and updates
- ORM models → SQL database: persists records
- Product routes → Product images: stores and removes images
- FastAPI app → Product images: serves static files
- User routes → Authentication: creates tokens
- Product routes → Authentication: checks seller role
- Review routes → Authentication: checks buyer or user
- Cart routes → Authentication: authenticates requests
- Order routes → Authentication: authenticates requests
- Authentication → Session dependency: loads current user
- Review routes → Rating service: recalculates rating
- Rating service → SQL database: reads reviews; updates product
