# michellbrito/golfmini architecture

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

- Interactive diagram: https://gitdiagram.com/michellbrito/golfmini
- Repository: https://github.com/michellbrito/golfmini

## Overview

##### Main Components

a) Frontend Layer (Next.js Client):
- Pages (app directory - Next.js 13+ structure)
- Components (UI & Feature Components)
- Utils

b) Backend Layer (Express Server):
- API Routes
- Prisma ORM Layer
- Utils

c) Database Layer:

##### Component Relationships

- Frontend → Backend: HTTP requests to API endpoints (/locations)
- Backend → Database: Prisma ORM queries
- Request/response flow for the main features:
- Location search flow
- Photo viewing flow

##### Specific Implementation Details

Frontend Section:
**┌─ Next.js Frontend ─────────────────┐**
- Pages                           │
- Main Page (page.jsx)         │
- Components                      │
- Filters                      │
- Gallery                      │
- Navbar                       │
- UI Components               │
- Utils                          │
- ┘

Backend Section:
**┌─ Express Backend ─────────────────┐**
- API Routes                     │
- /locations                  │
- /locations/:id             │
- Prisma ORM                     │
- Database Utils                 │
- ┘

##### Additional Elements

Environment Variables Section:
- Configuration dependencies between components
- NEXT_PUBLIC_API_URL and DATABASE_URL

API Layer Details:
- Query parameters for /locations endpoint
- Pagination implementation

##### Important Architectural Patterns to Highlight

- Client-Server Architecture
- RESTful API design
- Component-based UI architecture
- Database migration system (Prisma)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        MainPage["Main Page"]
        Layout["Layout"]
        subgraph Components
            Filters["Filters Component"]
            Gallery["Gallery Component"]
            Navbar["Navbar Component"]
            subgraph UIComponents["UI Components"]
                Button["Button"]
                Dialog["Dialog"]
                Pagination["Pagination"]
                Select["Select"]
            end
        end
        FrontendUtils["Frontend Utils"]
    end

    subgraph Backend
        Server["Express Server"]
        subgraph Routes
            MainRoutes["Main Routes"]
            LocationsAPI["/locations API"]
        end
        DBUtils["Database Utils"]
    end

    subgraph Database
        PrismaORM["Prisma ORM"]
        PrismaSchema["Schema"]
        Migrations["Migrations"]
        MySQL[(MySQL Database)]
    end

    %% Frontend Relationships
    MainPage --> Filters
    MainPage --> Gallery
    MainPage --> Navbar
    Filters --> UIComponents
    Gallery --> UIComponents
    Navbar --> UIComponents

    %% Backend Relationships
    Server --> Routes
    MainRoutes --> LocationsAPI
    LocationsAPI --> PrismaORM
    PrismaORM --> MySQL
    DBUtils --> MySQL

    %% Cross-layer Communication
    Frontend --> Backend
    
    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333
    classDef backend fill:#90EE90,stroke:#333
    classDef database fill:#FFB347,stroke:#333
    classDef ui fill:#DDA0DD,stroke:#333

    class MainPage,Layout,Filters,Gallery,Navbar,FrontendUtils frontend
    class Server,MainRoutes,LocationsAPI,DBUtils backend
    class PrismaORM,PrismaSchema,Migrations,MySQL database
    class Button,Dialog,Pagination,Select,UIComponents ui

    %% Click Events
    click MainPage "https://github.com/michellbrito/golfmini/blob/main/client/app/page.jsx"
    click Layout "https://github.com/michellbrito/golfmini/blob/main/client/app/layout.jsx"
    click Filters "https://github.com/michellbrito/golfmini/blob/main/client/components/Filters/index.jsx"
    click Gallery "https://github.com/michellbrito/golfmini/blob/main/client/components/Gallery/index.jsx"
    click Navbar "https://github.com/michellbrito/golfmini/blob/main/client/components/Navbar/index.jsx"
    click UIComponents "https://github.com/michellbrito/golfmini/tree/main/client/components/ui/"
    click FrontendUtils "https://github.com/michellbrito/golfmini/blob/main/client/utils/index.js"
    click Server "https://github.com/michellbrito/golfmini/blob/main/server/server.js"
    click MainRoutes "https://github.com/michellbrito/golfmini/blob/main/server/routes/index.js"
    click LocationsAPI "https://github.com/michellbrito/golfmini/blob/main/server/routes/locations.js"
    click PrismaSchema "https://github.com/michellbrito/golfmini/blob/main/server/prisma/schema.prisma"
    click DBUtils "https://github.com/michellbrito/golfmini/blob/main/server/utils/db.js"
    click Migrations "https://github.com/michellbrito/golfmini/tree/main/server/prisma/migrations/"
    click Button "https://github.com/michellbrito/golfmini/blob/main/client/components/ui/button.jsx"
    click Dialog "https://github.com/michellbrito/golfmini/blob/main/client/components/ui/dialog.jsx"
    click Pagination "https://github.com/michellbrito/golfmini/blob/main/client/components/ui/pagination.jsx"
    click Select "https://github.com/michellbrito/golfmini/blob/main/client/components/ui/select.jsx"
```
