# giridharrnair/profstatsutd architecture

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

- Interactive diagram: https://gitdiagram.com/giridharrnair/profstatsutd
- Repository: https://github.com/giridharrnair/profstatsutd

## Overview

##### Project Type and Purpose
- It’s a full-stack project with a Chrome extension frontend (React built with Vite) and a Golang backend.
- The extension is used to present course/professor information to students by merging rating data and grade distributions. The data is sourced from CSV files (raw_data) and loaded into a SQLite database created/populated via Python scripts.

##### File Structure – Key Components
- Frontend: Located primarily in the "src" folder, with components such as course-info.jsx, grades-graph.jsx, lookup-form.jsx, and professor-info.jsx. There’s an index.html at the root, with Vite configuration provided.
- Backend API: Contained in the "api" folder. You have:
- Controllers (e.g., course_information.go, professor_information.go, search_suggestions.go) for handling HTTP requests.
- Specific modules for courses, professors, and database operations (API/db, API/course, API/professor).
- Tests for these controllers and modules indicate a layered and testable design.
- The “api/Dockerfile” indicates containerization for deployment on Azure.
- Database: Instead of a separate database configuration file, SQLite is used. The initialization and population are handled by Python scripts in the "db_setup" folder, which processes CSV files in the "raw_data" directory.
- Development and Deployment: GitHub workflows and related CI/CD configurations in the ".github" folder and package files (package.json, package-lock.json) ensure that deployment (e.g., Chrome Web Store deployments) and code quality (ESLint, Prettier, etc.) are maintained.

##### Main Components and Their Relationships
a. Frontend (Chrome Extension User Interface)
- Component: React application built with Vite (located in src/).
- Role: Handles user interactions, displays course and professor details, and gathers student queries.
- Interaction: Sends HTTP requests (REST API) to the backend for data such as course information or rating searches.

b. Backend API Server
- Component: Golang service (located in the api/ folder with controllers, course, professor, and database modules).
- Role: Processes requests coming from the frontend, handles business logic, interacts with the database, and returns data.
- Pattern: Follows RESTful design with endpoints grouped in controllers.
- Containerization: Runs inside a Docker container (evident from the Dockerfile) and deployed on Azure Web App.

c. Database and Data Pipeline
- Component: SQLite database that is built and populated by Python scripts (db_setup folder).
- Role: Stores course, professor, and related grade information.
- Data Ingestion: CSV files (raw_data directory) are processed to fill the database.
- Interaction: The backend Golang API interacts with this database through defined DB methods (e.g., get_course_suggestions.go, init_db_conn.go).

d. CI/CD and Deployment Pipelines
- Components: GitHub workflows (in .github/workflows) including deployments to the Chrome Web Store, linting, and testing workflows.
- Role: Automation and continuous deployment/integration ensuring code quality and smooth deployment cycles.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between frontend (user interface in React) and backend (Golang API).
- RESTful API: Controllers handle discrete API endpoints.
- Containerization: Use of Docker for easier, isolated deployment, especially on Azure.
- Data Processing Pipeline: Python scripts are used to set up and maintain the database based on CSV input.
- Testing: Directory structure indicates that testing is integral to both the API (controllerstest) and individual modules (course_test.go, professor_test.go).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Frontend Subgraph
    subgraph "Chrome Extension Frontend"
        FE1["index.html (Frontend Entry)"]:::frontend
        FE2["src/ (React/Vite Components)"]:::frontend
    end

    %% Backend API Server Subgraph
    subgraph "Backend API Server"
        BE0["api/ (Golang Service)"]:::backend
        BE1["api/main.go"]:::backend
        subgraph "Controllers"
            BE2["course_information.go"]:::backend
            BE3["professor_information.go"]:::backend
            BE4["search_suggestions.go"]:::backend
        end
        subgraph "Modules"
            BE5["api/course/"]:::backend
            BE6["api/professor/"]:::backend
            BE7["api/db/"]:::backend
        end
        BE8["Dockerfile (Docker Container)"]:::container
    end

    %% Database and Data Pipeline Subgraph
    subgraph "Database & Data Pipeline"
        DB1[("SQLite Database")]:::database
        subgraph "Data Ingestion"
            DIP1["db_setup/ (Python Scripts)"]:::database
            DIP2["raw_data/ (CSV Files)"]:::database
        end
    end

    %% CI/CD Pipelines Subgraph
    subgraph "CI/CD Pipelines"
        CICD1[".github/workflows/"]:::ci
    end

    %% Connections between components
    FE2 -->|"HTTPRequests/RESTAPI"| BE0
    BE0 -->|"Queries/Updates"| DB1
    DIP2 -->|"DataIngestion"| DIP1
    DIP1 -->|"LoadsData"| DB1
    CICD1 -->|"CI/CD"| FE2
    CICD1 -->|"CI/CD"| BE0

    %% Styles
    classDef frontend fill:#f7d794,stroke:#333,stroke-width:2px;
    classDef backend fill:#a4d4ff,stroke:#333,stroke-width:2px;
    classDef database fill:#c3f584,stroke:#333,stroke-width:2px;
    classDef ci fill:#ffb3ba,stroke:#333,stroke-width:2px;
    classDef container fill:#d1c4e9,stroke:#333,stroke-width:2px;

    %% Click Events
    click FE1 "https://github.com/giridharrnair/profstatsutd/blob/main/index.html"
    click FE2 "https://github.com/giridharrnair/profstatsutd/tree/main/src/"
    click BE0 "https://github.com/giridharrnair/profstatsutd/tree/main/api/"
    click BE1 "https://github.com/giridharrnair/profstatsutd/blob/main/api/main.go"
    click BE2 "https://github.com/giridharrnair/profstatsutd/blob/main/api/controllers/course_information.go"
    click BE3 "https://github.com/giridharrnair/profstatsutd/blob/main/api/controllers/professor_information.go"
    click BE4 "https://github.com/giridharrnair/profstatsutd/blob/main/api/controllers/search_suggestions.go"
    click BE5 "https://github.com/giridharrnair/profstatsutd/tree/main/api/course/"
    click BE6 "https://github.com/giridharrnair/profstatsutd/tree/main/api/professor/"
    click BE7 "https://github.com/giridharrnair/profstatsutd/tree/main/api/db/"
    click BE8 "https://github.com/giridharrnair/profstatsutd/tree/main/api/Dockerfile"
    click DIP1 "https://github.com/giridharrnair/profstatsutd/tree/main/db_setup/"
    click DIP2 "https://github.com/giridharrnair/profstatsutd/tree/main/raw_data/"
    click CICD1 "https://github.com/giridharrnair/profstatsutd/tree/main/.github/workflows/"
```
