# hac1es/friendwithbooks-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/hac1es/friendwithbooks-frontend
- Repository: https://github.com/hac1es/friendwithbooks-frontend

## Overview

##### Project Type and Purpose
- This is a single-page application (SPA) front-end built with Vue 3 and Vite.
- It provides both customer and admin views (e.g., product listings, cart, checkout, admin dashboard and CRUD interfaces).
- It relies on Supabase for authentication and database, uses Axios for any custom API calls, and is deployed as a static site (Netlify).

##### File Structure Analysis
- Top-level config & metadata:
- `package.json` / lockfile, `vite.config.js`, `tailwind.config.js`, `postcss.config.js`, `jsconfig.json`, `netlify.toml`
- Public assets:
- `public/` (favicon, static files)
- `index.html`
- Source code (`src/`):
- `main.js` – entry point, mounts Vue app
- `App.vue` – root component, hosts `<router-view/>`
- `router/index.js` – Vue Router setup with route definitions
- `store/index.js` – state management (Vuex or Pinia)
- `assets/` – global CSS and images
- `components/` – reusable UI primitives (cards, buttons, headers, filters, chat popups)
- `pages/` – route-level components (LandingPage, Products, CartView, AdminDashboard, Login, etc.)
- `composables/` – reusable logic (useFilter, useCountdown)
- `utils/` – wrappers around Axios, Supabase client, URL helpers
- Build & deployment:
- Vite handles bundling; Netlify config for CI/CD.

##### Key Architectural Patterns
- Component-based UI: small, focused components compose pages.
- Router-driven navigation: each .vue in `pages/` maps to a route.
- Centralized store: shared state (e.g., cart, user session).
- Composables for encapsulating reactive logic.
- Utility layer abstracts external service calls (Axios, Supabase).

