# cis3296s25/01-smartschedule architecture

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

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

## Overview

##### Main components
- Frontend: The React application located in the "src" directory along with the public assets and configuration files (e.g., vite.config.js, package.json). Key components here include the main React components (CourseSearch, GeneratedSchedules, SaveLoadControls, ScheduleRestrictions, SelectedCourses, SemesterSelector) that are part of the user interface.
- Backend: The Python server in the "backend" directory. The main entry point is backend/main.py, with additional utility modules (backend/utils/fetch.py) that assist in data fetching and possibly other backend tasks.
- API Endpoints: Clearly described in the README, including endpoints to get subjects and courses as well as the root endpoint. Also note the Swagger UI available under /docs for interactive API testing.

##### And map the relationships/interactions
- That the backend, powered by uvicorn, handles the HTTP requests, returns JSON responses, and exposes endpoints like GET /, GET /api/subjects, GET /api/subject/courses, and GET /api/all-courses.
- External tools like Swagger UI as an optional component to represent developer interaction with the API.

##### And highlight architectural patterns/design principles
- Separation of Concerns: Notice the clear division between frontend and backend. Frontend components handle UI and presentation, while the backend is solely dedicated to business logic and API servicing.
- Modular Architecture: The backend is split into main application logic (main.py) and utility functions (utils/fetch.py), while the frontend is organized into a component-based structure typical for React applications.

##### Detailing relevant technologies and libraries
- Frontend: React, Vite (for bundling and HMR), ESLint (for code standards), and possibly Babel or SWC (as indicated by the available plugins for fast refresh).
- Backend: Python 3.9+, uvicorn (for running an ASGI server), and internal utility modules for handling specific backend tasks.
- Configurations files like eslint.config.js and vite.config.js that configure the development environment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend"
        direction TB
        %% Core Setup
        subgraph "Core Setup"
            direction TB
            E["Entry Point"]:::frontend
            A["Main React App"]:::frontend
            I["index.html"]:::config
            P["Public Assets"]:::config
            V["vite.config.js"]:::config
            PK["package.json"]:::config
            E --> A
        end
        %% UI Components
        subgraph "UI Components"
            direction TB
            CS["CourseSearch"]:::frontend
            GS["GeneratedSchedules"]:::frontend
            SLC["SaveLoadControls"]:::frontend
            SR["ScheduleRestrictions"]:::frontend
            SC["SelectedCourses"]:::frontend
            SS["SemesterSelector"]:::frontend
        end
    end

    %% Backend Subgraph
    subgraph "Backend"
        direction TB
        PS["Python Server"]:::backend
        subgraph "API Endpoints"
            direction TB
            ROOT["GET /"]:::api
            SUBJ["GET /api/subjects"]:::api
            SCOURSES["GET /api/subject/courses"]:::api
            AC["GET /api/all-courses"]:::api
            DOCS["Swagger UI (/docs)"]:::api
        end
        UTL["Data Fetching Utility"]:::backend
    end

    %% Connections from Frontend UI Components to Backend Server (API calls)
    CS -->|"GET"| PS
    GS -->|"GET"| PS
    SLC -->|"GET"| PS
    SR -->|"GET"| PS
    SC -->|"GET"| PS
    SS -->|"GET"| PS

    %% Backend internal exposure of endpoints
    PS --> ROOT
    PS --> SUBJ
    PS --> SCOURSES
    PS --> AC
    PS --> DOCS

    %% Backend utility supports Python Server
    UTL -.-> PS

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef api fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef config fill:#FFCDD2,stroke:#C62828,stroke-width:2px;

    %% Click Events for Frontend
    click E "https://github.com/cis3296s25/01-smartschedule/blob/main/src/main.jsx"
    click A "https://github.com/cis3296s25/01-smartschedule/blob/main/src/App.jsx"
    click I "https://github.com/cis3296s25/01-smartschedule/blob/main/index.html"
    click P "https://github.com/cis3296s25/01-smartschedule/tree/main/public"
    click V "https://github.com/cis3296s25/01-smartschedule/blob/main/vite.config.js"
    click PK "https://github.com/cis3296s25/01-smartschedule/blob/main/package.json"
    click CS "https://github.com/cis3296s25/01-smartschedule/blob/main/src/components/CourseSearch.jsx"
    click GS "https://github.com/cis3296s25/01-smartschedule/blob/main/src/components/GeneratedSchedules.jsx"
    click SLC "https://github.com/cis3296s25/01-smartschedule/blob/main/src/components/SaveLoadControls.jsx"
    click SR "https://github.com/cis3296s25/01-smartschedule/blob/main/src/components/ScheduleRestrictions.jsx"
    click SC "https://github.com/cis3296s25/01-smartschedule/blob/main/src/components/SelectedCourses.jsx"
    click SS "https://github.com/cis3296s25/01-smartschedule/blob/main/src/components/SemesterSelector.jsx"

    %% Click Events for Backend
    click PS "https://github.com/cis3296s25/01-smartschedule/blob/main/backend/main.py"
    click UTL "https://github.com/cis3296s25/01-smartschedule/blob/main/backend/utils/fetch.py"
```
