# shreyavaidya2311/timetable-generator architecture

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

- Interactive diagram: https://gitdiagram.com/shreyavaidya2311/timetable-generator
- Repository: https://github.com/shreyavaidya2311/timetable-generator

## Overview

##### Project Type and Purpose
- This is a full-stack, single-page web application (“Time Table Generator”) that lets users enter course and scheduling constraints via a React frontend and generates a valid timetable by solving a Constraint Satisfaction Problem (CSP) in a Python/Flask backend.

##### File Structure
- Top-level folders:
- backend/ – Flask application (app.py), CSP solver (csp.py), data model (model.py), Python dependencies (requirements.txt)
- src/ – React application (components, pages, styles, tests)
- public/ – Static HTML, manifest, robots.txt
- Config files: package.json & package-lock.json for frontend, requirements.txt for backend
- No external database—data is passed in at runtime and processed in memory.

##### Key Insights from README
- Users supply courses, instructors, lecture counts, durations, working hours, and pairwise “non-consecutive” constraints.
- The backend models “variables” (timeslots), “domains” (subjects), and enforces constraints (no overlaps, teacher hours, etc.).
- Tech stack: React + Node for frontend; Python + Flask + python-constraint library for backend.

##### Main Architectural Components
a. Frontend (Browser)
- React SPA (src/) with components:
– AddCourses.jsx
– AddConstraints.jsx
– ViewTimeTable.jsx
– Dashboard.jsx
- Public assets (public/index.html)
b. API Layer (Flask app.py)
- HTTP endpoints for submitting course data, constraints, and requesting timetable
c. CSP Engine
- csp.py implements solver algorithms
- model.py defines data structures (Course, Instructor, TimeSlot)
d. Data Flow & User Interaction
- User → React UI → REST API → CSP Engine → Flask returns JSON → React renders timetable

##### Relationships and Interactions
- Directional HTTP calls from frontend to backend
- Internal calls: app.py imports model.py and csp.py to build and solve the CSP
- JSON payloads carry course definitions, constraint lists, and solution timetables

##### Architectural Patterns and Design Principles
- Separation of concerns: UI vs. API vs. business logic (CSP solver)
- Modularization: React components vs. Flask modules
- Stateless backend: no persistent store, each request reconstructs and solves the CSP

##### Technologies and Frameworks to Annotate
- React (UI)
- Axios or Fetch (HTTP client in React)
- Flask (REST API)
- python-constraint (solver library)
- Node/NPM (frontend build)
- pip (backend dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TB
    user("User"):::external
    browser("Browser"):::external
    user --> browser

    subgraph "Frontend (React SPA)"
        direction TB
        entry["public/index.html"]:::frontend
        click entry "https://github.com/shreyavaidya2311/timetable-generator/blob/master/public/index.html"
        bootstrap["src/index.js"]:::frontend
        click bootstrap "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/index.js"
        app["src/App.js"]:::frontend
        click app "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/App.js"
        subgraph "Components"
            direction TB
            addCourses["AddCourses.jsx"]:::frontend
            click addCourses "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/components/AddCourses.jsx"
            addConstraints["AddConstraints.jsx"]:::frontend
            click addConstraints "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/components/AddConstraints.jsx"
            viewTT["ViewTimeTable.jsx"]:::frontend
            click viewTT "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/components/ViewTimeTable.jsx"
        end
        dashboard["Dashboard.jsx"]:::frontend
        click dashboard "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/pages/Dashboard.jsx"
        styles["Global Styles"]:::styles
        click styles "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/App.css"
        click styles "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/index.css"
        click styles "https://github.com/shreyavaidya2311/timetable-generator/blob/master/src/theme.js"
        config["package.json / package-lock.json"]:::config
        click config "https://github.com/shreyavaidya2311/timetable-generator/blob/master/package.json"
        click config "https://github.com/shreyavaidya2311/timetable-generator/blob/master/package-lock.json"
    end

    subgraph "Backend (Flask API)"
        direction TB
        api["backend/app.py"]:::backend
        click api "https://github.com/shreyavaidya2311/timetable-generator/blob/master/backend/app.py"
        model["backend/model.py"]:::data
        click model "https://github.com/shreyavaidya2311/timetable-generator/blob/master/backend/model.py"
        solver["backend/csp.py"]:::logic
        click solver "https://github.com/shreyavaidya2311/timetable-generator/blob/master/backend/csp.py"
        requirements["backend/requirements.txt"]:::config
        click requirements "https://github.com/shreyavaidya2311/timetable-generator/blob/master/backend/requirements.txt"
    end

    browser --> entry
    entry --> bootstrap
    bootstrap --> app
    app --> addCourses
    app --> addConstraints
    app --> viewTT
    app --> dashboard

    app -->|"submits data via HTTP"| api
    api --> solver
    api --> model
    solver --> model
    api -->|"returns JSON"| app

    classDef external fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef frontend fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef backend fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef logic fill:#fff9c4,stroke:#333,stroke-width:1px
    classDef data fill:#ffccbc,stroke:#333,stroke-width:1px
    classDef styles fill:#e1bee7,stroke:#333,stroke-width:1px
    classDef config fill:#ffe0b2,stroke:#333,stroke-width:1px
```
