# ashnasiddiqi/library architecture

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

- Interactive diagram: https://gitdiagram.com/ashnasiddiqi/library
- Repository: https://github.com/ashnasiddiqi/library

## Overview

##### Project type and purpose
- This is a full-stack JavaScript/TypeScript web application.
- Frontend: React + TypeScript, built with Vite.
- Backend: Node.js + Express, serving API endpoints.
- Database: relational SQL (schema provided in library_db.sql).

##### File structure
- Top-level directories:
- backendProject: contains server code
- public: static assets for frontend
- src: React application source
- Config files at root:
- vite.config.ts, tsconfig*.json, eslint.config.js, package*.json for frontend
- backendProject/package*.json, backendProject/src define the API.
- library_db.sql defines the database schema.
- Routes in backendProject/src/routes follow a modular pattern (books.js, etc.).

##### Key insights from README
- The frontend uses Vite + React + TypeScript with HMR.
- ESLint is configured for type-aware linting.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["Browser"]:::client
        Vite["Vite Dev Server / Static Host (port 5173)"]:::frontend
        subgraph "React Application"
            direction TB
            Entry["main.tsx"]:::frontend
            App["App.tsx"]:::frontend
            subgraph "Components"
                direction TB
                Main["Main.tsx"]:::frontend
                Card["Card.tsx"]:::frontend
                Modal["Modal.tsx"]:::frontend
            end
        end
        subgraph "Public Assets"
            direction TB
            PublicDir["public/"]:::frontend
            Index["index.html"]:::frontend
        end
        subgraph "Frontend Configs"
            direction TB
            ViteConfig["vite.config.ts"]:::config
            TSConfig["tsconfig.json"]:::config
            TSApp["tsconfig.app.json"]:::config
            TSNode["tsconfig.node.json"]:::config
            ESLintFE["eslint.config.js"]:::config
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        ExpressEntry["hw2.js"]:::backend
        subgraph "Routes Module"
            direction TB
            BooksRoute["books.js"]:::backend
        end
        DBLayer["db.js"]:::backend
        subgraph "Backend Configs"
            direction TB
            BackendPkg["package.json"]:::config
            BackendLock["package-lock.json"]:::config
        end
    end

    %% Database
    Database["SQL Database"]:::database
    Schema["library_db.sql"]:::database

    %% Connections
    Browser -->|"HTTP GET static assets"| Vite
    Vite -->|"Serves index.html & JS"| Browser
    Browser -->|"REST API calls (GET/POST)"| ExpressEntry
    ExpressEntry -->|"uses routes"| BooksRoute
    BooksRoute -->|"executes queries"| DBLayer
    DBLayer -->|"SQL queries"| Database
    Database -->|"initialized by"| Schema

    %% Click Events
    click Entry "https://github.com/ashnasiddiqi/library/blob/main/src/main.tsx"
    click App "https://github.com/ashnasiddiqi/library/blob/main/src/App.tsx"
    click Main "https://github.com/ashnasiddiqi/library/blob/main/src/components/Main.tsx"
    click Card "https://github.com/ashnasiddiqi/library/blob/main/src/components/Card.tsx"
    click Modal "https://github.com/ashnasiddiqi/library/blob/main/src/components/Modal.tsx"
    click PublicDir "https://github.com/ashnasiddiqi/library/tree/main/public/"
    click Index "https://github.com/ashnasiddiqi/library/blob/main/index.html"
    click ViteConfig "https://github.com/ashnasiddiqi/library/blob/main/vite.config.ts"
    click TSConfig "https://github.com/ashnasiddiqi/library/blob/main/tsconfig.json"
    click TSApp "https://github.com/ashnasiddiqi/library/blob/main/tsconfig.app.json"
    click TSNode "https://github.com/ashnasiddiqi/library/blob/main/tsconfig.node.json"
    click ESLintFE "https://github.com/ashnasiddiqi/library/blob/main/eslint.config.js"
    click ExpressEntry "https://github.com/ashnasiddiqi/library/blob/main/backendProject/src/hw2.js"
    click BooksRoute "https://github.com/ashnasiddiqi/library/blob/main/backendProject/src/routes/books.js"
    click DBLayer "https://github.com/ashnasiddiqi/library/blob/main/backendProject/src/db.js"
    click BackendPkg "https://github.com/ashnasiddiqi/library/blob/main/backendProject/package.json"
    click BackendLock "https://github.com/ashnasiddiqi/library/blob/main/backendProject/package-lock.json"
    click Schema "https://github.com/ashnasiddiqi/library/blob/main/library_db.sql"

    %% Styles
    classDef client fill:#D1C4E9,stroke:#7E57C2,color:#000
    classDef frontend fill:#BBDEFB,stroke:#2196F3,color:#000
    classDef backend fill:#C8E6C9,stroke:#4CAF50,color:#000
    classDef database fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef config fill:#E0E0E0,stroke:#9E9E9E,color:#000
```
