Skip to content

About

Flask + MySQL event finance tracker for college events: registrations, spend, revenue and profit. Coursework prototype — see README for known issues.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FinSystem — Event Finance Tracker

A Flask web application for tracking the finances of college events: what each event cost, what it earned from participant registrations, and whether it turned a profit. Built as a coursework project to practise server-side web development against a relational database.

Python Flask MySQL License

⚠️ Project status: incomplete prototype

This repository is published as coursework, not as working software. Several routes reference helper functions that were never written, so the app starts but crashes on most pages. The Known issues section lists exactly what is broken and why. It is kept public as an honest record of an early project; see quakeguard or cpr-simulator for finished work.


Demo

📹 Watch the demo video — download Demo.mp4 from the latest release. It shows the login, dashboard and event-creation flow working against a populated database.


What it does

Feature Route Status
Session login GET/POST / ✅ Works
Dashboard — event count, revenue, spend, profit GET /dashboard ✅ Works
Create an event GET/POST /create_event ✅ Works
Event detail + participant list GET /event/<id> ✅ Works
Register a participant, auto-update event takings POST /add_participant/<id> ✅ Works
Logout GET /logout ✅ Works
Event list with Upcoming/Ongoing/Completed status GET /events ❌ Crashes
Edit an event GET/POST /edit_event/<n> ❌ Crashes
Delete an event and its participants GET /delete_event/<n> ❌ Crashes
Delete a participant GET /delete_participant/<id> ❌ Crashes
Calendar view GET /calendar ❌ Crashes
CSV export of all events GET /export/events ❌ Crashes

The working half demonstrates the core idea: an event's profit is recomputed in SQL every time a participant pays, so the dashboard aggregates stay correct without a separate reconciliation step.


Architecture

Browser
   │  HTML form POST
   ▼
Flask (app.py)          ── session cookie holds the logged-in username
   │  parameterised SQL
   ▼
MySQL (database: practise)
   ├── users          login credentials
   ├── events         one row per event, with running spend/earnings/profit
   └── participants   one row per registration, FK to events

Rendering is server-side Jinja: templates/base.html defines the shell and every other template extends it.

Money flow

When a participant is registered, three statements run in sequence:

INSERT INTO participants (event_number, name, reg_no, amount_paid) VALUES (...);
UPDATE events SET amount_earned = amount_earned + %s WHERE event_number = %s;
UPDATE events SET profit = amount_earned - amount_spent WHERE event_number = %s;

profit is therefore a stored column kept in sync on write, rather than being derived on read. That makes the dashboard query a simple SUM, at the cost of the column being wrong if rows are ever edited outside the app.


Project structure

FinSystem/
├── app.py                     # All routes, DB connection, business logic
├── requirements.txt
├── templates/
│   ├── base.html              # Layout shell — nav + content block
│   ├── login.html             # Credential form
│   ├── dashboard.html         # KPI cards + recent events table
│   ├── create_event.html      # New-event form
│   ├── events.html            # Event list with computed status
│   └── event_details.html     # Single event + participants + add form
├── LICENSE
└── README.md

Running it locally

Prerequisites: Python 3.10+, a running MySQL server.

git clone https://github.com/Joshayy265/FinSystem.git
cd FinSystem
pip install -r requirements.txt

Create the database and tables:

CREATE DATABASE practise;
USE practise;

CREATE TABLE users (
    username VARCHAR(50) PRIMARY KEY,
    password VARCHAR(255) NOT NULL
);

CREATE TABLE events (
    event_number  INT AUTO_INCREMENT PRIMARY KEY,
    event_name    VARCHAR(120) NOT NULL,
    event_date    DATE NOT NULL,
    amount_spent  DECIMAL(10,2) DEFAULT 0,
    amount_earned DECIMAL(10,2) DEFAULT 0,
    profit        DECIMAL(10,2) DEFAULT 0
);

CREATE TABLE participants (
    id           INT AUTO_INCREMENT PRIMARY KEY,
    event_number INT NOT NULL,
    name         VARCHAR(120) NOT NULL,
    reg_no       VARCHAR(50),
    amount_paid  DECIMAL(10,2) DEFAULT 0,
    FOREIGN KEY (event_number) REFERENCES events(event_number)
);

INSERT INTO users VALUES ('admin', 'admin');

The schema above is reconstructed from the SQL in app.py — the original .sql dump was never committed. Column types are inferred, not authoritative.

The connection is hardcoded at app.py:9 (host=127.0.0.1, user=root, empty password, database=practise). Edit it to match your server, then:

python app.py

Open http://localhost:5000 and log in with admin / admin.


Known issues

These are real defects, listed so anyone reading the code isn't left guessing.

1. get_db() is never defined. Six routes call it (events, calendar, edit_event, delete_event, delete_participant) and raise NameError on first request. export_events similarly calls an undefined get_all_events(). The working routes use the module-level cursor instead.

2. Two incompatible SQL dialects. The routes that work use MySQL's %s placeholders; the broken ones use SQLite's ? and a db.execute(...).fetchone() chaining style that mysql-connector does not support. The file looks like two tutorials merged without reconciliation.

3. Two templates are missing. edit_event.html and calendar.html are rendered by their routes but were never committed.

4. Passwords are stored and compared in plaintext. app.py:24 does SELECT * FROM users WHERE username=%s AND password=%s. A real version needs hashing (werkzeug.security.generate_password_hash).

5. secret_key = "secret" is hardcoded, so session cookies are trivially forgeable. It belongs in an environment variable.

6. One global cursor is shared by every request. mysql-connector cursors are not thread-safe; under concurrent requests results can interleave. A per-request connection (or a pool) is the standard fix.

7. debug=True is set in the entry point, which exposes the Werkzeug debugger console.

If I were to finish it

Replace the raw connection with SQLAlchemy so one dialect and one session lifecycle apply everywhere, hash passwords, move config to .env, write the two missing templates, and add a schema.sql so the database is reproducible.


License

MIT — see LICENSE.

About

Flask + MySQL event finance tracker for college events: registrations, spend, revenue and profit. Coursework prototype — see README for known issues.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages