# zahooronly/smit-project architecture

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

- Interactive diagram: https://gitdiagram.com/zahooronly/smit-project
- Repository: https://github.com/zahooronly/smit-project

## Overview

##### Main System Components

A. Frontend Layer
- Client-Side Components
- Server-Side Components (Next.js App Router)
- State Management
- UI Components

B. API Layer
- Authentication Routes
- Product Routes
- User Routes

C. Backend Layer
- Database Models
- External Services
- Configuration

##### Detailed Component Breakdown

Frontend Layer:
- Components hierarchy (Navbar, Hero, ProductCatalog, etc.)
- Client-side vs server-side components
- Shopping cart flow

API Layer:
- API routes by domain (/api/products, /api/users)
- Authentication middleware flow
- Protected routes

Backend Layer:
- Database models (User, Product, Cart, Order)
- External service integrations (mailer helper)
- Configuration services (dbConfig)

Use the following visual elements:

Components:
- Rectangle: Pages and Components
- Hexagon: API Endpoints
- Cloud: External Services

- Blue: Frontend Components
- Green: API Routes
- Orange: Database Models
- Purple: External Services
- Gray: Configuration/Infrastructure

- Double lines: Authentication flow

##### Key Relationships to Highlight

- Authentication Flow:
Login/Signup → API Routes → User Model → JWT Token
- Product Flow:
ProductCatalog → Product API → Product Model
- Shopping Flow:
Cart → Checkout → Order Model

##### Infrastructure Layer (Config, Database)

Left to Right:
- User-related flows on the left
- Product-related flows in the middle
- Order/Cart-related flows on the right

##### Additional Elements

Include:
- Authentication middleware coverage
- Data flow direction indicators
- Component state management
- API route protection status

##### Important Notes

- Next.js App Router structure
- Server-side vs client-side rendering
- Shopping cart state management
- Form handling and validation flow
- Error handling and toast notifications

This system design should effectively communicate the application's architecture to other developers while maintaining clarity and accuracy in representing the actual implementation.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        Dashboard["Dashboard"]:::frontend
        Products["Products"]:::frontend
        Profile["Profile"]:::frontend
        Login["Login"]:::frontend
        Signup["Signup"]:::frontend
        
        subgraph "UI Components"
            Navbar["Navbar"]:::frontend
            Hero["Hero"]:::frontend
            ProductCatalog["Product Catalog"]:::frontend
            ShoppingCart["Shopping Cart"]:::frontend
            ProductForm["Product Form"]:::frontend
            UserRegForm["User Registration Form"]:::frontend
            ToastContainer["Toast Container"]:::frontend
            CheckoutForm["Checkout Form"]:::frontend
        end
    end

    subgraph "API Layer"
        subgraph "Auth Routes"
            LoginAPI["Login API"]:::api
            SignupAPI["Signup API"]:::api
            LogoutAPI["Logout API"]:::api
            VerifyAPI["Token Verify API"]:::api
        end
        
        subgraph "Product Routes"
            ProductCreateAPI["Create Product API"]:::api
            ProductManageAPI["Product Management API"]:::api
        end
    end

    subgraph "Backend Layer"
        subgraph "Database Models"
            UserModel[(User Model)]:::db
            ProductModel[(Product Model)]:::db
            CartModel[(Cart Model)]:::db
            OrderModel[(Order Model)]:::db
        end
        
        subgraph "Services & Config"
            DBConfig[("Database Config")]:::config
            EmailService["Email Service"]:::service
            ThemeConfig["Theme Config"]:::config
            AuthMiddleware["Auth Middleware"]:::service
        end
    end

    %% Relationships
    Dashboard --> Navbar
    Products --> ProductCatalog
    ProductCatalog --> ProductManageAPI
    Login --> LoginAPI
    Signup --> SignupAPI
    ShoppingCart --> CartModel
    CheckoutForm --> OrderModel
    
    LoginAPI --> UserModel
    SignupAPI --> UserModel
    ProductManageAPI --> ProductModel
    
    AuthMiddleware -.-> LoginAPI
    AuthMiddleware -.-> SignupAPI
    EmailService -.-> SignupAPI
    DBConfig -.-> UserModel
    DBConfig -.-> ProductModel
    DBConfig -.-> CartModel
    DBConfig -.-> OrderModel

    %% Click Events
    click Dashboard "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/dashboard/page.tsx"
    click Products "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/products/page.tsx"
    click Profile "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/profile/page.tsx"
    click Login "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/login/page.tsx"
    click Signup "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/signup/page.tsx"
    click Navbar "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/Navbar/Navbar.tsx"
    click Hero "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/Hero/Hero.tsx"
    click ProductCatalog "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/ProductCatalog/ProductCatalog.tsx"
    click ShoppingCart "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/ShoppingCart/ShoppingCart.tsx"
    click ProductForm "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/ProductForm/ProductForm.tsx"
    click UserRegForm "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/UserRegistrationForm/UserRegistrationForm.tsx"
    click ToastContainer "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/ToastContainer/ToastContainer.tsx"
    click CheckoutForm "https://github.com/zahooronly/SMIT-PROJECT/blob/master/components/CheckoutForm/CheckoutForm.tsx"
    click LoginAPI "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/api/users/login/route.ts"
    click SignupAPI "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/api/users/signup/route.ts"
    click LogoutAPI "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/api/users/logout/route.ts"
    click VerifyAPI "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/api/users/verifytoken/route.ts"
    click ProductCreateAPI "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/api/products/create/route.ts"
    click ProductManageAPI "https://github.com/zahooronly/SMIT-PROJECT/blob/master/app/api/products/[id]/route.ts"
    click UserModel "https://github.com/zahooronly/SMIT-PROJECT/blob/master/models/userModel.js"
    click ProductModel "https://github.com/zahooronly/SMIT-PROJECT/blob/master/models/productSchema.js"
    click CartModel "https://github.com/zahooronly/SMIT-PROJECT/blob/master/models/cartSchema.js"
    click OrderModel "https://github.com/zahooronly/SMIT-PROJECT/blob/master/models/orderShema.js"
    click DBConfig "https://github.com/zahooronly/SMIT-PROJECT/blob/master/config/dbConfig.ts"
    click EmailService "https://github.com/zahooronly/SMIT-PROJECT/blob/master/helpers/mailer.ts"
    click ThemeConfig "https://github.com/zahooronly/SMIT-PROJECT/blob/master/theme/themeConfig.ts"
    click AuthMiddleware "https://github.com/zahooronly/SMIT-PROJECT/blob/master/middleware.ts"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef db fill:#e67e22,stroke:#d35400,color:white
    classDef service fill:#9b59b6,stroke:#8e44ad,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        API["API Route"]:::api
        Database[(Database Model)]:::db
        Service["Service"]:::service
        Config["Configuration"]:::config
    end
```
