# brighteyekid/tsc-store architecture

> Architecture diagram of the GitHub repository brighteyekid/tsc-store, 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/brighteyekid/tsc-store
- Repository: https://github.com/brighteyekid/tsc-store

## Overview

##### Main System Components

a) Client-Side (Frontend):
- Components Layer (UI Components)
- Context Layer (Region Context)
- Routing Layer (React Router)
- Hooks Layer (Custom Hooks)
- Assets & Utils

b) Backend Services:
- Authentication
- Firestore Database
- Storage
- Security Rules

##### Component Organization
Create sub-sections within the frontend container showing:

a) Core Components:
- Public Components (Navbar, Footer, ProductCard)
- Protected Components (Admin Dashboard)
- Route Guards (AdminRouteGuard, ProtectedRoute)

b) Feature Modules:
- Products Management
- Categories Management
- Collections Management
- Region Management

##### Data Flow Visualization
- User authentication flow
- Product data retrieval
- Admin operations
- Region-based content delivery

##### Specific Implementation Details

**User Interface Layer**
**↓↑**
**Context & Hooks Layer (RegionContext, useProducts)**
**↓↑**
**Firebase Services Layer**

##### Important Elements

a) Authentication Flow:
**User → Login Component → Firebase Auth → Admin Dashboard**

b) Data Management Flow:
**Products Manager → Firebase Firestore ← Product Display**

c) Region-Based Logic:
**Region Selector → Region Context → Content Delivery**

##### Technical Stack Indicators
Technology badges or labels for:
- React
- Firebase
- Tailwind CSS
- TypeScript
- React Router

##### Security Layer Representation
Security implementations:
- Protected Routes
- Admin Guards
- Firebase Security Rules

##### Key Interactions
Flows:
- User authentication
- Product management
- Region-based content delivery
- Admin operations

##### Environment Configuration
A section showing configuration dependencies:
- Firebase Config
- Environment Variables
- Admin Access Control

Remember to:
- Brief descriptions for complex interactions
- Both synchronous and asynchronous operations
- Public vs. protected routes
- Separation of concerns

This will provide a clear understanding of how the various components interact while maintaining the region-based e-commerce functionality at its core.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI[User Interface Layer]
        
        subgraph Components
            direction TB
            PublicComp[Public Components]
            ProtectedComp[Protected Components]
            Guards[Route Guards]
            
            subgraph Public["Public Components Details"]
                direction TB
                Nav["Navbar"]:::file
                Foot["Footer"]:::file
                PCard["Product Card"]:::file
                RegSel["Region Selector"]:::file
                PFilter["Product Filters"]:::file
            end
            
            subgraph Protected["Protected Components Details"]
                direction TB
                AdminDash["Admin Dashboard"]:::file
                ProdMan["Products Manager"]:::file
                CatMan["Categories Manager"]:::file
                CollMan["Collections Manager"]:::file
                ProdForm["Product Form"]:::file
            end
            
            subgraph GuardDetails["Guard Components"]
                direction TB
                AdminGuard["Admin Route Guard"]:::file
                ProtRoute["Protected Route"]:::file
            end
        end
        
        subgraph Context
            RegContext["Region Context"]:::file
        end
        
        subgraph Hooks
            ProdHooks["Products Hook"]:::file
        end
        
        subgraph Pages
            direction TB
            HomePage["Home Page"]:::file
            ProdPage["Products Page"]:::file
            LoginPage["Login Page"]:::file
        end
        
        subgraph Utils
            AdminUtils["Admin Utilities"]:::file
        end
        
        subgraph Types
            direction TB
            ProdTypes["Product Types"]:::file
            CollTypes["Collection Types"]:::file
        end
    end
    
    subgraph Firebase["Firebase Services"]
        direction TB
        Auth["Authentication"]
        Firestore["Firestore Database"]
        Storage["Storage"]
        Rules["Security Rules"]
        FBConfig["Firebase Config"]:::file
    end
    
    %% Connections
    UI --> Components
    Components --> Context
    Components --> Hooks
    Context --> Firebase
    Hooks --> Firebase
    Guards --> Auth
    ProtectedComp --> Auth
    
    %% Click events
    click Nav "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/Navbar.tsx"
    click Foot "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/Footer.tsx"
    click PCard "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/ProductCard.tsx"
    click RegSel "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/RegionSelector.tsx"
    click AdminDash "https://github.com/brighteyekid/TSC-STORE/blob/main/src/pages/Admin/Dashboard.tsx"
    click ProdMan "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/admin/ProductsManager.tsx"
    click CatMan "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/admin/CategoriesManager.tsx"
    click CollMan "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/CollectionsManager.tsx"
    click AdminGuard "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/AdminRouteGuard.tsx"
    click ProtRoute "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/ProtectedRoute.tsx"
    click RegContext "https://github.com/brighteyekid/TSC-STORE/blob/main/src/context/RegionContext.tsx"
    click ProdHooks "https://github.com/brighteyekid/TSC-STORE/blob/main/src/hooks/useProducts.ts"
    click LoginPage "https://github.com/brighteyekid/TSC-STORE/blob/main/src/pages/Admin/Login.tsx"
    click ProdTypes "https://github.com/brighteyekid/TSC-STORE/blob/main/src/types/product.ts"
    click CollTypes "https://github.com/brighteyekid/TSC-STORE/blob/main/src/types/collection.ts"
    click FBConfig "https://github.com/brighteyekid/TSC-STORE/blob/main/src/config/firebase.ts"
    click PFilter "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/products/ProductFilters.tsx"
    click ProdForm "https://github.com/brighteyekid/TSC-STORE/blob/main/src/components/admin/ProductForm.tsx"
    click AdminUtils "https://github.com/brighteyekid/TSC-STORE/blob/main/src/utils/adminUtils.ts"
    click HomePage "https://github.com/brighteyekid/TSC-STORE/blob/main/src/pages/Home.tsx"
    click ProdPage "https://github.com/brighteyekid/TSC-STORE/blob/main/src/pages/Products.tsx"
    
    %% Styling
    classDef file fill:#f9f,stroke:#333,stroke-width:2px
    classDef default fill:#fff,stroke:#333,stroke-width:2px
    
    %% Legend
    subgraph Legend
        direction TB
        L1["Component"]
        L2["File Component"]:::file
    end
```
