# tamertawfik/dcreator architecture

> Architecture diagram of the GitHub repository tamertawfik/dcreator, 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/tamertawfik/dcreator
- Repository: https://github.com/tamertawfik/dcreator

## Overview

Based on our analysis of the file tree and README, the project is a full-stack Next.js application called “Dcreator” that enables sellers to distribute digital products. It’s built with a modern React framework (Next.js) using an app directory structure that logically separates the marketing site and the dashboard (admin interface). It also exposes backend API endpoints (using Next.js API routes) to handle authentication, product and category management, file uploads, etc. The system leverages Prisma as its ORM (to interact with a PlanetScale/MySQL database) and integrates with a number of external services and libraries like Auth.js, Uploadthing, Tailwind CSS, Shadcn UI, and others.

##### Main Components
- Frontend/UI
- Two primary user paths: the Marketing (public-facing) site and the Dashboard (admin/seller area).
- Use clear logical groupings to indicate pages (with folder paths like /app/(marketing) and /app/(dashboard)).
- Shared components such as navbars, footers, and individual UI components residing in the “components” directory.
- Backend/API
- API endpoints are defined under /app/api for authentication, categories, products, and file uploads.
- That these endpoints encapsulate the business logic (e.g., product CRUD, user auth via Auth.js).
- Database Layer
- Connection to a PlanetScale/MySQL database managed via Prisma (note the prisma/schema.prisma file).
- External Integrations & Services
- Notate integrations with external platforms like Vercel (deployment) and authentication providers (handled via Auth.js).
- Mention Uploadthing used for file handling.

##### Relationships & Interactions
- A clear separation between the frontend and backend:
- The Marketing and Dashboard UIs interact with API endpoints over HTTP.
- The API layer interacts with the database (indicate data persistence using Prisma).
- External integrations:
- For example, the authentication API calls Auth.js, and file uploads call Uploadthing.
- The deployment flow (from repository to Vercel) and database hosting with PlanetScale.

##### Architectural Patterns & Design Principles
- Use of Next.js as both a frontend and API backend (hybrid approach).
- Modularity:
- The application is broken into logically separated modules (marketing, dashboard, and shared components).
- Adherence to code quality and type safety principles through the use of TypeScript, ESLint, and Prettier.
- The separation of concerns is clear from distinct directories for API routes, UI components, configuration, and utilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client/Browser Layer
    subgraph "Client/Browser"
        MarketingUI["Marketing UI"]:::frontend
        DashboardUI["Dashboard UI"]:::frontend
        SharedUI["Shared UI Components"]:::frontend
    end

    %% Next.js Application Layer (UI + API)
    subgraph "Next.js Application"
        API_Auth["API: Auth"]:::backend
        API_Categories["API: Categories"]:::backend
        API_Products["API: Products"]:::backend
        API_FileUpload["API: File Upload"]:::backend
        Config["Config & Env"]:::config
    end

    %% Database Layer
    subgraph "Database Layer"
        Prisma["Prisma ORM\n(Database Access)"]:::database
    end

    %% External Services Layer
    subgraph "External Services"
        ExtAuth["Auth.js Integration"]:::external
        ExtUpload["Uploadthing Integration"]:::external
        Vercel["Vercel (Deployment)"]:::external
    end

    %% Client to API interactions
    MarketingUI -->|"HTTP"| API_Auth
    MarketingUI -->|"HTTP"| API_Products

    DashboardUI -->|"HTTP"| API_Auth
    DashboardUI -->|"HTTP"| API_Categories
    DashboardUI -->|"HTTP"| API_Products
    DashboardUI -->|"HTTP"| API_FileUpload

    %% Shared UI components reference both UIs (dotted connection)
    SharedUI ---|"provides common elements"| MarketingUI
    SharedUI ---|"provides common elements"| DashboardUI

    %% API endpoints to Database
    API_Auth -->|"DB Query"| Prisma
    API_Categories -->|"DB Query"| Prisma
    API_Products -->|"DB Query"| Prisma
    API_FileUpload -->|"DB Query"| Prisma

    %% API endpoints call external integrations
    API_Auth -->|"Calls"| ExtAuth
    API_FileUpload -->|"Calls"| ExtUpload

    %% Configuration affects API endpoints
    Config -->|"Configures"| API_Auth
    Config -->|"Configures"| API_Categories
    Config -->|"Configures"| API_Products
    Config -->|"Configures"| API_FileUpload

    %% Deployment flow from configuration to external hosting
    Config -->|"Deploys to"| Vercel

    %% Click Events for Component Mapping
    click MarketingUI "https://github.com/tamertawfik/dcreator/tree/develop/app/(marketing)"
    click MarketingUI "https://github.com/tamertawfik/dcreator/tree/develop/components/marketing"
    click DashboardUI "https://github.com/tamertawfik/dcreator/tree/develop/app/(dashboard)"
    click DashboardUI "https://github.com/tamertawfik/dcreator/tree/develop/components/dashboard"
    click SharedUI "https://github.com/tamertawfik/dcreator/blob/develop/components/main-nav.tsx"
    click SharedUI "https://github.com/tamertawfik/dcreator/blob/develop/components/site-footer.tsx"
    click API_Auth "https://github.com/tamertawfik/dcreator/blob/develop/app/api/auth/[...nextauth]/route.ts"
    click API_Categories "https://github.com/tamertawfik/dcreator/blob/develop/app/api/categories/route.ts"
    click API_Categories "https://github.com/tamertawfik/dcreator/blob/develop/app/api/categories/[categoryId]/route.ts"
    click API_Products "https://github.com/tamertawfik/dcreator/blob/develop/app/api/products/route.ts"
    click API_Products "https://github.com/tamertawfik/dcreator/blob/develop/app/api/products/[productId]/route.ts"
    click API_FileUpload "https://github.com/tamertawfik/dcreator/blob/develop/app/api/uploadthing/route.ts"
    click API_FileUpload "https://github.com/tamertawfik/dcreator/blob/develop/app/api/uploadthing/core.ts"
    click Prisma "https://github.com/tamertawfik/dcreator/blob/develop/prisma/schema.prisma"
    click Prisma "https://github.com/tamertawfik/dcreator/blob/develop/lib/db.ts"
    click ExtAuth "https://github.com/tamertawfik/dcreator/blob/develop/lib/auth.ts"
    click ExtUpload "https://github.com/tamertawfik/dcreator/blob/develop/lib/uploadthing.ts"
    click Config "https://github.com/tamertawfik/dcreator/blob/develop/next.config.js"
    click Config "https://github.com/tamertawfik/dcreator/blob/develop/.env.example"

    %% Styles
    classDef frontend fill:#9de0ad,stroke:#333,stroke-width:2px;
    classDef backend fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef database fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef external fill:#f94144,stroke:#333,stroke-width:2px;
    classDef config fill:#577590,stroke:#333,stroke-width:2px;
```
