# jaye29dphy/fibo architecture

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

- Interactive diagram: https://gitdiagram.com/jaye29dphy/fibo
- Repository: https://github.com/jaye29dphy/fibo

## Overview

##### Project Overview and Purpose
- FIBO is a full-stack application designed to let users search for, book, and manage sports field reservations.
- It emphasizes efficiency and simplicity for booking sports fields, providing information on pricing, availability, and user reviews.
- The project is split into a backend (Node.js/TypeScript API server) and a frontend (React/TypeScript app, likely targeting mobile given the app.json and usage of .tsx in a layout and tab components).

##### Main Components
- Frontend Application:
- Represents the user interface where customers interact with the app.
- Contains various screens/pages such as registration, dashboard, calendar views, profile, and booking details.
- Organized into a structured folder with components, hooks, assets, and constants to implement the UI and state management.
- Backend API Server:
- Built in Node.js with TypeScript, handling business logic and REST API endpoints.
- Key layers include:
- Routes: (authRoutes, calendarRoutes, courtRoutes) that define the API endpoints.
- Controllers: (authController, calendarController, courtController) that execute business logic.
- Middleware: For authentication (authMiddleware) to secure endpoints.
- Configuration: Database configuration and environment variables.
- Utility modules: Example – sendEmail for notifications.
- Database (and possibly other external services):
- While the file tree shows a database configuration, the actual DB choice isn’t explicitly mentioned. However, it is a core component, as the backend’s config indicates connectivity with the underlying database.
- Optional Integration/Build Layers:
- Build artifacts (dist folder) and configuration files (tsconfig.json, package.json) denote the build and deployment aspects.

##### Relationships and Interactions
- The Frontend communicates with the Backend over HTTP/HTTPS through clearly defined API endpoints.
- The Backend uses Controllers and Routes to process requests, applying Middleware for authentication and validation before interacting with the database.
- Data flows from the client to the server (routing, controller processing) and then onto persistent storage (database).
- Utility functionalities like email notifications tie into the flow as side operations.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear separation between frontend and backend functionalities.
- MVC-like structure in the backend:
- Routes handle incoming requests.
- Controllers process business logic.
- Middleware enforces security and auth.
- Use of TypeScript across both the frontend and backend for type safety and maintainability.
- Modular design: Both frontend and backend are split into logical modules (controllers, routes, hooks, components, etc.), which makes each component independently understandable and extensible.

- Clear labels for each major component (Frontend, Backend – subdivided into Routes, Controllers, Middleware, Database).
- Keep your representation modular, detailing how components communicate rather than devolving into implementation intricacies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1["App (UI)"]:::frontend
        FE2["Components"]:::frontend
        FE3["Hooks"]:::frontend
        FE4["Constants"]:::frontend
        FE5["User Registration Screen"]:::frontend
        FE6["Dashboard & Booking"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE1["Backend API Server"]:::backend
        subgraph "Routes"
            R1["authRoutes"]:::backend
            R2["calendarRoutes"]:::backend
            R3["courtRoutes"]:::backend
        end
        subgraph "Controllers"
            C1["authController"]:::backend
            C2["calendarController"]:::backend
            C3["courtController"]:::backend
        end
        BE2["Auth Middleware"]:::backend
        BE3["Utility: sendEmail"]:::backend
        BE4["Database Config"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["Database"]:::database
    end

    %% Flow Connections between layers
    FE1 -->|"HTTPRequests"| R1
    FE1 -->|"HTTPRequests"| R2
    FE1 -->|"HTTPRequests"| R3

    R1 -->|"Calls"| C1
    R2 -->|"Calls"| C2
    R3 -->|"Calls"| C3

    BE2 -->|"Verifies"| R1
    BE2 -->|"Verifies"| R2
    BE2 -->|"Verifies"| R3

    C1 -->|"DBQuery"| DB
    C2 -->|"DBQuery"| DB
    C3 -->|"DBQuery"| DB

    C1 -->|"SendsEmail"| BE3
    C2 -->|"SendsEmail"| BE3
    C3 -->|"SendsEmail"| BE3

    BE4 -->|"Configures"| DB

    FE5 -.-> FE1
    FE6 -.-> FE1

    %% Click Events for Frontend
    click FE1 "https://github.com/jaye29dphy/fibo/tree/main/frontend/app"
    click FE2 "https://github.com/jaye29dphy/fibo/tree/main/frontend/components"
    click FE3 "https://github.com/jaye29dphy/fibo/tree/main/frontend/hooks"
    click FE4 "https://github.com/jaye29dphy/fibo/tree/main/frontend/constants"

    %% Click Events for Backend and related components
    click BE1 "https://github.com/jaye29dphy/fibo/tree/main/backend/src"
    click R1 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/routes/authRoutes.ts"
    click R2 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/routes/calendarRoutes.ts"
    click R3 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/routes/courtRoutes.ts"
    click C1 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/controllers/authController.ts"
    click C2 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/controllers/calendarController.ts"
    click C3 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/controllers/courtController.ts"
    click BE2 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/middleware/authMiddleware.ts"
    click BE4 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/config/database.ts"
    click BE3 "https://github.com/jaye29dphy/fibo/blob/main/backend/src/utils/sendEmail.ts"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#ABEBC6,stroke:#1D8348,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
```
