Structure of the project
Architecture & Frontend Patterns (Midas)
The RFiDRFID Tracker (codenamedcodename Midas) follows a traditional Django structure but uses a "“Single File Component"Component” philosophy for its views.
1. Project Organization
The project is split into the core configuration and the functional app logic.
Directory / File | Role |
| The active module containing the latest logic, models, and views. |
| Legacy code kept for bookkeeping; do not use for new features. |
| The |
| Database schema ( |
| The |
| Maps URLs to specific Python functions in |
2. The Frontend Pattern
Layout Strategy
Every page follows this block-based hierarchy:
{% extends 'midas/base.html' %}: Inherits the sidebar, navbar, and global styles.{% block head %}: Contains page-specific CSS and external libraries (like Chart.js).{% block main %}: The actual HTML content (cards, forms, tables).<script>: Local logic for charts or UI interactions.
3. The "“Data Bridge"Bridge” (Python to JavaScript)
To keep the code clean and secure, we use a specific pattern to pass data from the Python backend to the JavaScript frontend.
The json_script Filter
Instead of messy string concatenation, we use Django's json_script tag. This safely injects Python dictionaries into the HTML as a JSON object that JS can read.
In the HTML Template:{{ page_data|json_script:"frontend-data" }}
In the JavaScript block:const appData = JSON.parse(document.getElementById('frontend-data').textContent);// Now appData.chart.labels is ready for Chart.js!
4. Backend Logic & Calculation
The heavy lifting is done in the Python files before the page even loads:
- Calculations: Logic like
"“TotalHours"Hours” or"“Avg perMember"Member” is calculated inviews.pyor helper files likestatistics.py. - Database Interaction: Uses Django’s ORM (Object-Relational Mapper) to query the
db.sqlite3(dev) or the production DB. - Forms: Django’s
forms.pyhandles input validation when you change dates or teams in the dashboard.
5. Admin dashboard
Django provides its own built-in admin dashboard which can be reached through "“Admin Dashboard"Dashboard” button on the side bar.sidebar. (if you are a super user)superuser).