# pankajkumardev/feedwall architecture

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

- Interactive diagram: https://gitdiagram.com/pankajkumardev/feedwall
- Repository: https://github.com/pankajkumardev/feedwall

## Overview

##### Main Components
- Frontend: Represented by the Next.js components in the “app” folder (pages, layouts, and specific UI modules such as the widget in components/ui). This is where the feedback widget and other user interface elements (e.g., Hero, Navigation, Footer) live.
- API/Backend: The “app/api” directory holds the Next.js API routes for authentication, feedback handling, and user-related actions. This layer serves as the intermediary between the UI and the database.
- Database Layer: The “prisma” folder (along with the schema and migrations) represents the database layer, which is most likely a PostgreSQL instance accessed via Prisma in “lib/db.ts” or related files.
- Business Logic & Services: In the “app/actions” directory, you find the business logic for operations such as creating and deleting projects or feedback. Additionally, integration with external AI services (Gemini API) for generating insights is an important service component.
- External Services/Integrations: Include NextAuth (for authentication), Gemini API (for AI insights), and any external communication like deployment on Vercel.
- Configuration & DevOps: Files such as Dockerfile, .env.example, next.config.ts, and various config files indicate containerization, environment configuration, and deployment strategies.

##### Relationships and Interactions
- The User interacts with the frontend (web pages in the “app” directory). The widget is embedded in external projects.
- The frontend makes HTTP (or AJAX) requests to the backend API routes (e.g., “app/api/feedback/route.ts”).
- API routes process these requests, invoking business logic (located in “app/actions”) and interacting with the database using Prisma (via “lib/db.ts”).
- Authentication middleware is provided by NextAuth in “app/api/auth/[...nextauth]”.
- External integration with the Gemini API enhances functionality by processing feedback to generate AI-driven insights.
- All these components are connected via well-defined data flows; e.g., user input → frontend widget → API route → database operations → optional AI processing → response back to the frontend.

##### Architectural Patterns and Key Principles
- Separation of Concerns: The project clearly separates UI (Next.js pages/components), API (server-side functions), and data access (Prisma).
- Component-based Structure: The use of React components, especially with a designated “components” folder, shows the component-based UI architecture.
- API Layer Encapsulation: The API routes in “app/api” handle specific concerns like authentication, feedback, and user data.
- Modern Full-Stack Design: Integration of server components (Next.js API routes) with client components (The UI in “app” and “components”) reflects a modern approach where the boundary between frontend and backend is managed seamlessly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entity
    U("User"):::user

    %% Presentation Layer
    subgraph "Presentation Layer"
        FE("Frontend (Next.js UI)"):::presentation
        FW("Feedback Widget"):::presentation
    end

    %% API/Backend Layer
    subgraph "API/Backend Layer"
        APIAuth("API: Auth (NextAuth)"):::api
        APIFeedback("API: Feedback"):::api
        APIUser("API: User"):::api
    end

    %% Business Logic & Services
    subgraph "Business Logic & Services"
        Actions("Business Logic (Actions)"):::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DB("Database (PostgreSQL via Prisma)"):::data
        ORM("Prisma Client (lib/db.ts)"):::data
    end

    %% External Services
    subgraph "External Services"
        Gemini("AI Integration (Gemini API)"):::external
        NextAuth("Authentication (NextAuth)"):::external
    end

    %% DevOps & Deployment
    subgraph "DevOps & Deployment"
        Config("Config & Containerization"):::devops
        Vercel("Deployment (Vercel)"):::devops
    end

    %% Connections
    U --> FE
    FE --> FW
    FE --> APIAuth
    FE --> APIFeedback
    FE --> APIUser

    APIAuth --> NextAuth
    APIFeedback --> Actions
    APIUser --> Actions

    Actions --> DB
    Actions --> ORM
    Actions --> Gemini

    %% DevOps connections
    FE --> Config
    APIAuth --> Config
    APIFeedback --> Config
    APIUser --> Config
    Actions --> Config
    Config --> Vercel

    %% Styles
    classDef user fill:#B5838D,stroke:#6D6875,stroke-width:2px
    classDef presentation fill:#A8DADC,stroke:#457B9D,stroke-width:2px
    classDef api fill:#F4A261,stroke:#E76F51,stroke-width:2px
    classDef business fill:#E9C46A,stroke:#F4A261,stroke-width:2px
    classDef data fill:#8ec07c,stroke:#458588,stroke-width:2px
    classDef external fill:#D4A5A5,stroke:#d49982,stroke-width:2px
    classDef devops fill:#C0C0C0,stroke:#808080,stroke-width:2px

    %% Click Events
    click FE "https://github.com/pankajkumardev/feedwall/tree/main/app"
    click FW "https://github.com/pankajkumardev/feedwall/blob/main/components/ui/FeedbackWidget.tsx"
    click APIAuth "https://github.com/pankajkumardev/feedwall/blob/main/app/api/auth/[...nextauth]/route.ts"
    click APIFeedback "https://github.com/pankajkumardev/feedwall/blob/main/app/api/feedback/route.ts"
    click APIUser "https://github.com/pankajkumardev/feedwall/blob/main/app/api/user/route.ts"
    click Actions "https://github.com/pankajkumardev/feedwall/tree/main/app/actions"
    click DB "https://github.com/pankajkumardev/feedwall/tree/main/prisma"
    click ORM "https://github.com/pankajkumardev/feedwall/blob/main/lib/db.ts"
    click Gemini "https://github.com/pankajkumardev/feedwall/blob/main/app/actions/Ai.ts"
    click NextAuth "https://github.com/pankajkumardev/feedwall/blob/main/app/api/auth/[...nextauth]"
    click Config "https://github.com/pankajkumardev/feedwall/tree/main/Dockerfile"
```
