# arpitgami/artivio architecture

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

- Interactive diagram: https://gitdiagram.com/arpitgami/artivio
- Repository: https://github.com/arpitgami/artivio

## Overview

##### Project Type & Purpose
- Artivio is a full-stack web application built on the MERN stack that serves as a customizable poster marketplace. It provides an interactive poster editor, user accounts with Google authentication, secure payment handling with Stripe, image management via Cloudinary, and automated email notifications using Nodemailer.
- The purpose is to allow users (and designers) to browse, customize, and purchase posters, with a seamless integration of design customization, payment processing, and user authentication.

##### File Structure Analysis
- The project is split into two main directories: “frontend” and “backend.”
- The “backend” directory includes controllers, routes, middleware, and models – indicating an MVC-like pattern for handling requests and business logic.
- The “frontend” directory houses React code (with pages, components, contexts, and public assets) along with Tailwind/DaisyUI styling configured.
- Additional configuration files (such as vercel.json and package.json files) show deployment details and dependency management.

##### Key Components
a. Frontend (Client-Side):
- Built with React, using components (like the PosterEditor and NavigationPanel) and pages (e.g., LandingPage, PosterEditor, Cart, etc.).
- Uses Tailwind CSS and DaisyUI for styling.
- Communicates with the backend through RESTful API calls.

b. Backend (Server-Side):
- Utilizes Node.js and Express with clearly separated controllers, routes, and middleware.
- Implements authentication (with Google and custom login/signup flows) and business logic (cart management, poster customization, designer approval, and order processing).
- Contains models to interface with MongoDB and handle data such as user info, poster edits, cart, etc.

c. Database:
- While not directly represented in the file tree, the README indicates the use of MongoDB to store user data, poster edits, and cart information.
- Data compression and chunking for handling large JSON data tied to poster edits.

d. External Services and Integrations:
- Fabric.js for providing the interactive, layer-based poster editing functionality.
- Cloudinary for image uploads and handling large JSON data in chunks.
- Google Authentication for secure user logins.
- Stripe for secure payment gateway integration.
- Nodemailer for sending email notifications (e.g., order confirmations and approval emails).
- Optionally, consider including integration with any admin email system (as described in the approval process).

##### Relationships & Interactions
- The backend interacts with MongoDB for storage. Represent data flow between the “Backend” and “Database.”
- If applicable, show the Fabric.js integration occurring within the frontend (interactive canvas) for dynamic user edits.

