# panduthegang/library-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/panduthegang/library-management-system
- Repository: https://github.com/panduthegang/library-management-system

## Overview

##### Project Type and Purpose
- The project is a modern, full-stack library management system. Even though most of the code lives on the frontend using React with TypeScript, the application integrates with Firebase (Firestore and Authentication) to handle backend functionalities. The system is designed to manage books, user borrowings, and includes role-based access controls for admin and users.
- Key features include authentication, book catalog management, real-time availability tracking, and separate dashboards for Admin and User roles.

##### Analyzing the File Structure
- At the project’s root, you see essential configuration files (e.g., .env, package.json, vite.config.ts, etc.) which set up the build process and environment.
- The src directory contains:
- Main application files (App.tsx, main.tsx, index.css) serving as the entry point.
- A components folder that encapsulates reusable UI components like Navbar, Sidebar, and specialized forms (e.g., AddBookForm) plus utility components (SkeletonLoader, SuccessConfetti).
- A pages folder that represents distinct application routes (AdminDashboard, UserDashboard, Login, Register) which help enforce role-based views.
- A config directory with firebase.ts, clearly outlining integration with Firebase services.
- Utility functions (src/utils) for handling authentication and book-related logic.
- Custom hooks (src/hooks) to handle browser events like window resizing.

##### Elements
- Frontend Components (rectangles)
- Separation between role-specific components (Admin vs. User) if necessary.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend - Pages
    subgraph "Frontend - Pages"
        ADP["Admin Dashboard Page"]:::frontend
        UDP["User Dashboard Page"]:::frontend
        LP["Login Page"]:::frontend
        RP["Register Page"]:::frontend
    end

    %% Frontend - UI Components
    subgraph "Frontend - UI Components"
        NB["Navbar Component"]:::frontend
        SB["Sidebar Component"]:::frontend
        ABF["AddBookForm Component"]:::frontend
        PR["ProtectedRoute Component"]:::frontend
        SL["SkeletonLoader"]:::frontend
        SC["SuccessConfetti"]:::frontend
    end

    %% Frontend - Hooks
    subgraph "Frontend - Hooks"
        WH["Custom Hook for Window Resizing"]:::frontend
    end

    %% Utilities
    subgraph "Utilities"
        AU["Authentication Utility Functions"]:::utility
        BM["Books Management Utility Functions"]:::utility
    end

    %% Configuration
    subgraph "Configuration"
        FC["Firebase Configuration (Authentication & Firestore)"]:::config
    end

    %% Backend - Firebase Services
    subgraph "Backend - Firebase Services"
        FAuth["Firebase Authentication Service"]:::backend
        FStore["Firestore Database"]:::backend
    end

    %% Connections from Pages to ProtectedRoute component (for secure routing)
    LP -->|"uses"| PR
    RP -->|"uses"| PR
    ADP -->|"securedBy"| PR
    UDP -->|"securedBy"| PR

    %% Pages interacting with UI components
    ADP -->|"includes"| NB
    ADP -->|"includes"| SB
    ADP -->|"includes"| ABF
    UDP -->|"includes"| NB
    UDP -->|"includes"| SB

    %% UI Components depending on hooks
    NB -->|"responsiveWith"| WH
    SB -->|"responsiveWith"| WH

    %% Pages triggering utility functions
    LP -->|"triggers"| AU
    RP -->|"triggers"| AU
    ADP -->|"managesBooks"| BM
    UDP -->|"managesBooks"| BM

    %% Utilities use Firebase configuration for backend operations
    AU -->|"configuredBy"| FC
    BM -->|"configuredBy"| FC

    %% Firebase configuration interacts with Firebase services (bidirectional for real-time updates)
    FC <-->|"integratesWith"| FAuth
    FC <-->|"integratesWith"| FStore

    %% UI Feedback Components used in pages/components
    ADP -->|"displays"| SL
    ADP -->|"displays"| SC
    UDP -->|"displays"| SL
    UDP -->|"displays"| SC

    %% Click Events
    click ADP "https://github.com/panduthegang/library-management-system/blob/main/src/pages/AdminDashboard.tsx"
    click UDP "https://github.com/panduthegang/library-management-system/blob/main/src/pages/UserDashboard.tsx"
    click LP "https://github.com/panduthegang/library-management-system/blob/main/src/pages/Login.tsx"
    click RP "https://github.com/panduthegang/library-management-system/blob/main/src/pages/Register.tsx"
    click NB "https://github.com/panduthegang/library-management-system/blob/main/src/components/Navbar.tsx"
    click SB "https://github.com/panduthegang/library-management-system/blob/main/src/components/Sidebar.tsx"
    click ABF "https://github.com/panduthegang/library-management-system/blob/main/src/components/AddBookForm.tsx"
    click PR "https://github.com/panduthegang/library-management-system/blob/main/src/components/ProtectedRoute.tsx"
    click FC "https://github.com/panduthegang/library-management-system/blob/main/src/config/firebase.ts"
    click AU "https://github.com/panduthegang/library-management-system/blob/main/src/utils/auth.ts"
    click BM "https://github.com/panduthegang/library-management-system/blob/main/src/utils/books.ts"
    click WH "https://github.com/panduthegang/library-management-system/blob/main/src/hooks/useWindowSize.ts"
    click SL "https://github.com/panduthegang/library-management-system/blob/main/src/components/SkeletonLoader.tsx"
    click SC "https://github.com/panduthegang/library-management-system/blob/main/src/components/SuccessConfetti.tsx"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef backend fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef config fill:#c2e699,stroke:#333,stroke-width:2px;
    classDef utility fill:#ffffcc,stroke:#333,stroke-width:2px;
```
