# kuldeepyeware/fooder_ecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/kuldeepyeware/fooder_ecommerce
- Repository: https://github.com/kuldeepyeware/fooder_ecommerce

## Overview

##### Main Components
- Frontend Applications:
- Customer-facing website (apps/web): Includes user authentication flows (login, registration, password reset), product browsing, shopping cart, checkout flows and payment processing.
- Admin dashboard (apps/admin): Provides order management, product management, category handling, customer queries, and potentially reporting/metrics.
- API Layers:
- Both apps expose API endpoints (under /app/api) for authentication, file uploads, and other actions. The APIs handle server-side operations integrating with authentication providers and payment processors.
- Backend and Data Layer:
- Prisma with PostgreSQL (located in packages/db): Manages data models (users, products, orders, tokens) including migrations & seeding.
- Shared Libraries and Configurations:
- UI components (packages/ui): Contains shared React components used for consistent styling and responsive behavior across both web and admin applications.
- Common tools such as ESLint and TypeScript configurations (in packages/eslint-config and packages/typescript-config) ensure code quality and consistency.
- External Services:
- Payment processing via Razorpay.
- Media storage and content delivery using AWS S3 and CloudFront.
- Authentication integrated via NextAuth and Auth0.

##### Relationships and Interactions
- The user-facing web app communicates with its API endpoints for tasks like authentication, checkout, and product queries. It also directly interfaces with the shared UI library for a consistent look and feel.
- Similarly, the admin dashboard app uses its own set of API endpoints for managing products, orders, categories, and user queries.
- Both applications interact with the common backend (Prisma/PostgreSQL) for data persistence. They might also share code patterns or even interact with the same data layer via packages/db.
- The authentication layer (NextAuth and Auth0) is integrated into the API routes which expose secure endpoints.
- Payment actions are handled through dedicated action modules (e.g., Razorpay integration endpoints) that directly interact with the Razorpay API when checkout events occur.

##### Architectural Patterns & Design Principles
- Monorepo Architecture: Leveraging Turborepo to manage multiple apps and shared packages helps enforce consistency across projects.
- Separation of Concerns: Clear division between customer and admin functionalities, segregating UI components, API routes, and business logic.
- Server Components & API Routes: Use of Next.js’s app directory encourages thin, dedicated components for views and robust API endpoints for handling server-side logic.
- Reusability: Shared UI components and common configurations ensure DRY principles.

##### Specific Elements
- Each component should be clearly labeled: for example, "Customer Website", "Admin Dashboard", "API Gateway", "PostgreSQL Database (Prisma)", "Shared UI Components", "AWS S3/CloudFront", "Razorpay", and "Auth (NextAuth/Auth0)".
- Client → API → Database,
- Client → Authentication Service,
- Payment processing flow from Checkout → Razorpay → API.
- Frontend components,
- Backend services,
- Shared libraries,
- External integrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Applications
    subgraph "Frontend Applications"
        cust["Customer Website"]:::frontend
        admin["Admin Dashboard"]:::frontend
    end

    %% API Layers
    subgraph "API Layers"
        apiWeb["API Endpoints (Web)"]:::backend
        apiAdmin["API Endpoints (Admin)"]:::backend
    end

    %% Shared Packages
    subgraph "Shared Packages"
        ui["Shared UI Components"]:::shared
        eslint["ESLint Configuration"]:::shared
        tsConfig["TypeScript Configuration"]:::shared
    end

    %% Data Layer
    subgraph "Data Layer"
        db["((Data Layer (Prisma/PostgreSQL)))"]:::backend
    end

    %% External Services
    subgraph "External Services"
        auth["Auth (NextAuth/Auth0)"]:::external
        s3cf["AWS S3/CloudFront"]:::external
        razorpay["Razorpay"]:::external
    end

    %% Relationships
    cust -->|"calls"| apiWeb
    admin -->|"calls"| apiAdmin

    apiWeb -->|"queries"| db
    apiAdmin -->|"queries"| db

    cust -->|"uses"| ui
    admin -->|"uses"| ui

    cust -->|"authenticatesWith"| auth
    apiWeb -->|"paymentProcessing"| razorpay
    apiWeb -->|"mediaHandling"| s3cf

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#000,stroke-width:2px;
    classDef shared fill:#D5F5E3,stroke:#000,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#000,stroke-width:2px;

    %% Click Events
    click cust "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/apps/web"
    click admin "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/apps/admin"
    click apiWeb "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/apps/web/app/api"
    click apiAdmin "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/apps/admin/app/api"
    click db "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/packages/db"
    click ui "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/packages/ui"
    click eslint "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/packages/eslint-config"
    click tsConfig "https://github.com/kuldeepyeware/fooder_ecommerce/tree/main/packages/typescript-config"
```
