# yasinakbulut25/dyt-deniz architecture

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

- Interactive diagram: https://gitdiagram.com/yasinakbulut25/dyt-deniz
- Repository: https://github.com/yasinakbulut25/dyt-deniz

## Overview

##### Project Type and Purpose
- This is a full-stack Next.js web application (portfolio/blog) that:
- Renders static and dynamic pages (SSR/SSG) for public content (home, about, services, blog posts, comments).
- Exposes serverless API routes to send email and handle image uploads.

##### File Structure
- Top-level configs: `next.config.mjs`, `tailwind.config.mjs`, ESLint, PostCSS, JSConfig.
- `src/app/`: Next.js “app router” pages and layout (`layout.jsx`, `page.jsx`) plus API routes under `src/app/api/send-email/route.js` and `src/app/api/upload/route.js`.
- `src/hooks/`, `src/lib/`: custom hooks and utilities.
- `src/api`: client-side API wrapper (`fetchRequest.js`, endpoints).

##### README
- Confirms Next.js, client can run dev server, uses `next/font` for custom fonts, deploys on Vercel.
- No external database—uses serverless functions for email and file uploads.

##### Main Components
a. Client (Browser)
b. CDN / Edge Cache (serving static `/public` assets and pre-rendered pages)
c. Next.js Application Server (SSR/SSG rendering, routing)
d. API Route Handlers (Serverless Functions)
- send-email → SMTP or 3rd-party email service
- upload → file storage (local disk or cloud bucket)
e. Data Store (if any)—in this project the file system under `/public/uploads`
f. Optional External Services
- Email provider (e.g., SendGrid, Mailgun)
- Cloud storage (e.g., AWS S3) if extended

##### Relationships & Data Flows
- Browser → (1) HTTP GET → CDN/Edge → Next.js server → page HTML/JSON → Browser.
- Browser → (2) API POST → `/api/send-email` → Email service → SMTP.
- Browser → (3) API POST → `/api/upload` → File storage → return URL → Browser.
- Next.js build pipeline reads `src/app`, `src/components`, tailwind/Next config → outputs static assets + serverless functions.

##### Architectural Patterns & Design Principles
- **Serverless Functions**: encapsulated in `/src/app/api/*/route.js`.
- **App Router (Next.js)**: file-system based routing under `src/app`.
- **Component-Driven UI**: isolation of reusable UI in `src/components`.
- **CDN-First**: static assets and prerendered pages served globally.

##### Technologies & Frameworks to Annotate
- Next.js 13+ App Router
- React & JSX
- Tailwind CSS + PostCSS
- Vercel (deployment & CDN)
- Node.js runtime for Serverless routes
- Optional: SMTP / Cloud Storage SDK

