# bachelor-group-13/frontend architecture

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

- Interactive diagram: https://gitdiagram.com/bachelor-group-13/frontend
- Repository: https://github.com/bachelor-group-13/frontend

## Overview

##### Project Type and Purpose
- The project is clearly a frontend application built with Next.js using the new app directory routes (pages like auth, garage, profile, etc.).
- It’s focused on a parking system (“Inneparkert”), likely enabling functionalities such as authentication, managing garages, profile management, and interacting with various UI components (such as license plate upload, parking spot detection, etc.).
- The README indicates setup for Supabase credentials, meaning that while this is the frontend, it likely communicates with an external backend/API (Supabase) for data storage and authentication.

##### File Structure
- Top-Level Directories/Files:
- The “app” directory contains the main Next.js pages (including layouts, individual route pages like /auth, /garage, /profile, and a global CSS file), which suggests the primary routing structure.
- The “components” directory contains both general layout/UI components (like navbar, card components, alert dialogs, buttons, and other UI primitives in components/ui) and feature-specific components (e.g., auth-context, license-plate-upload, parking-spot-detection).
- The “hooks” directory contains custom hooks (e.g., useGarageReservations, useLicensePlateDetection, useWebcamCapture) indicating logic abstraction for functional concerns.
- “lib” and “utils” directories provide types, utility functions, and API/auth helpers that support the business logic and integrations.
- Configuration Files: Tools like ESLint, Prettier, Tailwind, and Next.js config files indicate standard practices and code style in a modern React/Next.js frontend.

##### Key Elements
a. Main Components:
- Next.js Application (the “app” folder), which includes:
- Global Layout (app/layout.tsx)
- Pages: Home (app/page.tsx), Authentication (app/auth/page.tsx), Garage (app/garage/page.tsx), Profile (app/profile/page.tsx), and a not-found (app/not-found.tsx).
- Reusable UI Components (in “components” and “components/ui”): navbar, card, alert, avatar, etc.
- Business Logic Hooks (from the “hooks” directory) to capture functionalities like license plate detection, webcam capture, and garage reservations.
- Utility Modules (from “lib” and “utils”) that handle API calls, authentication, and helper functions.
- External Services Integration: The configuration for Supabase suggests that there is an API layer (possibly abstracted in utils/api.ts) for handling backend data interactions.

b. Relationships & Data Flow:
- The Next.js pages (in the “app” folder) use the reusable UI components from the “components” directories.
- Hooks are used within the pages and components to encapsulate business logic (e.g., initiating webcam capture, sending data for license plate detection, or handling reservation logic).
- Auth context (components/auth-context.tsx) is likely used to manage user state across multiple pages.

c. Architectural Patterns & Design Principles:
- Modular Structure: The project is structured to separate concerns clearly across pages, components, hooks, and utilities.
- MVC/Component-based Design: The Next.js pages serve as the “controller/views”, with components handling the UI and hooks fulfilling business logic.
- Reusability: The “components/ui” folder exemplifies a reusable component system, which is enhanced by the custom hooks in “hooks” to keep business logic decoupled from UI.

d. Relevant Technologies:
- Next.js for SSR and React-based component management.
- Tailwind CSS (configured via tailwind.config.ts) for styling.
- Supabase (as indicated by the environment variables in the README) for backend services.
- ESLint, Prettier for code quality/linting.
- pnpm as the package manager.

