# cis3296s25/tuquiet architecture

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

- Interactive diagram: https://gitdiagram.com/cis3296s25/tuquiet
- Repository: https://github.com/cis3296s25/tuquiet

## Overview

##### Main Components
- Frontend:
- Represented by the frontend directory.
- Uses ReactJS (App.jsx, various component files like BuildingCard.jsx, ReportingForm.jsx, Sidebar.jsx, etc.) and Vite for development.
- Serves the user interface where students can view study space data and submit reports.
- Backend:
- Represented by the backend directory.
- Implemented in Java using Spring Boot. Key elements include:
◦ Main application class (App.java) indicating the entry point.
◦ Controller package (with ReportController.java) which exposes RESTful endpoints for receiving and serving reports.
◦ Configuration package (with WebConfig.java) that sets cross-cutting settings for the web layer.
- Includes test classes and configuration files (e.g., application.properties).
- Database:
- While not explicitly visible as a running service in the file tree, the presence of SQL files (createTables.sql) indicates that a relational database is used for storing study space reports and possibly other user data.
- Deployment/Execution Elements:
- The README explains how to run the backend (via a Spring Boot jar file) and the frontend (npm-driven development server), which implies that the system is deployed as two separate services that interact via HTTP calls (likely REST APIs).

##### Relationships and Interactions
- User Interaction:
- Users interact with the frontend (React application) through browser-based interfaces.
- API Communication:
- The frontend sends HTTP requests (e.g., via fetch or axios) to the backend’s REST endpoints, handled by controllers like ReportController.
- Data Persistence:
- The backend manages state/data (e.g., noise levels, crowdedness reports) and persists them in a relational database (set up using the provided SQL scripts).
- Configuration and Environment:
- There is a clear separation of concerns. Backend components (controller, configuration, and tests) and frontend components (views, pages, components) are modularized, reflecting common best practices in web app architecture.

##### Architectural Patterns & Key Design Principles
- Separation of Concerns:
- Distinct responsibilities are maintained for the frontend (presentation/UI) and backend (business logic & API layer).
- MVC (Model-View-Controller) in the Backend:
- Although simplified, the backend organizes code in a structure typical of MVC: controllers handling HTTP requests, configuration handling application-wide settings, and (likely) service/model classes managing data.
- Component-based Architecture in the Frontend:
- The React application is built using individual components (e.g., BuildingCard, ReportingForm, Sidebar) that encapsulate specific UI functionalities.
- Real-time Nature:
- While not explicitly using real-time technologies like websockets, the web app is designed to update study locations based on current reports, hinting at either polling or a dynamic refresh mechanism.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        FE["Frontend<br/>(ReactJS, Vite, JavaScript, CSS)"]:::frontend
        FEApp["React App (App.jsx)"]:::frontend
        FEComponents["UI Components<br/>(BuildingCard, ReportingForm, Sidebar, StudySpotCard)"]:::frontend
        FEPages["Frontend Pages<br/>(Buildings, Home, StudySpotsInBuilding)"]:::frontend
        FELayouts["Frontend Layouts<br/>(DashboardLayout)"]:::frontend
    end

    subgraph "Backend"
        BE["Backend<br/>(Java, Spring Boot, Maven)"]:::backend
        BEEntry["Main Application (App.java)"]:::backend
        BEController["REST Controller<br/>(ReportController)"]:::backend
        BEConfig["Web Configuration<br/>(WebConfig)"]:::backend
        BEProps["Configuration Properties<br/>(application.properties)"]:::backend
        BETests["Backend Tests<br/>(AppTest)"]:::backend
    end

    subgraph "Database"
        DB["Database<br/>(SQL RDBMS)"]:::database
        DBScript["Database Setup Script<br/>(createTables.sql)"]:::database
    end

    FE -->|"HTTP/REST_API_Calls"| BE
    BE -->|"SQL_Queries/Data_Persistence"| DB

    click FE "https://github.com/cis3296s25/tuquiet/tree/main/frontend"
    click FEApp "https://github.com/cis3296s25/tuquiet/blob/main/frontend/src/App.jsx"
    click FEComponents "https://github.com/cis3296s25/tuquiet/tree/main/frontend/src/components"
    click FEPages "https://github.com/cis3296s25/tuquiet/tree/main/frontend/src/pages"
    click FELayouts "https://github.com/cis3296s25/tuquiet/tree/main/frontend/src/layouts"
    
    click BEEntry "https://github.com/cis3296s25/tuquiet/blob/main/backend/src/main/java/edu/temple/App.java"
    click BEController "https://github.com/cis3296s25/tuquiet/blob/main/backend/src/main/java/edu/temple/controller/ReportController.java"
    click BEConfig "https://github.com/cis3296s25/tuquiet/blob/main/backend/src/main/java/edu/temple/config/WebConfig.java"
    click BEProps "https://github.com/cis3296s25/tuquiet/blob/main/backend/src/main/resources/application.properties"
    click BETests "https://github.com/cis3296s25/tuquiet/blob/main/backend/src/test/java/edu/temple/AppTest.java"
    
    click DBScript "https://github.com/cis3296s25/tuquiet/blob/main/sqlFiles/createTables.sql"

    classDef frontend fill:#adebad,stroke:#333,stroke-width:2px;
    classDef backend fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef database fill:#ffcc99,stroke:#333,stroke-width:2px;
```