- Break out:
- **Frontend**: React pages/components, styling, routing.
- **Backend**: Next.js SSR/SSG engine, API functions.
- **External Dependencies**: Email provider, optional storage.
- Both **build-time** (Next.js build, Tailwind compile) and **run-time** flows (HTTP requests, serverless executions).
- Keep it **detailed but uncluttered**, grouping related pieces logically.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["Client (Browser)"]:::external
    end

    %% CDN Layer
    subgraph "CDN/Edge Layer"
        CDN["CDN / Edge Cache\n(Static Assets & Pre-rendered Pages)"]:::assets
    end

    %% Application Layer
    subgraph "Application Layer"
        subgraph "Next.js App Server"
            AppServer["Next.js App Server\n(App Router)"]:::frontend
        end

        subgraph "Pages & Components"
            Layout["Main Layout\nlayout.jsx"]:::frontend
            Home["Home Page\npage.jsx"]:::frontend
            About["About Page\nhakkimda/page.jsx"]:::frontend
            ServicesList["Services List\nhizmet/page.jsx"]:::frontend
            ServiceDetail["Service Detail\nhizmet/[url]/page.jsx"]:::frontend
            BlogList["Blog List\nyazilar/page.jsx"]:::frontend
            BlogPost["Blog Post\nyazi/[url]/page.jsx"]:::frontend
            CommentsList["Comments List\nyorumlar/page.jsx"]:::frontend
            AddComment["Add Comment Page\nyorum-ekle/page.jsx"]:::frontend
            AddCommentForm["AddCommentForm\nAddCommentForm.jsx"]:::frontend
            MailPage["Contact Form Page\nmail/page.jsx"]:::frontend
            ClientProvider["ClientProvider\nClientProvider.jsx"]:::frontend
            MainEntry["Main Entry\nmain.jsx"]:::frontend
        end

        subgraph "UI Component Library"
            Sections["Sections\ncomponents/sections/"]:::frontend
            FormControls["Form Controls\ncomponents/form/"]:::frontend
            SelectControls["Select Controls\ncomponents/select/"]:::frontend
            Loading["Loading States\ncomponents/loading/"]:::frontend
            UIPrimitives["UI Primitives\ncomponents/ui/"]:::frontend
        end

        subgraph "Hooks & Utils"
            Hooks["Custom Hooks\nuseRoutes.jsx"]:::frontend
            Utils["Utility Functions\nutils.js"]:::frontend
        end

        subgraph "API Wrapper (Client)"
            Endpoints["Endpoints\napi/endpoints.js"]:::api
            FetchHelper["Fetch Helper\napi/fetchRequest.js"]:::api
        end

        subgraph "Serverless API Routes"
            SendEmail["send-email Function\napi/send-email/route.js"]:::api
            Upload["upload Function\napi/upload/route.js"]:::api
        end
    end

    %% Data & External
    subgraph "Data & External Services"
        FileSystem["File Storage\npublic/uploads/"]:::assets
        Icons["Icons\npublic/icons/"]:::assets
        EmailService["Email Service\n(e.g., SendGrid)"]:::external
        CloudStorage["Cloud Storage\n(e.g., AWS S3)"]:::external
    end

    %% Flows
    Browser -->|GET Page| CDN
    CDN -->|Forward Cache Miss| AppServer
    AppServer -->|Render Page| Browser

    Browser -->|POST send-email| SendEmail
    SendEmail -->|Send Email| EmailService
    EmailService -->|Confirm| SendEmail
    SendEmail -->|Response| Browser

    Browser -->|POST upload| Upload
    Upload -->|Store File| FileSystem
    FileSystem -->|Return URL| Upload
    Upload -->|Response| Browser

    %% Build-time Flow
    AppServer -->|Build reads| Layout
    AppServer --> Layout
    AppServer --> Home
    AppServer --> About
    AppServer --> ServicesList
    AppServer --> ServiceDetail
    AppServer --> BlogList
    AppServer --> BlogPost
    AppServer --> CommentsList
    AppServer --> AddComment
    AppServer --> AddCommentForm
    AppServer --> MailPage
    AppServer --> ClientProvider
    AppServer --> MainEntry
    AppServer --> Sections
    AppServer --> FormControls
    AppServer --> SelectControls
    AppServer --> Loading
    AppServer --> UIPrimitives
    AppServer --> Hooks
    AppServer --> Utils
    AppServer --> Endpoints
    AppServer --> FetchHelper
    AppServer --> SendEmail
    AppServer --> Upload
    AppServer --> Icons

    %% Click Events
    click AppServer "https://github.com/yasinakbulut25/dyt-deniz/tree/main/src/app/"
    click Layout "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/layout.jsx"
    click Home "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/page.jsx"
    click About "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/hakkimda/page.jsx"
    click ServicesList "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/hizmet/page.jsx"
    click ServiceDetail "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/hizmet/[url]/page.jsx"
    click BlogList "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/yazilar/page.jsx"
    click BlogPost "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/yazi/[url]/page.jsx"
    click CommentsList "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/yorumlar/page.jsx"
    click AddComment "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/yorum-ekle/page.jsx"
    click AddCommentForm "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/yorum-ekle/AddCommentForm.jsx"
    click MailPage "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/mail/page.jsx"
    click Endpoints "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/api/endpoints.js"
    click FetchHelper "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/api/fetchRequest.js"
    click SendEmail "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/api/send-email/route.js"
    click Upload "https://github.com/yasinakbulut25/dyt-deniz/blob/main/src/app/api/upload/route.js"
    click Icons "https://github.com/yasinakbulut25/dyt-deniz/tree/main/public/icons/"
    click FileSystem "https://github.com/yasinakbulut25/dyt-deniz/tree/main/public/uploads/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#4A90E2,stroke-width:1px;
    classDef api fill:#D0FFE0,stroke:#34A853,stroke-width:1px;
    classDef external fill:#FFF4C1,stroke:#E2C044,stroke-width:1px;
    classDef assets fill:#F0F0F0,stroke:#A0A0A0,stroke-width:1px;
```
