# siddhesh1051/ownlink architecture

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

- Interactive diagram: https://gitdiagram.com/siddhesh1051/ownlink
- Repository: https://github.com/siddhesh1051/ownlink

## Overview

##### And Segment the Main Components
- Frontend (Client): Represent the entire client folder including:
– State Management: The Redux store and slices (e.g., bgSlice, bioSlice, emailSlice, etc.) which maintain the application state.
– Utility Modules: Utility functions such as googleAnalytics integration and configuration files (Tailwind config).
- Backend (Server): Represent the entire server folder including:
– API Routes and Controllers: Identify the endpoints from files like authroutes.js and controllers (authcontroller, promoterAuthController, etc.). These define the RESTful interface for authentication, promoter functions, referrals, scratch card operations, and more.
– Business Logic & Helpers: Highlight helper functions (for sending emails, building HTML for notifications, and verification OTP) which encapsulate key business logic.
– Data Models: Include the models (authmodel, otpModel, scratchCardModel, etc.) that define the schema and interactions with the database.
– Configuration: Include configuration files like firebase.js which hint at additional integrated services.

##### Data Flow and Interactions
- Backend-to-Database/External Services: Show the backend interacting with external systems:
- MongoDB: Represent the database where user data, link configurations, and other metadata are stored.
- Cloudinary: Illustrate the connection for image storage and retrieval.
- (Firebase): Optionally include Firebase if there are elements (like push notifications or auth integrations) suggested by the firebase.js.

##### Architectural Patterns and Design Principles
- Layered Architecture: Identify the separation between the presentation layer (React frontend), business logic layer (Node.js controllers and helpers), and data layer (models with MongoDB interaction).
- Modular Design: Note that both client and server are structured in modular ways (e.g., many reusable components in React and clearly separated controllers/models in the backend).
- RESTful API Communication: Highlight the standard request/response model between the client and server.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% User Device
  UD("User Device"):::external

  %% Frontend Subgraph
  subgraph "Frontend (Client)"
    F1("React UI Components"):::frontend
    F2("Redux Store"):::frontend
    F3("Utility Modules"):::frontend
  end

  %% Backend Subgraph
  subgraph "Backend (Server)"
    B1("API Routes & Controllers"):::backend
    B2("Business Logic & Helpers"):::backend
    B3("Data Models"):::backend
    B4("Configuration"):::backend
  end

  %% External Services
  EM("MongoDB Database"):::external
  EC("Cloudinary Storage"):::external
  EF("Firebase Service"):::external

  %% Connections: User to Frontend
  UD -->|"Access"| F1

  %% Frontend internal connection
  F1 -->|"StateManagement"| F2
  F1 -->|"Utilizes"| F3

  %% Frontend to Backend
  F1 -->|"CallsAPI"| B1

  %% Backend internal flows
  B1 -->|"InvokesLogic"| B2
  B2 -->|"UsesModels"| B3

  %% Backend to External Services
  B3 -->|"PersistsData"| EM
  B1 -->|"SendsImages"| EC
  B4 -->|"Integrates"| EF

  %% Apply Styles
  classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
  classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
  classDef external fill:#FFA500,stroke:#000,stroke-width:2px;

  %% Click Events for Frontend (Client)
  click F1 "https://github.com/siddhesh1051/ownlink/tree/main/client/src/components"
  click F1 "https://github.com/siddhesh1051/ownlink/tree/main/client/src/pages"
  click F2 "https://github.com/siddhesh1051/ownlink/tree/main/client/src/store"
  click F3 "https://github.com/siddhesh1051/ownlink/tree/main/client/src/utils"
  click F3 "https://github.com/siddhesh1051/ownlink/blob/main/client/tailwind.config.js"

  %% Click Events for Backend (Server) - API Routes and Controllers
  click B1 "https://github.com/siddhesh1051/ownlink/tree/main/server/routes"
  click B1 "https://github.com/siddhesh1051/ownlink/blob/main/server/controllers/authcontroller.js"
  click B1 "https://github.com/siddhesh1051/ownlink/blob/main/server/controllers/promoterAuthController.js"
  click B1 "https://github.com/siddhesh1051/ownlink/blob/main/server/controllers/redeemPointsController.js"
  click B1 "https://github.com/siddhesh1051/ownlink/blob/main/server/controllers/referralController.js"
  click B1 "https://github.com/siddhesh1051/ownlink/blob/main/server/controllers/scratchCardController.js"

  %% Click Events for Backend (Server) - Business Logic & Helpers
  click B2 "https://github.com/siddhesh1051/ownlink/blob/main/server/helpers/cancelorderHTML.js"
  click B2 "https://github.com/siddhesh1051/ownlink/blob/main/server/helpers/mailHTML.js"
  click B2 "https://github.com/siddhesh1051/ownlink/blob/main/server/helpers/orderplacedHTML.js"
  click B2 "https://github.com/siddhesh1051/ownlink/blob/main/server/helpers/sendMail.js"
  click B2 "https://github.com/siddhesh1051/ownlink/blob/main/server/helpers/sendNotification.js"
  click B2 "https://github.com/siddhesh1051/ownlink/blob/main/server/helpers/verifyotpHTML.js"

  %% Click Events for Backend (Server) - Data Models
  click B3 "https://github.com/siddhesh1051/ownlink/blob/main/server/model/authmodel.js"
  click B3 "https://github.com/siddhesh1051/ownlink/blob/main/server/model/otpModel.js"
  click B3 "https://github.com/siddhesh1051/ownlink/blob/main/server/model/promoterModel.js"
  click B3 "https://github.com/siddhesh1051/ownlink/blob/main/server/model/scratchCardModel.js"
  click B3 "https://github.com/siddhesh1051/ownlink/blob/main/server/model/transactionModel.js"

  %% Click Events for Backend (Server) - Configuration
  click B4 "https://github.com/siddhesh1051/ownlink/blob/main/server/config/firebase.js"
  click B4 "https://github.com/siddhesh1051/ownlink/blob/main/server/.env"
```
