# alicangunduz/nacizane architecture

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

- Interactive diagram: https://gitdiagram.com/alicangunduz/nacizane
- Repository: https://github.com/alicangunduz/nacizane

## Overview

##### Project Type & Purpose
- The project is a full-stack web application built with Next.js (ReactJS and TypeScript) meant for users to give and receive anonymous, honest, and constructive feedback.
- It includes user authentication via NextAuth integrated with GitHub OAuth, utilizes Prisma for database interactions with PostgreSQL, and uses the Gemini API for additional functionality (likely in feedback moderation).

##### Analyzing the File Structure to Identify Main Components
- Frontend Components:
- The “app” directory contains Next.js pages and layouts (e.g., app/page.tsx, layout.tsx) along with specialized pages for user profiles (app/[username]/page.tsx) and settings (app/ayarlar/page.tsx).
- The “app/components” directory includes components for the landing page (Header, Footer, Announcement, ProfileCard) and user-specific components (FeedbackForm, FeedbackComment).
- Global styling via “app/globals.css” and additional UI components in the “components/ui” directory offer building blocks (e.g., button, card, input).
- Backend/API:
- Within “app/api”, there are segments for authentication (app/api/auth/[...nextauth]/route.ts) and user related endpoints (feedback send, delete, update). This separation clearly indicates dedicated backend API routes to manage authentication, user updates, and feedback processing.
- Utility & Infrastructure:
- The “app/utils” directory contains helper functions (auth, db, token, user ID retrieval) that likely abstract the database and authentication details.
- “lib” contains additional utility code (random author name generation, utils), which might be used across various parts of the system.
- Database & ORM:
- Prisma configuration, including the schema (prisma/schema.prisma) and migrations, point out the use of a structured relational PostgreSQL database.
- Authentication:
- NextAuth is integrated as seen in app/api/auth, specifying GitHub OAuth configuration.
- Additional modules:
- There are configuration files (package.json, next.config.mjs, tailwind.config.ts, tsconfig.json, etc.) that indicate the environment and build configurations.

a. Main Components:
- Frontend:
- Pages / Views (e.g., Landing page, User Profile, Settings, Privacy and Terms pages)
- UI Components (buttons, forms, cards, etc.)
- Backend API:
- Authentication API (NextAuth with GitHub OAuth)
- User Feedback API (sending, deleting feedback)
- User Update API (profile or settings updates)
- Database:
- PostgreSQL managed via Prisma (schema, migrations)
- Third-Party Services:
- Gemini API (for AI moderation)
- GitHub OAuth for authentication
b. Relationships & Interactions:
- The frontend (Next.js pages and components) makes HTTP requests to backend API endpoints.
- The authentication component is responsible for managing user sessions via NextAuth.
- Upon feedback submission, data flows from the client to the appropriate API route that processes and validates data (possibly moderated through the Gemini API) before saving it via Prisma to the PostgreSQL database.
- User updates follow a similar flow.
c. Architectural Patterns and Design Principles:
- The project follows a typical full-stack architecture with separation of concerns: view (pages/components) vs. business logic (API routes) vs. data access (Prisma/database).
- It leverages API routes in Next.js for a serverless or microservice-like backend.
- Modular UI components are used (organized in separate folders) to improve reusability and maintainability.
d. Technologies, Frameworks, Libraries:
- Frontend: ReactJS/Next.js, TypeScript, Tailwind CSS for styling.
- Backend: Next.js API routes, NextAuth for authentication.
- Data Layer: Prisma ORM with PostgreSQL.
- Additional Libraries: Various UI components, Gemini API integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Client (Browser)"]:::clientStyle
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        Pages["Pages & Routing"]:::frontend
        UI["UI Components"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        AuthAPI["Authentication API (NextAuth)"]:::api
        FeedbackAPI["User Feedback API (Send/Delete)"]:::api
        UpdateAPI["User Update API"]:::api
    end

    %% Business Logic & Utilities
    subgraph "Business Logic & Utilities"
        Utilities["Utilities & Helpers"]:::utils
    end

    %% Database Layer
    subgraph "Database Layer"
        Database["Prisma/PostgreSQL Database"]:::database
    end

    %% External Services
    subgraph "External Services"
        GitHub["GitHub OAuth"]:::external
        Gemini["Gemini Moderation Service"]:::external
    end

    %% Data Flow
    Browser -->|"UserRequest"| Pages
    Browser -->|"Interaction"| UI

    Pages -->|"CallsAuth"| AuthAPI
    UI -->|"TriggersAuth"| AuthAPI

    Pages -->|"SubmitsFeedback"| FeedbackAPI
    UI -->|"FeedbackForm"| FeedbackAPI

    AuthAPI -->|"DBQuery"| Database
    FeedbackAPI -->|"DBUpdate"| Database
    UpdateAPI -->|"DBUpdate"| Database

    AuthAPI -->|"OAuthFlow"| GitHub
    FeedbackAPI -->|"ModerationCheck"| Gemini

    Pages -->|"UsesUtils"| Utilities
    UI -->|"UsesUtils"| Utilities
    Utilities -->|"SupportAuth"| AuthAPI
    Utilities -->|"SupportFeedback"| FeedbackAPI
    Utilities -->|"SupportUpdate"| UpdateAPI

    %% Click Events for Component Mapping
    click Pages "https://github.com/alicangunduz/nacizane/blob/main/app/page.tsx"
    click Pages "https://github.com/alicangunduz/nacizane/blob/main/app/[username]/page.tsx"
    click Pages "https://github.com/alicangunduz/nacizane/blob/main/app/ayarlar/page.tsx"
    click Pages "https://github.com/alicangunduz/nacizane/blob/main/app/gizlilik-politikasi/page.tsx"
    click Pages "https://github.com/alicangunduz/nacizane/blob/main/app/kullanim-kosullari/page.tsx"

    click UI "https://github.com/alicangunduz/nacizane/tree/main/app/components"
    click UI "https://github.com/alicangunduz/nacizane/tree/main/components/ui"

    click AuthAPI "https://github.com/alicangunduz/nacizane/blob/main/app/api/auth/[...nextauth]/route.ts"

    click FeedbackAPI "https://github.com/alicangunduz/nacizane/blob/main/app/api/user/feedback/send/route.ts"
    click FeedbackAPI "https://github.com/alicangunduz/nacizane/blob/main/app/api/user/feedback/delete/route.ts"

    click UpdateAPI "https://github.com/alicangunduz/nacizane/blob/main/app/api/user/update/route.ts"

    click Utilities "https://github.com/alicangunduz/nacizane/tree/main/app/utils"
    click Utilities "https://github.com/alicangunduz/nacizane/tree/main/lib"

    click Database "https://github.com/alicangunduz/nacizane/blob/main/prisma/schema.prisma"
    click Database "https://github.com/alicangunduz/nacizane/tree/main/prisma/migrations"

    %% Legend
    subgraph "Legend"
        L1["Client Layer: #ffcc00"] 
        L2["Frontend Layer: #a2d2ff"]
        L3["API Layer: #bde0fe"]
        L4["Utilities: #dcedc1"]
        L5["Database: #ffc9de"]
        L6["External Services: #fcbf49"]
    end

    %% Styles
    classDef clientStyle fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef frontend fill:#a2d2ff,stroke:#333,stroke-width:2px;
    classDef api fill:#bde0fe,stroke:#333,stroke-width:2px;
    classDef utils fill:#dcedc1,stroke:#333,stroke-width:2px;
    classDef database fill:#ffc9de,stroke:#333,stroke-width:2px;
    classDef external fill:#fcbf49,stroke:#333,stroke-width:2px;
```
