# sarthakdasari/codealpha_kartly architecture

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

- Interactive diagram: https://gitdiagram.com/sarthakdasari/codealpha_kartly
- Repository: https://github.com/sarthakdasari/codealpha_kartly

## Overview

Kartly is a Flask/SQLite storefront. Shoppers browse and inspect products, register or log in, manage a session-backed cart, submit a cash-on-delivery order, and review order history. The browser modules call JSON endpoints through a shared CSRF-aware API client; Flask handles the domain operations and SQLite persists catalog, user, cart, and order data. The README documents category browsing, account, cart, COD, and order-history capabilities. Some template and route details are unsampled, so those links rely on the shown app excerpt or README rather than assumed implementation details.

Main entry points: [`static/js/api.js`](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/api.js) (API client), [`app.py`](https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py) (Flask app), [`schema.sql`](https://github.com/sarthakdasari/codealpha_kartly/blob/main/schema.sql) (SQLite store), [`database.py`](https://github.com/sarthakdasari/codealpha_kartly/blob/main/database.py) (Database layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Storefront browser"]
  node_page_views["Page views"]
  node_shared_ui["Shared UI<br/>[common.js]"]
  node_api_client["API client<br/>[api.js]"]
  node_product_browse["Product browsing<br/>[products.js]"]
  node_product_detail["Product details<br/>[product.js]"]
  node_account_ui["Account access<br/>[auth.js]"]
  node_cart_ui["Cart management<br/>[cart.js]"]
  node_checkout_ui["COD checkout<br/>[checkout.js]"]
  node_account_profile["Account profile<br/>[account.js]"]
  node_order_history["Order history<br/>[orders.js]"]
end

subgraph group_service["Flask services"]
  node_flask_app["Flask app<br/>[app.py]"]
  node_catalog_api["Catalog endpoints<br/>[app.py]"]
  node_identity_api["Identity endpoints<br/>[app.py]"]
  node_cart_api["Cart endpoints<br/>[app.py]"]
  node_order_api["Order endpoints<br/>[app.py]"]
end

subgraph group_persistence["SQLite persistence"]
  node_db_layer["Database layer<br/>[database.py]"]
  node_sqlite_store[("SQLite store<br/>[schema.sql]")]
  node_catalog_seed["Catalog seed<br/>[seed.py]"]
end

subgraph group_runtime["Runtime setup"]
  node_configuration["App configuration<br/>[config.py]"]
end

node_shopper(("Shopper"))

node_shopper -->|"opens pages"| node_page_views
node_page_views -.->|"loads scripts"| node_shared_ui
node_shared_ui -->|"requests identity"| node_api_client
node_product_browse -->|"fetches catalog"| node_api_client
node_product_detail -->|"fetches product"| node_api_client
node_account_ui -->|"submits credentials"| node_api_client
node_cart_ui -->|"updates cart"| node_api_client
node_checkout_ui -->|"places order"| node_api_client
node_account_profile -.->|"uses API"| node_api_client
node_order_history -.->|"uses API"| node_api_client
node_api_client -->|"sends requests"| node_flask_app
node_flask_app -->|"loads settings"| node_configuration
node_flask_app -->|"initializes database"| node_db_layer
node_flask_app -->|"routes catalog"| node_catalog_api
node_flask_app -->|"routes identity"| node_identity_api
node_flask_app -->|"routes cart"| node_cart_api
node_flask_app -->|"routes orders"| node_order_api
node_catalog_api -->|"queries catalog"| node_sqlite_store
node_identity_api -->|"reads users"| node_sqlite_store
node_cart_api -->|"reads and writes"| node_sqlite_store
node_order_api -->|"records orders"| node_sqlite_store
node_db_layer -->|"creates schema"| node_sqlite_store
node_db_layer -->|"seeds catalog"| node_catalog_seed

click node_page_views "https://github.com/sarthakdasari/codealpha_kartly/tree/main/templates"
click node_shared_ui "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/common.js"
click node_api_client "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/api.js"
click node_product_browse "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/products.js"
click node_product_detail "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/product.js"
click node_account_ui "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/auth.js"
click node_cart_ui "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/cart.js"
click node_checkout_ui "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/checkout.js"
click node_account_profile "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/account.js"
click node_order_history "https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/orders.js"
click node_flask_app "https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py"
click node_catalog_api "https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py"
click node_identity_api "https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py"
click node_cart_api "https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py"
click node_order_api "https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py"
click node_configuration "https://github.com/sarthakdasari/codealpha_kartly/blob/main/config.py"
click node_db_layer "https://github.com/sarthakdasari/codealpha_kartly/blob/main/database.py"
click node_sqlite_store "https://github.com/sarthakdasari/codealpha_kartly/blob/main/schema.sql"
click node_catalog_seed "https://github.com/sarthakdasari/codealpha_kartly/blob/main/seed.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_page_views,node_shared_ui,node_api_client,node_product_browse,node_product_detail,node_account_ui,node_cart_ui,node_checkout_ui,node_account_profile,node_order_history toneBlue
class node_flask_app,node_catalog_api,node_identity_api,node_cart_api,node_order_api toneAmber
class node_db_layer,node_sqlite_store,node_catalog_seed toneMint
class node_configuration toneRose
class node_shopper toneIndigo
```

## Components

### Storefront browser

- [Page views](https://github.com/sarthakdasari/codealpha_kartly/tree/main/templates): `templates`
- [Shared UI](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/common.js): `static/js/common.js`
- [API client](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/api.js): `static/js/api.js`
- [Product browsing](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/products.js): `static/js/products.js`
- [Product details](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/product.js): `static/js/product.js`
- [Account access](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/auth.js): `static/js/auth.js`
- [Cart management](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/cart.js): `static/js/cart.js`
- [COD checkout](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/checkout.js): `static/js/checkout.js`
- [Account profile](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/account.js): `static/js/account.js`
- [Order history](https://github.com/sarthakdasari/codealpha_kartly/blob/main/static/js/orders.js): `static/js/orders.js`

### Flask services

- [Flask app](https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py): `app.py`
- [Catalog endpoints](https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py): `app.py`
- [Identity endpoints](https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py): `app.py`
- [Cart endpoints](https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py): `app.py`
- [Order endpoints](https://github.com/sarthakdasari/codealpha_kartly/blob/main/app.py): `app.py`

### SQLite persistence

- [Database layer](https://github.com/sarthakdasari/codealpha_kartly/blob/main/database.py): `database.py`
- [SQLite store](https://github.com/sarthakdasari/codealpha_kartly/blob/main/schema.sql): `schema.sql`
- [Catalog seed](https://github.com/sarthakdasari/codealpha_kartly/blob/main/seed.py): `seed.py`

### Runtime setup

- [App configuration](https://github.com/sarthakdasari/codealpha_kartly/blob/main/config.py): `config.py`

### Other components

- **Shopper**

## Connections

- Shopper → Page views: opens pages
- Page views → Shared UI: loads scripts
- Shared UI → API client: requests identity (evidence: `static/js/common.js`)
- Product browsing → API client: fetches catalog (evidence: `static/js/products.js`)
- Product details → API client: fetches product (evidence: `static/js/product.js`)
- Account access → API client: submits credentials (evidence: `static/js/auth.js`)
- Cart management → API client: updates cart (evidence: `static/js/cart.js`)
- COD checkout → API client: places order (evidence: `static/js/checkout.js`)
- Account profile → API client: uses API
- Order history → API client: uses API
- API client → Flask app: sends requests (evidence: `static/js/api.js`)
- Flask app → App configuration: loads settings (evidence: `app.py`)
- Flask app → Database layer: initializes database (evidence: `app.py`)
- Flask app → Catalog endpoints: routes catalog (evidence: `app.py`)
- Flask app → Identity endpoints: routes identity (evidence: `app.py`)
- Flask app → Cart endpoints: routes cart (evidence: `app.py`)
- Flask app → Order endpoints: routes orders (evidence: `app.py`)
- Catalog endpoints → SQLite store: queries catalog (evidence: `app.py`)
- Identity endpoints → SQLite store: reads users (evidence: `app.py`)
- Cart endpoints → SQLite store: reads and writes (evidence: `app.py`)
- Order endpoints → SQLite store: records orders (evidence: `app.py`)
- Database layer → SQLite store: creates schema (evidence: `database.py`)
- Database layer → Catalog seed: seeds catalog (evidence: `database.py`)
