# keshavadk/bookstore_app architecture

> Architecture diagram of the GitHub repository keshavadk/bookstore_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/keshavadk/bookstore_app
- Repository: https://github.com/keshavadk/bookstore_app

## Overview

##### Project type and purpose
- This is a simple full-stack dashboard application (“Bookstore Dashboard”)
- Frontend: Streamlit UI (frontend/app.py)
- Backend: FastAPI REST service (backend/main.py)
- Database: SQLite (backend/database.py + insert_dummy_data.py)

##### File structure
- Top-level:
- backend/ → FastAPI code & DB schema
- frontend/ → Streamlit app
- insert_dummy_data.py → script to seed SQLite
- requirements.txt → Python dependencies
- backend/main.py exposes HTTP endpoints, backend/database.py defines models and DB connection
- frontend/app.py uses Streamlit to call the FastAPI endpoints and render results

##### README for additional insights
- Confirms the use of nested JSON responses
- Highlights three core technologies: Streamlit (UI), FastAPI (API), SQLite (DB)
- Describes features: Authors, Books, Categories relations

a. Main components
- Streamlit Dashboard (frontend)
- FastAPI Service (backend API)
- SQLite Database (data store)
- Data Initialization Script (insert_dummy_data.py)
b. Relationships and data flows
1. Streamlit UI sends HTTP requests (GET/POST) → FastAPI endpoints
2. FastAPI handler invokes database.py functions → queries SQLite
3. SQLite returns records → FastAPI assembles nested JSON → returns to UI
4. UI parses JSON → displays tables/charts
5. (Offline) insert_dummy_data.py connects directly to SQLite to seed initial data
c. Architectural patterns / design principles
- Separation of concerns: UI layer vs. API layer vs. data layer
- RESTful service design returning nested JSON
- Single-file embedded database (SQLite) for simplicity
d. Key technologies / frameworks
- Streamlit (python streamlit.app)
- FastAPI (uvicorn/asgi)
- SQLite (sqlite3 or SQLAlchemy)
- Python requirements (listed in requirements.txt)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["Streamlit UI\n(port 8501)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["FastAPI API\n(port 8000)"]:::backend
    end

    %% Database
    DB["SQLite DB\n(bookstore.db)\n• Authors\n• Books\n• Categories"]:::db

    %% Utility Scripts and Documentation
    UTIL["Seed Script\n(insert_dummy_data.py)"]:::util
    REQ["requirements.txt"]:::note
    MD["README.md"]:::note

    %% Connections
    UI -->|"HTTP REST (GET/POST)"| API
    API -->|"SQL Query"| DB
    DB -->|"Result Set"| API
    API -->|"Nested JSON"| UI
    UTIL -->|"Direct SQL Writes"| DB

    %% Click Events
    click UI "https://github.com/keshavadk/bookstore_app/blob/main/frontend/app.py"
    click API "https://github.com/keshavadk/bookstore_app/blob/main/backend/main.py"
    click DB "https://github.com/keshavadk/bookstore_app/blob/main/backend/database.py"
    click UTIL "https://github.com/keshavadk/bookstore_app/blob/main/insert_dummy_data.py"
    click REQ "https://github.com/keshavadk/bookstore_app/blob/main/requirements.txt"
    click MD "https://github.com/keshavadk/bookstore_app/blob/main/README.md"

    %% Styles
    classDef frontend fill:#d0e7ff,stroke:#0366d6,color:#0366d6,stroke-width:2px;
    classDef backend fill:#e6ffe6,stroke:#28a745,color:#28a745,stroke-width:2px;
    classDef db fill:#ffe5b4,stroke:#d9822b,color:#d9822b,stroke-width:2px,shape:cylinder;
    classDef util fill:#f0f0f0,stroke:#999999,color:#555555,stroke-width:1px;
    classDef note fill:#fff5f5,stroke:#d73a49,color:#d73a49,stroke-width:1px;font-style:italic;
```
