# ssbawaskar08/student-crud architecture

> Architecture diagram of the GitHub repository ssbawaskar08/student-crud, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ssbawaskar08/student-crud
- Repository: https://github.com/ssbawaskar08/student-crud

## Overview

##### Project type and purpose
- This is a full-stack student management web application built with Flask (Python) on the backend and plain HTML/CSS/JavaScript on the frontend.
- Purpose: Provide authenticated users with Create, Read, Update, Delete operations on student records stored in an SQLite database, with AJAX-powered deletion and CSRF protection.

##### File structure
- Top-level directories and files:
- .github/workflows/static.yml – CI configuration
- student_crud_app/
– app.py (main Flask application entry point)
– add_user.py (user registration module)
– instance/students.db (SQLite database)
– static/ (CSS and client-side assets)
– templates/ (Jinja2 HTML templates + delete_student.js embedded)
- Pattern: A single-process monolithic Flask app following an MVC-style separation (templates for View; app.py and add_user.py for Controller; SQLAlchemy models for Model).

##### Extract additional insights from README
- Backend uses Flask, SQLAlchemy ORM, Flask-Login (authentication), Flask-WTF (CSRF).
- Frontend uses responsive HTML, dark-theme CSS, and JavaScript Fetch API for AJAX.
- Dependencies and security measures are clearly outlined.

a. Main components
- Client (Web Browser)
– HTML templates (Login, Index, Add/Edit Student)
– CSS stylesheets (login.css, styles.css)
– JavaScript (AJAX delete_student.js)
- Web Server (Flask App)
– Routing and Controllers (app.py, add_user.py)
– Authentication module (Flask-Login)
– CSRF protection (Flask-WTF)
- ORM Layer (SQLAlchemy)
- Database (SQLite file in instance/)
- External/CI service (GitHub Actions for static checks)
b. Relationships and interactions
– Browser → HTTP(S) requests → Flask routes
– Flask controllers → ORM calls → SQLite database
– AJAX Fetch (DELETE) from templates → JSON response from Flask → DOM update
– Flask-Login enforces session management on protected routes
– Flask-WTF injects CSRF token into forms and validates on submit
c. Architectural patterns and principles
– MVC-inspired layering
– RESTful endpoints for CRUD operations
– AJAX for partial updates (deletion)
– Single-node monolith, no microservices
d. Key technologies/frameworks
– Python + Flask
– SQLAlchemy ORM
– Flask-Login, Flask-WTF
– SQLite
– HTML, CSS, JavaScript (Fetch API)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)"
        direction TB
        Browser["Web Browser"]:::frontend
        Login["Login.html"]:::frontend
        Index["index.html"]:::frontend
        AddStudent["add_student.html"]:::frontend
        EditStudent["edit_student.html"]:::frontend
        Base["base.html"]:::frontend
        CSS1["login.css"]:::frontend
        CSS2["styles.css"]:::frontend
        DeleteJS["delete_student.js"]:::frontend
    end

    %% Web Server Layer
    subgraph "Web Server (Flask App)"
        direction TB
        App["app.py"]:::backend
        AddUser["add_user.py"]:::backend
        Auth["Flask-Login\n(Authentication)"]:::backend
        CSRF["Flask-WTF\n(CSRF Protection)"]:::backend
    end

    %% Data Layer
    subgraph "ORM & Database"
        direction TB
        ORM["SQLAlchemy ORM"]:::data
        DB["SQLite Database\nstudents.db"]:::data
    end

    %% CI Service
    CI["GitHub Actions\n(static.yml)"]:::external

    %% Relationships
    Browser -->|uses templates| Login
    Browser -->|uses templates| Index
    Browser -->|uses templates| AddStudent
    Browser -->|uses templates| EditStudent
    Browser -->|uses templates| Base
    Browser -->|loads CSS| CSS1
    Browser -->|loads CSS| CSS2
    Browser -->|executes AJAX| DeleteJS

    Browser -->|HTTP GET/POST| App
    DeleteJS -->|DELETE /delete_student| App

    App -->|calls| AddUser
    App -->|session mgmt| Auth
    App -->|CSRF validation| CSRF
    App -->|ORM session| ORM
    ORM -->|SQL INSERT/SELECT/DELETE| DB

    App -->|HTML Response| Browser
    App -->|JSON Response| DeleteJS

    CI -->|static checks| App

    %% Click Events
    click Login "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/templates/Login.html"
    click Index "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/templates/index.html"
    click AddStudent "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/templates/add_student.html"
    click EditStudent "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/templates/edit_student.html"
    click Base "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/templates/base.html"
    click CSS1 "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/static/login.css"
    click CSS2 "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/static/styles.css"
    click DeleteJS "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/templates/delete_student.js"
    click App "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/app.py"
    click AddUser "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/add_user.py"
    click DB "https://github.com/ssbawaskar08/student-crud/blob/main/student_crud_app/instance/students.db"
    click CI "https://github.com/ssbawaskar08/student-crud/blob/main/.github/workflows/static.yml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFD580,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
