# theanandppatel/onstore architecture

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

- Interactive diagram: https://gitdiagram.com/theanandppatel/onstore
- Repository: https://github.com/theanandppatel/onstore

## Overview

##### Project type and purpose
- This is a full-stack e-commerce web application built with Next.js (React) on the frontend and Next.js API routes on the backend, persisting data in MongoDB via Mongoose. It supports product listings, user authentication (email/password + Google Sign-In), orders, payments (Razorpay), and admin operations (add/update products, tokens, recommendations).

##### File structure
- Top-level directories:
- pages/ – React pages and Next.js API routes (pages/api/)
- components/ – UI components (Navbar, Footer, modals)
- models/ – Mongoose schemas (Product, Order, User, Token, etc.)
- middleware/ – Mongoose connection logic
- styles/ – CSS (Tailwind config, global styles)
- Configuration/DevOps files: .eslintrc.json, next.config.js, tailwind.config.js, package.json.

##### Detailed capture of essential elements
- UI: Navbar, Footer, Product pages, Checkout flow, modals
- Auth: signup/login/reset password flows (API routes + token model)
- Product management: add/update/search endpoints + Featured/Recommended models
- Order management: myorders, posttransaction
- Payment integration: /api/razorpay, makeCod
- DB connection middleware as shared infrastructure between all API routes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Tier"
        direction TB
        Browser["Browser/Client"]:::ui
        Navbar["Navbar"]:::ui
        Footer["Footer"]:::ui
        DisclaimerModal["Disclaimer Modal"]:::ui
        Pages["pages/"]:::ui
        PublicAssets["public/"]:::external
        Styles["styles/"]:::external
    end

    subgraph "Backend Tier"
        direction TB
        NextServer["Next.js Server (SSR/API)"]:::service
        Config["next.config.js"]:::external

        subgraph "API Routes"
            direction TB
            signup["Signup API"]:::service
            login["Login API"]:::service
            googlesignin["Google Sign-In API"]:::service
            authtoken["Auth Token API"]:::service
            authuser["Auth User API"]:::service
            sendresetlink["Send Reset Link API"]:::service
            resetpassword["Reset Password API"]:::service
            forgotpasswordPage["ForgotPassword Page"]:::service
            resetpasswordPage["ResetPassword Page"]:::service
            addprod["Add Product API"]:::service
            updateprod["Update Product API"]:::service
            getproducts["Get Products API"]:::service
            searchquery["Search Products API"]:::service
            addfeatured["Add Featured Product API"]:::service
            addrecommended["Add Recommended Product API"]:::service
            addtoken["Add Token API"]:::service
            gettoken["Get Token API"]:::service
            myorders["My Orders API"]:::service
            posttransaction["Post Transaction API"]:::service
            makeCod["Make COD API"]:::service
            razorpayAPI["Razorpay API"]:::service
            pincodeAPI["Pincode API"]:::service
            updateuser["Update User API"]:::service
        end

        Middleware["DB Middleware"]:::service

        subgraph "Mongoose Models"
            direction TB
            UserModel["User Model"]:::database
            ProductModel["Product Model"]:::database
            OrderModel["Order Model"]:::database
            TokenModel["Token Model"]:::database
            FeaturedModel["FeaturedProduct Model"]:::database
            RecommendedModel["RecommendedProduct Model"]:::database
        end

        DB["MongoDB"]:::database

        subgraph "External Services"
            direction TB
            Razorpay["Razorpay"]:::external
            GoogleOAuth["Google OAuth"]:::external
            EmailSMS["Email/SMS Gateway"]:::external
        end
    end

    %% Connections Frontend to Backend
    Browser -->|"serve pages (SSR/SSG)"| NextServer
    Browser -->|"static assets"| PublicAssets
    Browser -->|"styles"| Styles
    Browser -->|"API calls"| signup
    Browser -->|"API calls"| login

    %% Next.js server to components
    NextServer -->|routes| signup
    NextServer -->|routes| addprod
    NextServer -->|config| Config

    %% API to Middleware and Models
    signup -->|uses| Middleware
    login -->|uses| Middleware
    signup -->|reads/writes| UserModel
    login -->|reads/writes| UserModel

    addprod -->|uses| Middleware
    addprod -->|reads/writes| ProductModel
    updateprod -->|reads/writes| ProductModel
    getproducts -->|reads| ProductModel
    searchquery -->|reads| ProductModel
    addfeatured -->|reads/writes| FeaturedModel
    addrecommended -->|reads/writes| RecommendedModel

    myorders -->|uses| Middleware
    myorders -->|reads| OrderModel
    posttransaction -->|writes| OrderModel
    makeCod -->|writes| OrderModel

    razorpayAPI -->|calls| Razorpay
    razorpayAPI -->|writes| OrderModel

    googlesignin -->|calls| GoogleOAuth
    sendresetlink -->|calls| EmailSMS
    pincodeAPI -->|reads| Middleware

    %% Middleware to DB
    Middleware -->|connects| DB

    %% Legend and UI components grouping
    Navbar -.-> Browser
    Footer -.-> Browser
    DisclaimerModal -.-> Browser
    Pages -.-> Browser

    %% Click Events
    click Browser "https://github.com/theanandppatel/onstore/tree/main/pages/"
    click Navbar "https://github.com/theanandppatel/onstore/blob/main/components/Navbar.js"
    click Footer "https://github.com/theanandppatel/onstore/blob/main/components/Footer.js"
    click DisclaimerModal "https://github.com/theanandppatel/onstore/blob/main/components/DisclaimerModal.js"
    click signup "https://github.com/theanandppatel/onstore/blob/main/pages/api/signup.js"
    click login "https://github.com/theanandppatel/onstore/blob/main/pages/api/login.js"
    click googlesignin "https://github.com/theanandppatel/onstore/blob/main/pages/api/googlesignin.js"
    click authtoken "https://github.com/theanandppatel/onstore/blob/main/pages/api/authtoken.js"
    click authuser "https://github.com/theanandppatel/onstore/blob/main/pages/api/authuser.js"
    click sendresetlink "https://github.com/theanandppatel/onstore/blob/main/pages/api/sendresetlink.js"
    click resetpassword "https://github.com/theanandppatel/onstore/blob/main/pages/api/resetpassword.js"
    click forgotpasswordPage "https://github.com/theanandppatel/onstore/blob/main/pages/forgotpassword.js"
    click resetpasswordPage "https://github.com/theanandppatel/onstore/blob/main/pages/resetpassword.js"
    click addprod "https://github.com/theanandppatel/onstore/blob/main/pages/api/addproducts.js"
    click updateprod "https://github.com/theanandppatel/onstore/blob/main/pages/api/updateproduct.js"
    click getproducts "https://github.com/theanandppatel/onstore/blob/main/pages/api/getproducts.js"
    click searchquery "https://github.com/theanandppatel/onstore/blob/main/pages/api/searchquery.js"
    click addfeatured "https://github.com/theanandppatel/onstore/blob/main/pages/api/addfeaturedproduct.js"
    click addrecommended "https://github.com/theanandppatel/onstore/blob/main/pages/api/addrecommendedproduct.js"
    click addtoken "https://github.com/theanandppatel/onstore/blob/main/pages/api/addtoken.js"
    click gettoken "https://github.com/theanandppatel/onstore/blob/main/pages/api/gettoken.js"
    click myorders "https://github.com/theanandppatel/onstore/blob/main/pages/api/myorders.js"
    click posttransaction "https://github.com/theanandppatel/onstore/blob/main/pages/api/posttransaction.js"
    click makeCod "https://github.com/theanandppatel/onstore/blob/main/pages/api/makeCod.js"
    click razorpayAPI "https://github.com/theanandppatel/onstore/blob/main/pages/api/razorpay.js"
    click pincodeAPI "https://github.com/theanandppatel/onstore/blob/main/pages/api/pincode.js"
    click updateuser "https://github.com/theanandppatel/onstore/blob/main/pages/api/updateuser.js"
    click UserModel "https://github.com/theanandppatel/onstore/blob/main/models/Users.js"
    click ProductModel "https://github.com/theanandppatel/onstore/blob/main/models/Product.js"
    click OrderModel "https://github.com/theanandppatel/onstore/blob/main/models/Order.js"
    click TokenModel "https://github.com/theanandppatel/onstore/blob/main/models/Token.js"
    click FeaturedModel "https://github.com/theanandppatel/onstore/blob/main/models/FeaturedProduct.js"
    click RecommendedModel "https://github.com/theanandppatel/onstore/blob/main/models/RecommendedProduct.js"
    click Middleware "https://github.com/theanandppatel/onstore/blob/main/middleware/mongoose.js"
    click PublicAssets "https://github.com/theanandppatel/onstore/tree/main/public/"
    click Styles "https://github.com/theanandppatel/onstore/blob/main/styles/globals.css"
    click Config "https://github.com/theanandppatel/onstore/blob/main/next.config.js"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef service fill:#d4edda,stroke:#333,stroke-width:1px
    classDef database fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
```
