How bachelor-group-13/frontend works
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.