# brydzzz/polizarcie architecture

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

- Interactive diagram: https://gitdiagram.com/brydzzz/polizarcie
- Repository: https://github.com/brydzzz/polizarcie

## Overview

##### Project Type and Purpose
- Poliżarcie is a full-stack web platform built with Next.js aimed at helping WUT students discover new eating venues, use an interactive map, write reviews, and even match with other users based on taste.
- The README lists a rich set of integrated technologies (Next.js, React, TypeScript, Redux, Prisma, PostgreSQL, Supabase, AuthJS, Docker, etc.) which indicate that both a dynamic UI and extensive backend logic are in place.

##### Main Components
a. Frontend/UI Layer:
- Represented by the Next.js application in the “app” directory and the “components” folder.
- Subgroups for:
- Auth pages and components (found under app/(content)/auth and components/auth)
- Browsing, maps, restaurant pages, dashboard pages, and profile pages.
- Various UI elements such as buttons, cards, modals, inputs, headers, sidebars, snackbars, and sections.
- That styling is mostly handled via CSS modules (seen in *.module.scss files) and that the UI integrates with multiple libraries (React, Redux, etc.).

b. Backend/API Layer:
- API endpoints under app/api (specifically for authentication through AuthJS).
- Business logic components and server-specific code (e.g., middleware.ts, next.config.ts, providers.tsx).
- Point out components under the “lib” folder that encapsulate business logic, authentication (lib/auth.ts) and database interactions.

c. Database and ORM:
- Prisma integration by including the prisma folder which contains the schema (prisma/schema.prisma), seeding scripts, and CSV data.
- That Prisma is used as the ORM to interface with a PostgreSQL database (supported by the README images and technology list).

d. State Management and Data Handling:
- Redux-based state management and related store components (lib/store, components that utilize Redux hooks).
- How data flows from database queries (via Prisma) to UI components, often through API endpoints.

e. External Services and Integrations:
- External libraries/services such as:
- AuthJS for authentication (seen in the API routes and auth.ts files).
- Supabase and its image modules (lib/supabase, components/images).
- OpenStreetMap/OpenLayers for map functionalities (referenced in the README images).
- Docker bundled with a Dockerfile for containerized deployment.

##### Relationships and Data Flow
- Link the Backend/API to the Database layer where Prisma acts as the intermediary. Show two-way communication if there is real-time data synchronization.
- For dynamic and asynchronous data, illustrate how state management via Redux handles client-side data and interacts with the API.
- Connectors from the UI components to external services like AuthJS and Supabase to represent authentication and media handling.

##### Architectural Patterns and Design Principles
- Separation of concerns: clear division between view (React components and pages), application logic (API and lib layers), and data persistence (Prisma/Database).
- Modular structure found within directories (e.g., auth, dev, dashboard, and other domain-specific modules) that may follow a component-based architecture aligning with React/Next.js best practices.
- The file structure suggests an MVC-like separation — with “pages” acting as controllers, “components” as views, and API/lib/prisma acting as models/data access layers.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend Layer"
        NextPages["Next.js Pages & UI"]:::frontend
        UIComp["UI Components"]:::frontend
        subgraph "Auth Module (AuthJS)"
            AuthPages["Auth Pages"]:::frontend
            AuthComp["Auth Components"]:::frontend
            AuthConfig["Auth Configuration"]:::frontend
        end
        Redux["Redux Store"]:::frontend
    end

    subgraph "Backend/API Layer"
        API["API Endpoints"]:::backend
        Middleware["Server/Middleware"]:::backend
        BizLogic["Business Logic Modules"]:::backend
    end

    subgraph "Database Layer"
        Prisma["Prisma Integration"]:::database
        PrismaUtil["Prisma Utility"]:::database
        PostgreSQL["PostgreSQL Database"]:::database
    end

    subgraph "External Services"
        Supabase["Supabase Integration"]:::external
        MapInt["Map Integration"]:::external
        AuthJS["AuthJS Service"]:::external
    end

    subgraph "Deployment & DevOps"
        Docker["Docker Containerization"]:::deployment
    end

    %% Data Flow Connections
    NextPages -->|"UserRequest"| API
    UIComp -->|"UserRequest"| API
    AuthPages -->|"AuthRequest"| API
    API -->|"DatabaseQuery"| Prisma
    Prisma -->|"DataReply"| API
    API -->|"BusinessLogicCall"| BizLogic
    BizLogic -->|"PrismaUtilCall"| PrismaUtil
    Prisma -->|"DataStorage"| PostgreSQL
    API -->|"StateUpdate"| Redux
    UIComp -->|"UsesState"| Redux
    NextPages -->|"ImageRequest"| Supabase
    NextPages -->|"MapData"| MapInt
    API -->|"AuthValidation"| AuthJS

    %% Deployment Connections
    Docker -->|"Deploys"| NextPages
    Docker -->|"Deploys"| UIComp
    Docker -->|"Deploys"| API
    Docker -->|"Deploys"| Prisma
    Docker -->|"Deploys"| Supabase

    %% Click Events
    click NextPages "https://github.com/brydzzz/polizarcie/tree/main/app/(content)"
    click UIComp "https://github.com/brydzzz/polizarcie/tree/main/components"
    click AuthPages "https://github.com/brydzzz/polizarcie/tree/main/app/(content)/auth"
    click AuthComp "https://github.com/brydzzz/polizarcie/tree/main/components/auth"
    click AuthConfig "https://github.com/brydzzz/polizarcie/blob/main/auth.config.ts"
    click API "https://github.com/brydzzz/polizarcie/blob/main/app/api/auth/[...nextauth]/route.ts"
    click Middleware "https://github.com/brydzzz/polizarcie/blob/main/middleware.ts"
    click BizLogic "https://github.com/brydzzz/polizarcie/tree/main/lib"
    click Prisma "https://github.com/brydzzz/polizarcie/tree/main/prisma"
    click PrismaUtil "https://github.com/brydzzz/polizarcie/blob/main/prisma.ts"
    click Redux "https://github.com/brydzzz/polizarcie/tree/main/lib/store"
    click Supabase "https://github.com/brydzzz/polizarcie/tree/main/lib/supabase"
    click MapInt "https://github.com/brydzzz/polizarcie/tree/main/app/(content)/map"
    click Docker "https://github.com/brydzzz/polizarcie/tree/main/Dockerfile"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#000,stroke-width:2px;
    classDef database fill:#D7BDE2,stroke:#000,stroke-width:2px;
    classDef external fill:#A9DFBF,stroke:#000,stroke-width:2px;
    classDef deployment fill:#F5B7B1,stroke:#000,stroke-width:2px;
```