##### Main Components & Their Relationships
- Browser / Client
↳ Serves `index.html` → loads bundled Vue app
- Vue Application
- Root (App.vue)
- Router → delegates to Page components
- Store → global state accessible by pages/components
- Composables & Utils → data-fetching, business logic
- Page Components
- Customer-facing: LandingPage, Products, ProductDetail, CartView, Checkout, Login/Signup, UserProfile
- Admin-facing: AdminDashboard, AdminProducts, OrderCRUDAdmin, StatAdmin
- Reusable Components
- UI elements (cards, headers, breadcrumb, filter panels)
- External Services
- Supabase (authentication, database)
- Any REST APIs via Axios (payment gateway, third-party integrations)
- Deployment
- Vite build → static assets → Netlify CDN

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Layer
    Browser["Browser/Client"]:::ui
    indexHTML["index.html"]:::ui
    publicDir["public/"]:::ui

    Browser -->|loads| indexHTML
    Browser -->|requests assets| publicDir

    %% Vue Application Layer
    subgraph "Vue Application"
        direction TB
        main["src/main.js"]:::config
        App["src/App.vue"]:::ui
        router["Router<br/>(Vue Router)"]:::state
        store["Store<br/>(Vuex/Pinia)"]:::state
        main -->|mounts| App
        App -->|uses| router
        App -->|uses| store
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        subgraph "Pages"
            direction TB
            subgraph "Customer Pages" 
                direction TB
                LP["LandingPage.vue"]:::ui
                Prod["Products.vue"]:::ui
                Detail["ProductDetail.vue"]:::ui
                Cart["CartView.vue"]:::ui
                Pay["PayMent.vue"]:::ui
                Login["Login.vue"]:::ui
                Reg["Register.vue"]:::ui
                Forgot["ForgotPass.vue"]:::ui
                Profile["UserProfile.vue"]:::ui
            end
            subgraph "Admin Pages"
                direction TB
                ADash["AdminDashboard.vue"]:::ui
                AProd["AdminProducts.vue"]:::ui
                OrderAdmin["OrderCRUDAdmin.vue"]:::ui
                StatAdmin["StatAdmin.vue"]:::ui
                LandingAdmin["LandingAdmin.vue"]:::ui
            end
        end
        subgraph "Components"
            direction TB
            UIComp["src/components/"]:::ui
            AdminHeader["HeaderAdmin/"]:::ui
        end
        App -->|routes to| LP
        router -->|maps routes| LP
        LP -->|composed of| UIComp
        ADash -->|composed of| AdminHeader
    end

    %% Logic Layer
    subgraph "Logic Layer"
        direction TB
        subgraph "Composables"
            direction TB
            CompFilter["useFilter.js"]:::logic
            CompCount["useCountdown.js"]:::logic
        end
        subgraph "Utils"
            direction TB
            AxiosWrap["axios.js"]:::logic
            SupabaseClient["supabase.js"]:::service
            URLHelper["urlHelper.js"]:::logic
        end
        LP -->|invokes| CompFilter
        LP -->|invokes| CompCount
        CompFilter -->|calls| AxiosWrap
        CompCount -->|calls| SupabaseClient
    end

    %% State & Routing
    store -->|state read/write| LP
    store -->|state read/write| ADash
    router -->|renders pages| LP
    router -->|renders pages| ADash

    %% External Services
    subgraph "External Services"
        direction TB
        Supabase["Supabase (Auth/DB)"]:::service
        RESTAPI["Third-Party APIs<br/>(Payment, Integrations)"]:::service
    end
    SupabaseClient -->|SDK calls| Supabase
    AxiosWrap -->|HTTP calls| RESTAPI

    %% Deployment Flow
    subgraph "Deployment"
        direction TB
        Vite["vite.config.js"]:::config
        NetlifyCfg["netlify.toml"]:::config
        Build["Vite Build"]:::config
        Netlify["Netlify CDN"]:::service
    end
    main -->|build config| Vite
    Vite -->|builds| Build
    Build -->|deploys| Netlify
    Netlify -->|serves| Browser

    %% Click Events
    click indexHTML "https://github.com/hac1es/friendwithbooks-frontend/blob/main/index.html"
    click publicDir "https://github.com/hac1es/friendwithbooks-frontend/tree/main/public/"
    click main "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/main.js"
    click App "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/App.vue"
    click router "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/router/index.js"
    click store "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/store/index.js"
    click UIComp "https://github.com/hac1es/friendwithbooks-frontend/tree/main/src/components/"
    click AdminHeader "https://github.com/hac1es/friendwithbooks-frontend/tree/main/src/components/HeaderAdmin/"
    click LP "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/LandingPage.vue"
    click Prod "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/Products.vue"
    click Detail "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/ProductDetail.vue"
    click Cart "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/CartView.vue"
    click Pay "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/PayMent.vue"
    click Login "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/Login.vue"
    click Reg "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/Register.vue"
    click Forgot "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/ForgotPass.vue"
    click Profile "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/UserProfile.vue"
    click ADash "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/AdminDashboard.vue"
    click AProd "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/AdminProducts.vue"
    click OrderAdmin "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/OrderCRUDAdmin.vue"
    click StatAdmin "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/components/StatAdmin.vue"
    click LandingAdmin "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/pages/LandingAdmin.vue"
    click CompFilter "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/composables/useFilter.js"
    click CompCount "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/composables/useCountdown.js"
    click AxiosWrap "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/utils/axios.js"
    click SupabaseClient "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/utils/supabase.js"
    click URLHelper "https://github.com/hac1es/friendwithbooks-frontend/blob/main/src/utils/urlHelper.js"
    click Vite "https://github.com/hac1es/friendwithbooks-frontend/blob/main/vite.config.js"
    click NetlifyCfg "https://github.com/hac1es/friendwithbooks-frontend/blob/main/netlify.toml"

    %% Styles
    classDef ui fill:#e3f2fd,stroke:#1976d2,stroke-width:1px
    classDef logic fill:#e8f5e9,stroke:#388e3c,stroke-width:1px
    classDef state fill:#fff3e0,stroke:#f57c00,stroke-width:1px
    classDef service fill:#eceff1,stroke:#607d8b,stroke-width:1px
    classDef config fill:#f3e5f5,stroke:#8e24aa,stroke-width:1px
```
