Skip to content

v2: Restructure, redesign UI, fix bugs, remove committed databases - #1

Open
Jenks00 wants to merge 4 commits into
mainfrom
v2-redesign
Open

v2: Restructure, redesign UI, fix bugs, remove committed databases#1
Jenks00 wants to merge 4 commits into
mainfrom
v2-redesign

Conversation

@Jenks00

@Jenks00 Jenks00 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

This is a full production-readiness pass and UI redesign of the Student Management System, done entirely on this branch so main is untouched and easy to compare against or revert to.

  • Restructured the repo. The single 26KB Student_management_system.py file is split into main.py (entry point) plus a small app/ package: database.py (SQLite access layer), login_window.py, dashboard.py, theme.py (ttk styling), export.py (CSV/PDF), and validators.py (input validation). No functional behavior changed except the bug fixes below.
  • Removed all five committed .db files (app.db, login.db, sms.db, student.db, students.db, users.db). Only app.db was ever actually opened by the code (DB_FILE = "app.db"); the rest were dead leftovers. The database and its tables are now created automatically at runtime (CREATE TABLE IF NOT EXISTS, already present in the original code and preserved) and *.db is gitignored.
  • Fixed a real data-corruption bug: ttk.Treeview stringifies Python None to the literal text "None" when values are inserted. For a student with no linked login (username is NULL), selecting that row and then saving any edit would write the string "None" back into the username column — and since username is UNIQUE, a second such edit would fail with a UNIQUE/FOREIGN KEY constraint error. Fixed by sanitizing None to "" when populating the table.
  • Fixed plaintext password storage: passwords are now stored as SHA-256 hashes (hashlib, stdlib) instead of being stored and compared as plaintext.
  • Added input validation with user-facing messages for email format, phone format, and date format (previously only "required field" checks existed), so bad input produces a clear dialog instead of a malformed row.
  • Redesigned the UI with ttk: custom ttk.Style theme (light + dark palettes), a resizable grid layout (the old layout used fixed-pixel place() coordinates and a fixed window size), a striped/sortable ttk.Treeview data table with a scrollbar, consistent button styling by intent (primary/success/danger/warning/accent/secondary), and better spacing throughout.
  • Documented the real dependency: PDF export uses reportlab, which is not part of the standard library. This wasn't previously documented anywhere. requirements.txt now lists it, and the README calls out that everything else is pure stdlib. If reportlab isn't installed, PDF export shows a clear message instead of crashing; everything else still works.
  • Added tests/: test_database.py (22 checks against a throwaway sqlite file: auth, CRUD, role-scoped queries, search, validators) and test_gui.py (21 checks that drive the actual Tk widgets end-to-end — login, add/update/delete, search, sort, export, theme toggle, role restrictions — against a live Tk root). Both pass.
  • Added LICENSE (MIT) and rewrote README.md with features, tech stack, setup instructions, test instructions, and a PyInstaller packaging note.

How this was verified

Given the headless/CI-like constraints of the environment this was developed in (no real interactive desktop), verification was layered:

  1. python -m py_compile on every module — no syntax errors.
  2. tests/test_database.py — 22 automated checks against the real data-access layer (throwaway sqlite file).
  3. tests/test_gui.py — 21 automated checks that construct the actual LoginWindow and Dashboard widget trees on a live Tk() root and drive their real callback methods (not mocks), pumping the event loop with root.update(). This is what caught the None-stringification bug above.

Test plan

  • Pull this branch, run python main.py, log in with admin / admin123
  • Add, edit, delete a student record; confirm validation messages appear for bad email/phone/date
  • Toggle dark mode
  • Export CSV and PDF (install reportlab first for PDF)
  • python tests/test_database.py and python tests/test_gui.py both report all checks passing

Split the single Student_management_system.py file into main.py plus
app/database.py, login_window.py, dashboard.py, theme.py, export.py,
and validators.py. The database and its tables are now created at
runtime via CREATE TABLE IF NOT EXISTS instead of committing .db files.
Passwords are now stored as SHA-256 hashes instead of plaintext.
test_database.py covers auth, CRUD, role-scoped queries, search, and
validators against a throwaway sqlite file. test_gui.py drives the real
Tkinter widgets end to end (login, add/update/delete, search, sort,
export, theme toggle, role restrictions) to catch UI-level bugs that
unit tests on the data layer alone would miss.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant