# sai-deekshith-06/smart-campus-fine-track architecture

> Architecture diagram of the GitHub repository sai-deekshith-06/smart-campus-fine-track, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sai-deekshith-06/smart-campus-fine-track
- Repository: https://github.com/sai-deekshith-06/smart-campus-fine-track

## Overview

##### Project type and purpose
- This is a full-stack Flask web application called “Campus Fine Tracking System.”
- Purpose: allow administrators and students to submit, approve/reject, track, and manage campus fines, with automated email notifications and CLI tools for DB management.

##### File structure
- Top-level files:
- app.py – bootstrap and blueprint registration
- admin.py / student.py – Flask routes (controllers) for admin and student interfaces
- run.sh – startup script
- requirements.txt / .flaskenv – dependencies and environment config
- CLI to manage db/… – standalone Python scripts for populating and managing the MongoDB data
- Directories:
- templates/ – Jinja2 HTML templates (views) for admin_* and student_fines pages
- static/images/ – static assets (images)
- Data file: students.csv – batch import of student records via CLI

##### README insights
- Tech stack: Python 3.x, Flask, Flask-PyMongo, Flask-Mail, MongoDB, SMTP
- Features: separate admin/student interfaces, email notifications, secure session management
- Prerequisites / Setup: .flaskenv for MAIL_* and MONGO_URI, MongoDB running locally, SMTP server

a. Main components
1. Clients: Admin Browser, Student Browser
2. Web Server: Flask Application
- Subcomponents:
- Blueprints/Controllers (admin.py, student.py)
- Template Engine (templates/*.html)
- Static File Server (static/images)
- Configuration: .flaskenv (env vars for mail and DB)
- CLI Tools (manage_db.py, populate_students.py)
3. Data Store: MongoDB (finesdb)
4. External Service: SMTP Email Server
5. Optional: File storage for uploaded payment screenshots
b. Relationships and interactions
- HTTP(S) flow:
Admin/Student Browser → Flask App (routes) → business logic → MongoDB → Flask App → rendered HTML → Browser
- Email flow:
Flask App → Flask-Mail → SMTP Server → user inbox
- CLI flow (offline):
CLI scripts → connect to MongoDB → read/write student and fine category data
c. Architectural patterns
- MVC:
- Model: MongoDB collections accessed via Flask-PyMongo
- View: Jinja2 templates in templates/
- Controller: Flask route handlers in admin.py and student.py
- Modularization: two blueprints (admin vs student), plus a CLI module
- Configuration via environment variables for security and portability
d. Key technologies
- Flask (web framework)
- Flask-PyMongo (MongoDB integration)
- Flask-Mail (email notifications)
- Python-dotenv or .flaskenv (env var management)
- MongoDB (NoSQL database)
- SMTP (external email service)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AdminBrowser["Admin Browser"]:::client
        StudentBrowser["Student Browser"]:::client
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        FlaskApp["Flask Application"]:::server
        AdminController["Admin Blueprint / Controller"]:::server
        StudentController["Student Blueprint / Controller"]:::server
        TemplateEngine["Template Engine\n(templates/)"]:::server
        StaticServer["Static File Server\n(static/images/)"]:::server
        Config["Configuration\n(.flaskenv)"]:::server
        Startup["Startup Script\n(run.sh)"]:::server
        Doc["Project Documentation\n(README.md)"]:::server
        Dep["Dependencies\n(requirements.txt)"]:::server
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        MongoDB[(MongoDB\nfinesdb)]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTPServer((SMTP Email Server)):::external
    end

    %% CLI Tools
    subgraph "CLI Tools"
        direction TB
        ManageDB["Manage Database CLI\n(manage_db.py)"]:::cli
        Populate["Populate Students CLI\n(populate_students.py)"]:::cli
        DataFile["Batch Import File\n(students.csv)"]:::cli
    end

    %% Connections
    AdminBrowser -->|HTTPS GET/POST| FlaskApp
    StudentBrowser -->|HTTPS GET/POST| FlaskApp
    FlaskApp -->|renders HTML| AdminBrowser
    FlaskApp -->|renders HTML| StudentBrowser
    FlaskApp -->|PyMongo CRUD| MongoDB
    FlaskApp -->|SMTP / Flask-Mail| SMTPServer
    Config -->|env vars| FlaskApp
    Dep -->|install| FlaskApp
    Startup -->|bootstraps| FlaskApp
    Doc -->|reference| FlaskApp
    ManageDB -->|mongo driver| MongoDB
    Populate -->|mongo driver| MongoDB
    DataFile -->|input| Populate

    %% Click Events
    click FlaskApp "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/app.py"
    click AdminController "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/admin.py"
    click StudentController "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/student.py"
    click TemplateEngine "https://github.com/sai-deekshith-06/smart-campus-fine-track/tree/main/templates/"
    click StaticServer "https://github.com/sai-deekshith-06/smart-campus-fine-track/tree/main/static/images/"
    click ManageDB "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/CLI to manage db/manage_db.py"
    click Populate "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/CLI to manage db/populate_students.py"
    click DataFile "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/CLI to manage db/students.csv"
    click Startup "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/run.sh"
    click Dep "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/requirements.txt"
    click Doc "https://github.com/sai-deekshith-06/smart-campus-fine-track/blob/main/README.md"

    %% Styles
    classDef client fill:#FFD7FA,stroke:#D69DED
    classDef server fill:#DDEEFF,stroke:#5A9AD1
    classDef database fill:#DFFFE0,stroke:#5AB85A
    classDef external fill:#FFE0E0,stroke:#D14D4D
    classDef cli fill:#FFF2CC,stroke:#D1B200
```
