# ridvan-aydin-del/askzone architecture

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

- Interactive diagram: https://gitdiagram.com/ridvan-aydin-del/askzone
- Repository: https://github.com/ridvan-aydin-del/askzone

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js (v13+ using the “app/” router).
- Its primary purpose appears to be a Q&A or “knowledge-sharing” site (you have ask, questions/[id], favorites, profile, login/register pages).
- It uses Supabase as its backend for authentication and data storage.

##### File structure
- **app/** – The Next.js App Router directory, containing page-level folders (ask, favorites, login, register, questions/[id], profile/[username]) each with a page.tsx. Also global layout.tsx, globals.css.
- **components/** – Reusable React components (AuthForm, Header, QuestionForm, AnswersSection, UpVoteButton).
- **lib/supabase.ts** – A Supabase client helper for querying the database and handling auth.
- **public/** – Static assets served directly.
- **Configuration files** – next.config.ts, tsconfig.json, ESLint, PostCSS configs.
- **package.json / lockfile** – Dependency definitions, including Next.js and Supabase SDK.

##### README for additional insights
- It confirms the use of Next.js, nothing more about architecture beyond default instructions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)"
        direction TB
        Browser["Web Browser"]:::client
        subgraph "React Components"
            direction TB
            Header["Header"]:::frontend
            AuthForm["AuthForm"]:::frontend
            QuestionForm["QuestionForm"]:::frontend
            AnswersSection["AnswersSection"]:::frontend
            UpVoteButton["UpVoteButton"]:::frontend
        end
    end

    %% Next.js Server Layer
    subgraph "Next.js Server" 
        direction TB
        subgraph "App Router (app/)" 
            direction TB
            GlobalLayout["layout.tsx"]:::server
            GlobalsCSS["globals.css"]:::server
            HomePage["page.tsx (/)"]:::server
            AskPage["page.tsx (/ask)"]:::server
            FavoritesPage["page.tsx (/favorites)"]:::server
            LoginPage["page.tsx (/login)"]:::server
            RegisterPage["page.tsx (/register)"]:::server
            QuestionDetailPage["page.tsx (/questions/[id])"]:::server
            ProfilePage["page.tsx (/profile/[username])"]:::server
            NotFoundPage["not-found.tsx"]:::server
        end
        SupabaseClient["lib/supabase.ts"]:::server
    end

    %% Supabase Layer
    subgraph "Supabase"
        direction TB
        AuthService["Auth Service"]:::db
        PostgresDB["PostgreSQL Database"]:::db
    end

    %% CDN / Static Assets
    subgraph "CDN / Static Assets"
        direction TB
        StaticAssets["public/"]:::cdn
    end

    %% Data Flows
    Browser -->|"HTTP GET /ask"| AskPage
    Browser -->|"HTTP GET /"| HomePage
    Browser -->|"HTTP GET /favorites"| FavoritesPage
    Browser -->|"HTTP GET /login"| LoginPage
    Browser -->|"HTTP GET /register"| RegisterPage
    Browser -->|"HTTP GET /questions/:id"| QuestionDetailPage
    Browser -->|"HTTP GET /profile/:username"| ProfilePage
    Browser -->|"HTTP GET static"| StaticAssets

    HomePage -->|"SSR fetch"| SupabaseClient
    AskPage -->|"SSR fetch"| SupabaseClient
    FavoritesPage -->|"SSR fetch"| SupabaseClient
    QuestionDetailPage -->|"SSR fetch"| SupabaseClient
    ProfilePage -->|"SSR fetch"| SupabaseClient

    SupabaseClient -->|"auth.signIn() / auth.signUp()"| AuthService
    SupabaseClient -->|"query(SELECT/INSERT/...)"| PostgresDB
    AuthService -->|"JWT/session"| SupabaseClient
    PostgresDB -->|"data response"| SupabaseClient

    SupabaseClient -->|"HTML payload"| Browser

    Browser -->|"CSR API calls"| SupabaseClient
    Browser -->|"form submit / upvote"| SupabaseClient

    %% Click Events
    click Browser "https://github.com/ridvan-aydin-del/askzone/tree/main/N/A"
    click Header "https://github.com/ridvan-aydin-del/askzone/blob/main/components/Header.tsx"
    click AuthForm "https://github.com/ridvan-aydin-del/askzone/blob/main/components/AuthForm.tsx"
    click QuestionForm "https://github.com/ridvan-aydin-del/askzone/blob/main/components/QuestionForm.tsx"
    click AnswersSection "https://github.com/ridvan-aydin-del/askzone/blob/main/components/AnswersSection.tsx"
    click UpVoteButton "https://github.com/ridvan-aydin-del/askzone/blob/main/components/UpVoteButton.tsx"

    click GlobalLayout "https://github.com/ridvan-aydin-del/askzone/blob/main/app/layout.tsx"
    click GlobalsCSS "https://github.com/ridvan-aydin-del/askzone/blob/main/app/globals.css"
    click HomePage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/page.tsx"
    click AskPage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/ask/page.tsx"
    click FavoritesPage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/favorites/page.tsx"
    click LoginPage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/login/page.tsx"
    click RegisterPage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/register/page.tsx"
    click QuestionDetailPage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/questions/[id]/page.tsx"
    click ProfilePage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/profile/[username]/page.tsx"
    click NotFoundPage "https://github.com/ridvan-aydin-del/askzone/blob/main/app/not-found.tsx"

    click SupabaseClient "https://github.com/ridvan-aydin-del/askzone/blob/main/lib/supabase.ts"
    click StaticAssets "https://github.com/ridvan-aydin-del/askzone/tree/main/public/"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#00539C,color:#003566;
    classDef frontend fill:#E3F6F5,stroke:#3D5A80,color:#293241;
    classDef server fill:#D4F1F4,stroke:#4E8098,color:#1B262C;
    classDef db fill:#FFF4E6,stroke:#E09F3E,color:#5D4037;
    classDef cdn fill:#F0F0F0,stroke:#888888,color:#444444;
```