- For each page, indicate which UI components are being used (like the navbar or card components). You might also show that pages access the auth context.
- From the UI level, illustrate which hooks are invoked and then show how these hooks connect to utility functions.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Next.js Application"
        NL["Global Layout"]:::page
        HP["Home Page"]:::page
        AP["Auth Page"]:::page
        GP["Garage Page"]:::page
        PP["Profile Page"]:::page
        NP["404 Page"]:::page
    end

    subgraph "Reusable UI Components"
        NB["Navbar"]:::component
        AD["Alert Dialog"]:::component
        AL["Alert"]:::component
        AV["Avatar"]:::component
        BT["Button"]:::component
        CD["Card"]:::component
        DM["Dropdown Menu"]:::component
        HC["Hover Card"]:::component
        IP["Input"]:::component
        LB["Label"]:::component
        TB["Tabs"]:::component
    end

    subgraph "Feature-Specific Components"
        AC["Authentication Context"]:::component
        LP["License Plate Upload"]:::component
        PSD["Parking Spot Detection"]:::component
        GL["Garage Layout"]:::component
        CSV["Car Spot Visuals"]:::component
        PC["ParkingSpot Card"]:::component
    end

    subgraph "Business Logic Hooks"
        GHR["useGarageReservations"]:::hook
        LHD["useLicensePlateDetection"]:::hook
        WHC["useWebcamCapture"]:::hook
    end

    subgraph "Utilities & Helpers"
        API["API Integration"]:::util
        AH["Auth Helpers"]:::util
        UT["Additional Functions"]:::util
        TD["Type Definitions"]:::util
        GU["General Utilities"]:::util
    end

    subgraph "External Service"
        SUP["Supabase"]:::external
    end

    %% Next.js Application connections
    NL -->|"includes"| HP
    NL -->|"includes"| AP
    NL -->|"includes"| GP
    NL -->|"includes"| PP
    NL -->|"includes"| NP
    NL -->|"includes"| NB

    %% Page to Feature-Specific Components
    AP -->|"uses"| AC
    HP -->|"uses"| LP
    HP -->|"uses"| PSD
    GP -->|"uses"| GL
    GP -->|"uses"| CSV
    GP -->|"uses"| PC

    %% Page to Reusable UI Components
    HP -->|"uses"| AD
    HP -->|"uses"| AL
    HP -->|"uses"| AV
    AP -->|"uses"| BT
    GP -->|"uses"| CD
    PP -->|"uses"| DM

    %% UI Components to Business Logic Hooks
    NB -->|"triggers"| GHR
    CD -->|"triggers"| LHD
    DM -->|"triggers"| WHC

    %% Hooks to Utilities
    GHR -->|"calls"| API
    LHD -->|"calls"| API
    WHC -->|"calls"| API

    %% Feature-Specific Component to Utilities
    AC -->|"manages"| AH

    %% Utilities to External Service
    API -->|"connects"| SUP
    AH -->|"connects"| SUP

    %% Styles
    classDef page fill:#f9d6d5,stroke:#333,stroke-width:2px;
    classDef component fill:#c1f7c1,stroke:#333,stroke-width:2px;
    classDef hook fill:#d1d1f9,stroke:#333,stroke-width:2px;
    classDef util fill:#fff2b2,stroke:#333,stroke-width:2px;
    classDef external fill:#ffd2ec,stroke:#333,stroke-width:2px;

click NL "https://github.com/bachelor-group-13/frontend/blob/main/app/layout.tsx"
click HP "https://github.com/bachelor-group-13/frontend/blob/main/app/page.tsx"
click AP "https://github.com/bachelor-group-13/frontend/blob/main/app/auth/page.tsx"
click GP "https://github.com/bachelor-group-13/frontend/blob/main/app/garage/page.tsx"
click PP "https://github.com/bachelor-group-13/frontend/blob/main/app/profile/page.tsx"
click NP "https://github.com/bachelor-group-13/frontend/blob/main/app/not-found.tsx"
click NB "https://github.com/bachelor-group-13/frontend/blob/main/components/navbar.tsx"
click AD "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/alert-dialog.tsx"
click AL "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/alert.tsx"
click AV "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/avatar.tsx"
click BT "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/button.tsx"
click CD "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/card.tsx"
click DM "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/dropdown-menu.tsx"
click HC "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/hover-card.tsx"
click IP "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/input.tsx"
click LB "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/label.tsx"
click TB "https://github.com/bachelor-group-13/frontend/blob/main/components/ui/tabs.tsx"
click AC "https://github.com/bachelor-group-13/frontend/blob/main/components/auth-context.tsx"
click LP "https://github.com/bachelor-group-13/frontend/blob/main/components/license-plate-upload.tsx"
click PSD "https://github.com/bachelor-group-13/frontend/blob/main/components/parking-spot-detection.tsx"
click GL "https://github.com/bachelor-group-13/frontend/blob/main/components/garage-layout.tsx"
click CSV "https://github.com/bachelor-group-13/frontend/blob/main/components/carspot-visuals.tsx"
click PC "https://github.com/bachelor-group-13/frontend/blob/main/components/parkingspot-card.tsx"
click GHR "https://github.com/bachelor-group-13/frontend/blob/main/hooks/useGarageReservations.ts"
click LHD "https://github.com/bachelor-group-13/frontend/blob/main/hooks/useLicensePlateDetection.ts"
click WHC "https://github.com/bachelor-group-13/frontend/blob/main/hooks/useWebcamCapture.ts"
click API "https://github.com/bachelor-group-13/frontend/blob/main/utils/api.ts"
click AH "https://github.com/bachelor-group-13/frontend/blob/main/utils/auth.ts"
click UT "https://github.com/bachelor-group-13/frontend/blob/main/utils/helpers.ts"
click TD "https://github.com/bachelor-group-13/frontend/blob/main/lib/types.ts"
click GU "https://github.com/bachelor-group-13/frontend/blob/main/lib/utils.ts"
```
