CoolFace
Apppublic

daemon03/Gale_shapely

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
App README

๐Ÿ  Roommate Allocation System โ€” Python & Streamlit Edition

![Python](https://python.org) ![Streamlit](https://streamlit.io) ![Algorithm](https://en.wikipedia.org/wiki/Gale%E2%80%93Shapley_algorithm)

A modern Streamlit UI for the Gale-Shapley Roommate Allocation algorithm. This version uses Python for the algorithm and file-system storage (JSON) instead of MySQL.

๐Ÿ”— For the original C + MySQL version, see: https://github.com/Harshwardhan-Deshmukh03/Roommate-allocation-using-Gale-Shapley-Algorithm.git

โœจ Features

  • โ€”Stable Matching via the Nobel Prize-winning Gale-Shapley algorithm
  • โ€”Two-Stage Allocation: Roommate matching โ†’ CGPA-ranked room assignment
  • โ€”CSV Import: Bulk-upload students & rooms via CSV files
  • โ€”File-System Storage: No database needed โ€” data stored as JSON
  • โ€”Interactive Charts: Plotly visualizations of CGPA distributions
  • โ€”Premium UI: Dark theme with glassmorphism, gradients, and animations

๐Ÿš€ Quick Start

bash
# 1. Create virtual environment
python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # macOS/Linux

# 2. Install dependencies
pip install -r requirements.txt

# 3. Run the app
streamlit run app.py

๐Ÿ“ Project Structure

streamlit_gale_shapely/
โ”œโ”€โ”€ app.py                  # Main Streamlit UI application
โ”œโ”€โ”€ gale_shapley.py         # Gale-Shapley algorithm (Python port)
โ”œโ”€โ”€ db.py                   # File-system database layer (JSON)
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ .streamlit/
โ”‚   โ””โ”€โ”€ config.toml         # Streamlit theme configuration
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ students.json       # Student records (replaces MySQL 'main' table)
โ”‚   โ”œโ”€โ”€ rooms.json          # Room records (replaces MySQL 'RoomNum' table)
โ”‚   โ””โ”€โ”€ allocations.json    # Allocation results
โ””โ”€โ”€ sample_csv/
    โ”œโ”€โ”€ sample_students_10.csv   # 10 students (5 pairs)
    โ”œโ”€โ”€ sample_rooms_5.csv       # 5 rooms for 10 students
    โ”œโ”€โ”€ sample_students_26.csv   # 26 students (13 pairs)
    โ””โ”€โ”€ sample_rooms_13.csv      # 13 rooms for 26 students

๐Ÿ“Š CSV Format

Students CSV

ColumnTypeDescription
idintUnique student ID (0-indexed)
namestrStudent name
cgpafloatCGPA (0.0โ€“10.0)
pref_roommatestrSpace-separated preferred roommate IDs
pref_roomstrSpace-separated preferred room IDs

Rooms CSV

ColumnTypeDescription
room_idintUnique room ID (0-indexed)
room_numberstrRoom label (e.g., "A101")

๐Ÿง  Algorithm

  1. 1.Stage 1 โ€” Roommate Matching: Gale-Shapley pairs students into stable roommate matches.
  2. 2.Stage 2 โ€” Room Allocation: Pairs ranked by max CGPA select rooms via Gale-Shapley.

Higher CGPA pairs get priority in room selection.