# mehmethandoru/e-grocery architecture

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

- Interactive diagram: https://gitdiagram.com/mehmethandoru/e-grocery
- Repository: https://github.com/mehmethandoru/e-grocery

## Overview

##### Main System Components

Frontend Layer:
- Next.js App Router architecture
- Pages (Home, Cart, Checkout, Category, Search)
- Components organization (common, products, categories)

API Layer:
- In the middle
- Next.js API routes
- Supabase service integration
- Email service integration

Backend Services:
- At the bottom
- Supabase database
- SMTP email service

##### Component Relationships

Client-Side Flow:
- How pages interact with components
- Data flow between components and API layers
- Demonstrate the cart state management

Server-Side Flow:
- API routes connection to Supabase services
- Email service integration
- Data access patterns

##### Specific Implementation Details

Data Services:
**┌─ Supabase Services ─────┐**
- Category Service      │
- Product Service      │
- Rating Service       │
- Subscriber Service   │
- ┘

Frontend Components:
**┌─ Core Components ──────┐**
- Product Cards        │
- Cart Management     │
- Payment Forms       │
- Navigation          │
- ┘

##### Important Elements

- Authentication flow
- Database access layers
- API endpoint routing
- Component hierarchy
- State management flow
- Email service integration

##### Technical Stack Highlights

- Next.js 13+ (App Router)
- Supabase
- SMTP Email Service
- TailwindCSS

##### Data Flow Patterns

Illustrate:
- Client-side navigation
- Server-side rendering paths
- API request handling
- Database queries
- Email notifications

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        HomePage["Home Page"]:::page
        CartPage["Cart Page"]:::page
        CheckoutPage["Checkout Page"]:::page
        CategoryPage["Category Page"]:::page
        SearchPage["Search Page"]:::page

        subgraph CoreComponents
            ProductCard["Product Cards"]:::component
            CartManagement["Cart Management"]:::component
            PaymentForm["Payment Forms"]:::component
            Navigation["Navigation"]:::component
        end

        subgraph CommonComponents
            Footer["Footer"]:::common
            Loader["Loading State"]:::common
            Pagination["Pagination"]:::common
        end

        subgraph ProductComponents
            ProductDetail["Product Detail"]:::component
            ProductRating["Product Rating"]:::component
            LastViewed["Last Viewed Products"]:::component
        end
    end

    subgraph APILayer
        subgraph SupabaseServices
            CategoryService["Category Service"]:::service
            ProductService["Product Service"]:::service
            RatingService["Rating Service"]:::service
            SubscriberService["Subscriber Service"]:::service
        end

        subgraph DataAccess
            CategoriesAccess["Categories Access"]:::dal
            ProductsAccess["Products Access"]:::dal
            RatingsAccess["Ratings Access"]:::dal
            SubscribersAccess["Subscribers Access"]:::dal
        end

        subgraph EmailSystem
            EmailTemplates["Email Templates"]:::email
            EmailConfig["Email Configuration"]:::email
            SubscribeAPI["Subscribe API Route"]:::api
        end

        subgraph Config
            SupabaseConfig["Supabase Config"]:::config
            EnvConstants["Environment Constants"]:::config
        end
    end

    subgraph ExternalServices
        SupabaseDB[(Supabase DB)]:::external
        SMTPService["SMTP Service"]:::external
    end

    %% Relationships
    HomePage --> CoreComponents
    CartPage --> CartManagement
    CheckoutPage --> PaymentForm
    CategoryPage --> ProductComponents
    SearchPage --> ProductComponents

    CoreComponents --> SupabaseServices
    ProductComponents --> SupabaseServices

    SupabaseServices --> DataAccess
    DataAccess --> SupabaseDB
    EmailSystem --> SMTPService

    %% Styles
    classDef page fill:#e1f5fe,stroke:#01579b
    classDef component fill:#e8f5e9,stroke:#2e7d32
    classDef common fill:#fff3e0,stroke:#ff6f00
    classDef service fill:#f3e5f5,stroke:#7b1fa2
    classDef dal fill:#fce4ec,stroke:#c2185b
    classDef email fill:#fff8e1,stroke:#ffa000
    classDef api fill:#e8eaf6,stroke:#3f51b5
    classDef config fill:#efebe9,stroke:#5d4037
    classDef external fill:#b2dfdb,stroke:#00695c

    %% Click Events
    click HomePage "https://github.com/MehmethanDoru/e-grocery/blob/master/src/app/page.js"
    click CartPage "https://github.com/MehmethanDoru/e-grocery/blob/master/src/app/cart/page.js"
    click CheckoutPage "https://github.com/MehmethanDoru/e-grocery/blob/master/src/app/checkout/page.js"
    click CategoryPage "https://github.com/MehmethanDoru/e-grocery/blob/master/src/app/category/[categoryName]/page.js"
    click SearchPage "https://github.com/MehmethanDoru/e-grocery/blob/master/src/app/search/page.js"
    click ProductCard "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/Product-Card.js"
    click CartManagement "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/Cart-Items.js"
    click PaymentForm "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/Payment-Form.js"
    click Navigation "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/common/Navbar.js"
    click Footer "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/common/Footer.js"
    click Loader "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/common/Loader.js"
    click Pagination "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/common/Pagination.js"
    click ProductDetail "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/product-detail/ProductDetail.js"
    click ProductRating "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/product-detail/ProductRating.js"
    click LastViewed "https://github.com/MehmethanDoru/e-grocery/blob/master/src/components/products/Last-Viewed-Products.js"
    click CategoryService "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/services/categoryService.js"
    click ProductService "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/services/productService.js"
    click RatingService "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/services/ratingService.js"
    click SubscriberService "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/services/subscriberService.js"
    click CategoriesAccess "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/access-layers/categories.js"
    click ProductsAccess "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/access-layers/products.js"
    click RatingsAccess "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/access-layers/ratings.js"
    click SubscribersAccess "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/supabase/access-layers/subscribers.js"
    click EmailTemplates "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/email/templates/welcome.js"
    click EmailConfig "https://github.com/MehmethanDoru/e-grocery/blob/master/src/config/email.js"
    click SubscribeAPI "https://github.com/MehmethanDoru/e-grocery/blob/master/src/app/api/subscribe/route.js"
    click SupabaseConfig "https://github.com/MehmethanDoru/e-grocery/blob/master/src/config/supabase.js"
    click EnvConstants "https://github.com/MehmethanDoru/e-grocery/blob/master/src/api/constants/env.js"
```