##### Architectural Patterns & Design Principles
- MVC Pattern: Controllers, Routes, and Models in the backend.
- Separation of concerns: Clear split between frontend (presentation) and backend (API and business logic).
- Integration of micro-service-like external services to handle specialized tasks (payment, email, authentication, image processing).
- Emphasis on modularity and scalability, as each component (editing, authentication, payment processing) is loosely coupled.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Browser["User's Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (React Application)"]:::frontend
        PE_Page["Poster Editor Page (Fabric.js)"]:::frontend
        PE_Comp["Poster Editor Components"]:::frontend
        NP["Navigation Panel"]:::frontend
        LS_Login["Login Page"]:::frontend
        LS_Signup["Signup Page"]:::frontend
        GL["Google Login"]:::frontend
    end

    %% Backend Layer (Express API Server with MVC components)
    subgraph "Backend (Express API Server)"
        %% Authentication Subgroup
        subgraph "Authentication"
            A1["Auth Controller"]:::backend
            A2["Google Controller"]:::backend
            A3["Auth Routes"]:::backend
        end
        %% Cart & Order Processing Subgroup
        subgraph "Cart & Order Processing"
            CO1["Cart Controller"]:::backend
            CO2["Cart Model"]:::backend
            CO3["Checkout Controller"]:::backend
        end
        %% Poster Customization & Management Subgroup
        subgraph "Poster Customization & Management"
            PC1["PosterCanvas Controller"]:::backend
            PC2["Posters Controller"]:::backend
            PC3["PosterCanvas Model"]:::backend
            PC4["Posters Model"]:::backend
        end
        %% User Edits Handling Subgroup
        subgraph "User Edits Handling"
            UE1["UserEdits Controller"]:::backend
            UE2["UserEditsImage Controller"]:::backend
            UE3["UserEdits Model"]:::backend
            UE4["UserEditsImage Model"]:::backend
        end
    end

    %% External Services
    DB["MongoDB Database"]:::database
    GAE["Google Authentication Service"]:::external
    CL["Cloudinary"]:::external
    SP["Stripe Payment Gateway"]:::external
    NE["Email Service (Nodemailer)"]:::external

    %% Relationships: Frontend Interactions
    Browser -->|"accesses"| FE
    FE -->|"navigates to"| PE_Page
    FE -->|"displays"| NP
    FE -->|"shows"| LS_Login
    FE -->|"shows"| LS_Signup
    FE -->|"initiates"| GL
    PE_Page -->|"utilizes"| PE_Comp

    %% Frontend to Backend API Calls
    LS_Login -->|"login request"| A1
    LS_Signup -->|"signup request"| A1
    GL -->|"Google login request"| A2
    PE_Page -->|"sends poster data"| PC1

    %% Backend and Database Connections
    A1 ---|"CRUD"| DB
    A2 ---|"CRUD"| DB
    A3 ---|"CRUD"| DB
    CO1 ---|"CRUD"| DB
    CO2 ---|"CRUD"| DB
    CO3 ---|"processes"| SP
    CO3 ---|"sends confirmation"| NE
    PC1 ---|"saves edit data"| DB
    PC2 ---|"saves poster info"| DB
    PC1 ---|"uploads to"| CL
    UE1 ---|"manages edit records"| DB
    UE2 ---|"manages image edits"| DB
    UE3 ---|"persist data"| DB
    UE4 ---|"persist data"| DB

    %% Backend External Integrations
    A2 -->|"verifies via"| GAE

    %% Styling Classes
    classDef frontend fill:#DAF7A6,stroke:#333,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend Components
    click FE "https://github.com/arpitgami/artivio/tree/main/frontend/"
    click PE_Page "https://github.com/arpitgami/artivio/blob/main/frontend/src/Pages/PosterEditor.js"
    click PE_Comp "https://github.com/arpitgami/artivio/tree/main/frontend/src/component/PosterEditor/"
    click NP "https://github.com/arpitgami/artivio/blob/main/frontend/src/NavigationPannel.js"
    click LS_Login "https://github.com/arpitgami/artivio/blob/main/frontend/src/Pages/login.js"
    click LS_Signup "https://github.com/arpitgami/artivio/blob/main/frontend/src/Pages/signup.js"
    click GL "https://github.com/arpitgami/artivio/blob/main/frontend/googlelogin.js"

    %% Click Events for Backend Authentication
    click A1 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/authController.js"
    click A2 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/googleController.js"
    click A3 "https://github.com/arpitgami/artivio/blob/main/backend/routes/authRoutes.js"

    %% Click Events for Cart & Order Processing
    click CO1 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/cartControllers.js"
    click CO2 "https://github.com/arpitgami/artivio/blob/main/backend/models/cart.js"
    click CO3 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/checkoutcontroller.js"

    %% Click Events for Poster Customization & Management
    click PC1 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/posterCanvasController.js"
    click PC2 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/postersController.js"
    click PC3 "https://github.com/arpitgami/artivio/blob/main/backend/models/postercanvas.js"
    click PC4 "https://github.com/arpitgami/artivio/blob/main/backend/models/posters.js"

    %% Click Events for User Edits Handling
    click UE1 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/userEditsController.js"
    click UE2 "https://github.com/arpitgami/artivio/blob/main/backend/controllers/userEditsImageController.js"
    click UE3 "https://github.com/arpitgami/artivio/blob/main/backend/models/userEdits.js"
    click UE4 "https://github.com/arpitgami/artivio/blob/main/backend/models/usereditsimage.js"
```
