# theinfiniteprins/shaadisync architecture

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

- Interactive diagram: https://gitdiagram.com/theinfiniteprins/shaadisync
- Repository: https://github.com/theinfiniteprins/shaadisync

## Overview

##### Main Components
- Backend: Built using Node.js and Express.js and contains several key sub-components:
- API endpoints (located in backend/api, with index.js as an entry point).
- Authentication (files under backend/auth with signin.js and signup.js indicating user login and registration logic).
- Controllers (in backend/controllers, managing different domain areas such as Admin, Artist, Payment, Reviews, User and transactions).
- Models (in backend/models, representing MongoDB collections for Artists, User transactions, OTP management, etc.).
- Middleware (in backend/middleware, ensuring route protection and role-based authentication).
- Configuration files (e.g., db.js for DB connection, mailSender.js for email, and config.js for generic configurations).
- Routes (organized in backend/routes to connect controllers to endpoints).
- Frontend: Built using React.js and Tailwind CSS:
- Core React components (in frontend/src/components) that manage UI elements like Artist cards, navbars, sidebars, and forms.
- Layouts and Pages (under frontend/src/layouts and frontend/src/pages) which establish route-based navigation with separation for Admin, Artist, and User.
- Context and routing (frontend/src/context and frontend/src/routes) to manage state (like authentication) and URL mappings.
- Configuration for styling (Tailwind) and bundling (vite.config.js).
- External Services and Integrations:
- Cloudinary for image uploads.
- Stripe for handling payments.
- MongoDB as the primary database.
- JWT for authentication management.

##### Depicting Interactions & Relationships
- For the Frontend, highlight the components, layouts, and pages. Emphasize the integration with the backend API (using RESTful calls) and how context is used to manage authentication.
- Database: Represent MongoDB as another component that interacts primarily with the backend models.
- External systems such as Cloudinary (for image uploads) and Stripe (for payments) connected to the backend.
- Optionally, include a representation of the Admin Dashboard and how it interacts with both the frontend (Admin layout and pages) and the backend (specific admin routes and controllers).

##### Architectural Patterns & Design Principles
- Follow an MVC (Model-View-Controller) style on the backend – clearly separate the routing layer, controller logic, data models, and middleware.
- On the frontend, apply the component-based architecture typical in React applications. Note the use of centralized state management using React Context (AuthContext).
- Separation of concerns, with distinct folders handling configuration, authentication, and business logic.
- Security practices like JWT-based authentication in middleware and protected routes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Backend (Express + Node.js)"
        API["API Endpoints"]:::backend
        Auth["Authentication"]:::backend
        Ctrl["Controllers"]:::backend
        Mod["Models"]:::backend
        Mid["Middleware"]:::backend
        Rt["Routes"]:::backend
        subgraph "Configuration Files"
            DBConfig["DB Connection"]:::backend
            MailSender["Mail Service"]:::backend
            GenConfig["Generic Config"]:::backend
        end
    end

    subgraph "Frontend (React + Tailwind)"
        Comp["Core Components (UI)"]:::frontend
        Lay["Layouts"]:::frontend
        Pg["Pages"]:::frontend
        Cnt["Context (Auth)"]:::frontend
        Rout["Routing"]:::frontend
        subgraph "Styling & Bundling"
            TailwindConfig["Tailwind Config"]:::frontend
            ViteConfig["Vite Config"]:::frontend
        end
    end

    DB["Database (MongoDB)"]:::database
    Cloud["Image Service (Cloudinary)"]:::external
    Stripe["Payment Gateway (Stripe)"]:::external

    %% Frontend to Backend Communication
    Comp -->|"API_Call"| API
    Lay -->|"Compose_UI"| Comp
    Pg -->|"Render_Pages"| Lay
    Cnt -->|"Manage_Auth"| Comp
    Rout -->|"Map_Routes"| Pg

    %% Backend Internal Flow
    API -->|"Handles"| Ctrl
    Auth -->|"User_Auth"| Ctrl
    Rt -->|"Route_Handling"| Ctrl
    Mid -->|"Auth_Check"| Rt
    Ctrl -->|"CRUD_Operations"| Mod

    %% Configuration Usage
    DBConfig -->|"DB_Connection"| DB

    %% External Integrations via Controllers
    Ctrl -->|"Image_Upload"| Cloud
    Ctrl -->|"Payment_Process"| Stripe

    %% Bi-directional Frontend and Backend API Call
    API <-->|"REST_API"| Comp

    %% Click Events for Backend Components
    click API "https://github.com/theinfiniteprins/shaadisync/blob/main/backend/api/index.js"
    click Auth "https://github.com/theinfiniteprins/shaadisync/tree/main/backend/auth"
    click Ctrl "https://github.com/theinfiniteprins/shaadisync/tree/main/backend/controllers"
    click Mod "https://github.com/theinfiniteprins/shaadisync/tree/main/backend/models"
    click Mid "https://github.com/theinfiniteprins/shaadisync/tree/main/backend/middleware"
    click Rt "https://github.com/theinfiniteprins/shaadisync/tree/main/backend/routes"
    click DBConfig "https://github.com/theinfiniteprins/shaadisync/blob/main/backend/config/db.js"
    click MailSender "https://github.com/theinfiniteprins/shaadisync/blob/main/backend/config/mailSender.js"
    click GenConfig "https://github.com/theinfiniteprins/shaadisync/blob/main/backend/configs/config.js"

    %% Click Events for Frontend Components
    click Comp "https://github.com/theinfiniteprins/shaadisync/tree/main/frontend/src/components"
    click Lay "https://github.com/theinfiniteprins/shaadisync/tree/main/frontend/src/layouts"
    click Pg "https://github.com/theinfiniteprins/shaadisync/tree/main/frontend/src/pages"
    click Cnt "https://github.com/theinfiniteprins/shaadisync/blob/main/frontend/src/context/AuthContext.jsx"
    click Rout "https://github.com/theinfiniteprins/shaadisync/tree/main/frontend/src/routes"
    click TailwindConfig "https://github.com/theinfiniteprins/shaadisync/blob/main/frontend/tailwind.config.js"
    click ViteConfig "https://github.com/theinfiniteprins/shaadisync/blob/main/frontend/vite.config.js"

    %% Styles
    classDef backend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef frontend fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef database fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
