# gothan15/sgb_react architecture

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

- Interactive diagram: https://gitdiagram.com/gothan15/sgb_react
- Repository: https://github.com/gothan15/sgb_react

## Overview

##### Main Components

A. Frontend Layer:
- React Application (Vite-based)
- Component Structure:
- Authentication Components
- Dashboard Components (Admin, Librarian, User)
- UI Components
- Dialog Components
- Tab Components

B. Backend Services:
- Firebase Services:
- Authentication
- Firestore Database
- Firebase Functions
- Firebase Hosting

C. External Services:
- Cloudinary (for image management)

**[Client Layer]**
- ↑↓
**[Service Layer]**
- ↑↓
**[Data Layer]**

##### Detailed Component Breakdown

Client Layer (Top):

- React Frontend     |

- Auth Module    |  |
- User Dashboard |  |
- Admin Panel    |  |
- Library Module |  |

Service Layer (Middle):

- Firebase Services    |

- Authentication    |  |
- Cloud Functions   |  |
- Real-time Updates |  |

Data Layer (Bottom):

- Data Storage         |

- Firestore DB      |  |
- User Data         |  |
- Book Catalog      |  |
- Transactions      |  |

##### Key Flows to Highlight

a. User Authentication Flow:
**Login/Register → Firebase Auth → User Context → Dashboard**

b. Book Management Flow:
**Book Actions → Firebase Functions → Firestore → Real-time Updates**

c. Admin Operations Flow:
**Admin Panel → Security Rules → Database Operations**

##### Technical Stack Callouts

- React 18 + Vite
- TailwindCSS + Shadcn/ui
- Firebase Services
- Additional libraries (Tanstack Table, Framer Motion, etc.)

##### Deployment Flow

CI/CD pipeline:
**GitHub → GitHub Actions → Firebase Hosting**

Remember to:
- Use clear, consistent iconography
- Version information
- Document all integration points
- Security boundaries
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[React Frontend]
        AC[Authentication Components]
        AD[Admin Dashboard]
        LD[Librarian Dashboard]
        UD[User Dashboard]
        UI[UI Components]
        DG[Dialog System]
        TB[Tab System]
        UC[User Context]
    end

    subgraph Services
        FS[Firebase Services]
        FF[Firebase Functions]
        FA[Firebase Auth]
        CI[Cloudinary Integration]
    end

    subgraph Data
        FDB[(Firestore DB)]
        SR[Security Rules]
    end

    subgraph Deployment
        GH[GitHub]
        GA[GitHub Actions]
        FH[Firebase Hosting]
    end

    %% Client Layer Relationships
    FE --> AC
    FE --> AD
    FE --> LD
    FE --> UD
    FE --> UI
    FE --> DG
    FE --> TB
    FE --> UC

    %% Service Layer Relationships
    AC --> FA
    AD --> FF
    LD --> FF
    UD --> FF
    FF --> FDB
    DG --> CI

    %% Data Layer Relationships
    FF --> SR
    SR --> FDB

    %% Deployment Flow
    GH --> GA
    GA --> FH

    %% Click Events
    click AC "https://github.com/Gothan15/SGB_react/tree/main/src/components/auth/"
    click AD "https://github.com/Gothan15/SGB_react/blob/main/src/components/Admin-dashboard.jsx"
    click LD "https://github.com/Gothan15/SGB_react/blob/main/src/components/Bibliotecario-dashboard.jsx"
    click UD "https://github.com/Gothan15/SGB_react/blob/main/src/components/user-dashboard.jsx"
    click DG "https://github.com/Gothan15/SGB_react/tree/main/src/components/dialogs/"
    click UI "https://github.com/Gothan15/SGB_react/tree/main/src/components/ui/"
    click TB "https://github.com/Gothan15/SGB_react/tree/main/src/components/tabs/"
    click FF "https://github.com/Gothan15/SGB_react/tree/main/functions/"
    click CI "https://github.com/Gothan15/SGB_react/blob/main/src/utils/cloudinaryConfig.js"
    click UC "https://github.com/Gothan15/SGB_react/blob/main/src/components/UserContext.js"
    click SR "https://github.com/Gothan15/SGB_react/blob/main/firestore.rules"
    click FH "https://github.com/Gothan15/SGB_react/blob/main/.github/workflows/firebase-hosting-merge.yml"

    %% Styling
    classDef frontend fill:#3b82f6,color:white
    classDef service fill:#f97316,color:white
    classDef database fill:#8b5cf6,color:white
    classDef deployment fill:#22c55e,color:white

    class FE,AC,AD,LD,UD,UI,DG,TB,UC frontend
    class FS,FF,FA,CI service
    class FDB,SR database
    class GH,GA,FH deployment

    %% Legend
    subgraph Legend
        L1[Frontend Components]:::frontend
        L2[Services]:::service
        L3[Database]:::database
        L4[Deployment]:::deployment
    end
```
