# kiritoem/3d-shop architecture

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

- Interactive diagram: https://gitdiagram.com/kiritoem/3d-shop
- Repository: https://github.com/kiritoem/3d-shop

## Overview

##### Project Type and Purpose
- This is a full-stack, e-commerce / product-customization web application built with Next.js (App Router), React (client & server components), Prisma (ORM), and a PostgreSQL database.
- Key features:
- User authentication (NextAuth)
- Product catalog & category browsing
- 3D model rendering (Three.js)
- Shopping cart & Stripe payments
- Admin/data-import scripts (SQL dump)

##### File Structure
- `src/app/(auth)` & `src/app/(client)`: Next.js App Router zones for authenticated vs. public pages (login, signup, shop, payment result, product & category pages).
- `src/app/api/*`: API routes for auth ([...nextauth]), product, products, category, payment—each handling HTTP requests and server-side logic.
- `prisma/`: Database schema + migrations (user, transaction, customization_configs).
- `data_import/`: SQL dump for initial data load.
- `components/` & `features/`: UI building blocks and feature modules (auth forms, cart, shop filters, 3D-model viewers) following a modular/feature-slice pattern.
- `lib/`: Shared utilities (auth, Prisma client, Stripe client, HTTP exceptions, Zod schemas).
- `providers/`: React Context providers (NextAuth, TanStack Query, Theme).
- `docker-compose.yaml` & `Dockerfile`: Containerize app + Postgres (and possibly Redis if added).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Browser
    Browser["Client Browser<br/>(React SSR & CSR)"]:::frontend

    %% Static Asset Store
    Storage["Static Assets<br/>(Public Directory)"]:::storage

    %% Next.js Server
    subgraph "Next.js Server (Node.js)" 
        direction TB
        AppRouter["App Router<br/>(Server & Client Components)"]:::backend
        subgraph "Pages"
            direction TB
            AuthPages["Auth Pages<br/>(Login & Signup)"]:::backend
            ClientPages["Client Pages<br/>(Shop, Product, Category,<br/>Payment Result)"]:::backend
        end
        subgraph "API Layer"
            direction TB
            AuthAPI["/api/auth<br/>(NextAuth)"]:::backend
            ProductsAPI["/api/products"]:::backend
            ProductAPI["/api/product/[cuid]"]:::backend
            CategoryAPI["/api/category"]:::backend
            PaymentAPI["/api/payment"]:::backend
        end
        PrismaClient["Prisma Client"]:::backend
    end

    %% Database
    Database["PostgreSQL<br/>(Prisma ORM)"]:::database

    %% External Services
    OAuth["OAuth Providers<br/>(NextAuth)"]:::external
    Stripe["Stripe Payments API"]:::external

    %% Docker Network
    subgraph "Docker Network"
        direction TB
        AppContainer["App Container"]:::backend
        DBContainer["Postgres Container"]:::database
    end

    %% Connections
    Browser -->|"Requests / SSR"| AppRouter
    Browser -->|"Fetch 3D Models & Media"| Storage
    AppRouter -->|"/api/auth, /api/products,<br/>/api/product/{cuid}, /api/category,<br/>/api/payment"| AuthAPI
    AppRouter -->|Uses| PrismaClient
    PrismaClient -->|Read/Write| Database
    AuthAPI -->|OAuth Flow| OAuth
    PaymentAPI -->|Create/Confirm Payment| Stripe

    AppContainer -->|Network Link| DBContainer

    %% Click events
    click AppRouter "https://github.com/kiritoem/3d-shop/blob/develop/src/app/layout.tsx"
    click AuthPages "https://github.com/kiritoem/3d-shop/tree/develop/src/app/(auth)"
    click AuthPages "https://github.com/kiritoem/3d-shop/blob/develop/src/app/(auth)/login/page.tsx"
    click AuthPages "https://github.com/kiritoem/3d-shop/blob/develop/src/app/(auth)/signup/page.tsx"
    click ClientPages "https://github.com/kiritoem/3d-shop/tree/develop/src/app/(client)"
    click ClientPages "https://github.com/kiritoem/3d-shop/blob/develop/src/app/(client)/shop/page.tsx"
    click ClientPages "https://github.com/kiritoem/3d-shop/blob/develop/src/app/(client)/shop/[cuid]/page.tsx"
    click ClientPages "https://github.com/kiritoem/3d-shop/blob/develop/src/app/(client)/paymentResult/page.tsx"
    click AuthAPI "https://github.com/kiritoem/3d-shop/blob/develop/src/app/api/auth/[...nextauth]/route.ts"
    click ProductsAPI "https://github.com/kiritoem/3d-shop/blob/develop/src/app/api/products/route.ts"
    click ProductAPI "https://github.com/kiritoem/3d-shop/blob/develop/src/app/api/product/[cuid]/route.ts"
    click CategoryAPI "https://github.com/kiritoem/3d-shop/blob/develop/src/app/api/category/route.ts"
    click PaymentAPI "https://github.com/kiritoem/3d-shop/blob/develop/src/app/api/payment/route.ts"
    click PrismaClient "https://github.com/kiritoem/3d-shop/blob/develop/prisma/schema.prisma"
    click PrismaClient "https://github.com/kiritoem/3d-shop/tree/develop/prisma/migrations/"
    click Storage "https://github.com/kiritoem/3d-shop/tree/develop/public/uploaded-models/"
    click Storage "https://github.com/kiritoem/3d-shop/tree/develop/public/hdr/"
    click Storage "https://github.com/kiritoem/3d-shop/tree/develop/public/lotties/"
    click Storage "https://github.com/kiritoem/3d-shop/tree/develop/public/sounds/"
    click AppContainer "https://github.com/kiritoem/3d-shop/tree/develop/Dockerfile"
    click AppContainer "https://github.com/kiritoem/3d-shop/blob/develop/docker-compose.yaml"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#2B6CB0,color:#2B6CB0,stroke-width:1px;
    classDef backend fill:#D4F5D4,stroke:#2F855A,color:#2F855A,stroke-width:1px;
    classDef database fill:#E2E8F0,stroke:#4A5568,color:#4A5568,stroke-width:1px;
    classDef external fill:#FEF3C7,stroke:#D97706,color:#D97706,stroke-width:1px;
    classDef storage fill:#EDF2F7,stroke:#718096,color:#718096,stroke-width:1px;
```
