# vishalla/week7_ga architecture

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

- Interactive diagram: https://gitdiagram.com/vishalla/week7_ga
- Repository: https://github.com/vishalla/week7_ga

## Overview

##### Project Type and Purpose
- This is a full-stack Python Flask web application for managing courses, students, and enrollments.
- It serves both HTML pages (server-rendered via Jinja2 templates) and offers a JSON/REST API under the “applications/API” module.

##### High-Level Components
a. Presentation Layer
- app.py (root) – Flask application entry point, registers routes/blueprints.
- templates/ – Jinja2 HTML templates for pages (create/update/index/student_exists, etc.).
- static/styles.css – CSS styling served by Flask’s static folder.
b. API Layer
- applications/API/*.py – Flask Blueprints or route modules for course_API, student_API, enrollment_API.
- validation.py – Input validation logic before controller invocation.
c. Controller Layer
- applications/controllers/*.py – Business-logic controllers (coursecontrollers.py, studentcontrollers.py) handling CRUD flows.
d. Model & Data Access
- applications/model.py – ORM-style data models or entity definitions.
- applications/database.py – Database connection manager, session handling.
- week7_database.sqlite – SQLite file housing data.
e. Configuration
- applications/config.py – Configuration settings (DB URI, debug flags, etc.).
f. Requirements & Scripts
- req.txt – Python dependencies (Flask, etc.).
- instructions.txt / Week7_LA.pdf – Project guidelines and assignment doc.

##### Relationships & Data Flows
- Browser ⇄ Flask app:
- User submits form or clicks link → HTTP request to app.py routes.
- app.py dispatches to either API Blueprint (JSON end points) or controller endpoints (render templates).
- API Layer → Validation → Controllers:
- API module receives JSON payload, calls validation.py → passes to controllers for business logic.
- Controllers → Model & DB:
- Controller invokes model.py classes and uses database.py session to read/write to SQLite.
- Controllers → Templates:
- For HTML views, controller returns data to Jinja2 templates which generate HTML → sent back to Browser.

##### Architectural Patterns & Principles
- MVC-style separation:
- Models (applications/model.py + DB),
- Views (templates/ + static),
- Controllers (applications/controllers).
- Layered architecture:
Presentation → API/Validation → Business Logic → Data Access.
- Single-source config via applications/config.py.
- SQLite as embedded DB for simplicity.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top-level Client
    Browser["Client Browser"]:::frontend

    %% Flask App Entry
    App["Flask app.py"]:::backend

    Browser -->|"HTTP Request"| App

    %% Presentation Layer
    subgraph "Presentation Layer"
        Templates["templates/"]:::frontend
        Styles["static/styles.css"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        CourseAPI["course_API.py"]:::api
        StudentAPI["student_API.py"]:::api
        EnrollmentAPI["enrollment_API.py"]:::api
        Validation["validation.py"]:::api
    end

    %% Controller Layer
    subgraph "Controller Layer"
        CourseCtrl["coursecontrollers.py"]:::backend
        StudentCtrl["studentcontrollers.py"]:::backend
    end

    %% Model & Data Access
    subgraph "Model & Data Access"
        Model["model.py"]:::database
        DBConn["database.py"]:::database
        SQLite["week7_database.sqlite"]:::database
    end

    %% Configuration
    Config["config.py"]:::config

    %% Documentation & Requirements
    subgraph "Docs & Requirements"
        Req["req.txt"]:::docs
        Inst["instructions.txt"]:::docs
        PDF["Week7_LA.pdf"]:::docs
    end

    %% Application Flow
    App -->|"HTML Endpoint"| CourseCtrl
    App -->|"HTML Endpoint"| StudentCtrl
    App -->|"JSON Endpoint"| CourseAPI
    App -->|"JSON Endpoint"| StudentAPI
    App -->|"JSON Endpoint"| EnrollmentAPI

    CourseAPI -->|"validatePayload()"| Validation
    StudentAPI -->|"validatePayload()"| Validation
    EnrollmentAPI -->|"validatePayload()"| Validation

    Validation -->|"invokeBusinessLogic()"| CourseCtrl
    Validation -->|"invokeBusinessLogic()"| StudentCtrl

    CourseCtrl -->|"read/write()"| Model
    StudentCtrl -->|"read/write()"| Model

    Model -->|"connect()"| DBConn
    DBConn -->|"SQL Operations"| SQLite

    CourseCtrl -->|"renderTemplate()"| Templates
    StudentCtrl -->|"renderTemplate()"| Templates
    Templates -->|"HTML Response"| Browser
    Styles -->|"CSS"| Browser

    CourseAPI -->|"JSON Response"| Browser
    StudentAPI -->|"JSON Response"| Browser
    EnrollmentAPI -->|"JSON Response"| Browser

    Config --> App
    Config --> CourseAPI
    Config --> StudentAPI
    Config --> EnrollmentAPI
    Config --> Validation
    Config --> CourseCtrl
    Config --> StudentCtrl
    Config --> Model
    Config --> DBConn

    %% Click Events
    click App "https://github.com/vishalla/week7_ga/blob/main/app.py"
    click Templates "https://github.com/vishalla/week7_ga/tree/main/templates/"
    click Styles "https://github.com/vishalla/week7_ga/blob/main/static/styles.css"
    click CourseAPI "https://github.com/vishalla/week7_ga/blob/main/applications/API/course_API.py"
    click StudentAPI "https://github.com/vishalla/week7_ga/blob/main/applications/API/student_API.py"
    click EnrollmentAPI "https://github.com/vishalla/week7_ga/blob/main/applications/API/enrollment_API.py"
    click Validation "https://github.com/vishalla/week7_ga/blob/main/applications/API/validation.py"
    click CourseCtrl "https://github.com/vishalla/week7_ga/blob/main/applications/controllers/coursecontrollers.py"
    click StudentCtrl "https://github.com/vishalla/week7_ga/blob/main/applications/controllers/studentcontrollers.py"
    click Model "https://github.com/vishalla/week7_ga/blob/main/applications/model.py"
    click DBConn "https://github.com/vishalla/week7_ga/blob/main/applications/database.py"
    click SQLite "https://github.com/vishalla/week7_ga/blob/main/week7_database.sqlite"
    click Config "https://github.com/vishalla/week7_ga/blob/main/applications/config.py"
    click Req "https://github.com/vishalla/week7_ga/blob/main/req.txt"
    click Inst "https://github.com/vishalla/week7_ga/blob/main/instructions.txt"
    click PDF "https://github.com/vishalla/week7_ga/blob/main/Week7_LA.pdf"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#036B99,color:#000
    classDef backend fill:#C8E6C9,stroke:#2E7D32,color:#000
    classDef api fill:#FFF2CC,stroke:#BF8F00,color:#000
    classDef database fill:#FFE0B2,stroke:#EF6C00,color:#000
    classDef config fill:#E0E0E0,stroke:#757575,color:#000
    classDef docs fill:#EFEBE9,stroke:#5D4037,color:#000
```
