# akboxer/sacdap_clean architecture

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

- Interactive diagram: https://gitdiagram.com/akboxer/sacdap_clean
- Repository: https://github.com/akboxer/sacdap_clean

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with Flask (Python).
- It serves a static-dynamic website for a coaching institute, providing course PDFs, contact/enrollment forms, and admin views.

##### File-Structure Analysis
- Top-Level Python Modules:
- app.py / app_instance.py – entry point and Flask app factory
- main.py, routes.py – HTTP routes (controllers)
- forms.py – WTForms definitions (form models)
- data.py – data layer (course/catalog info, could be abstracted as the “model”)
- Templates (Jinja2 View Layer):
- templates/*.html – page layouts, base.html, home, contact, admin panels
- Static Assets:
- static/css, static/js – styling and client-side behavior
- static/images – brand, slide show
- static/pdfs – course material library
- Environment & Configuration:
- requirements.txt / pyproject.toml – Python dependencies
- venv – local Python environment
- No external database configured, implying flat file or in-memory data for now

##### Key Architectural Patterns
- MVC-style separation:
- Model: data.py (course data), forms.py (form schema)
- View: Jinja2 templates under templates/
- Controller: Flask route handlers in routes.py/main.py
- Static resource serving via Flask or fronted by a web server (Nginx) in production
- Optional: Email/SMTP service for contact form submissions (not explicitly coded)

A. Client (Browser)
– Sends HTTP(S) requests for pages, assets, form submissions
B. Reverse Proxy / Web Server (optional production layer)
– Nginx/Apache: handles SSL, static file caching, forwards dynamic requests to WSGI
C. WSGI Application Layer
– Gunicorn/uWSGI running the Flask app
– app_instance.py constructs Flask instance, routes.py defines endpoints
D. Flask Components
1. Routing/Controllers: map URLs to handlers
2. Forms Module: validate and process enrollment/contact data
3. Data Module: provides course/catalog data to views
4. Template Engine (Jinja2): renders HTML with dynamic data
E. Static File Server
– Serves CSS, JS, images, PDFs directly (either by Flask in dev or by Nginx in prod)
F. External Services (optional)
– Email/SMTP service for form notifications
– Analytics or monitoring (if added)

##### Relationships & Data Flows
- Browser → HTTP GET / POST → Nginx → Gunicorn → Flask route
- Route handler fetches data from data.py or processes forms via forms.py
- Flask injects data into templates → Jinja2 → HTML response → Client
- Static asset requests bypass Flask logic (direct serve)
- Form POST → Flask → Validate → (Email service or store) → Redirect to success page

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Layer"
        Browser["Browser"] 
    end
    class Browser frontend

    subgraph "Infrastructure"
        NGINX["Nginx/Apache"]
        Gunicorn["Gunicorn/uWSGI"]
        Venv["venv/"]
    end
    class NGINX,Gunicorn,Venv infra

    subgraph "Flask Application"
        subgraph "Entry Points"
            AppPy["app.py"]
            AppInst["app_instance.py"]
        end
        subgraph "Controllers (Routes)"
            Main["main.py"]
            Routes["routes.py"]
        end
        Forms["forms.py"]
        Data["data.py"]
        TemplateEngine["Jinja2 Engine"]
        subgraph "Templates"
            Base["base.html"]
            Home["home.html"]
            Contact["contact.html"]
            Enrollment["enrollment.html"]
            Success["success.html"]
            ITCourses["it_courses.html"]
            StockMarket["stock_market.html"]
            Accounts["accounts.html"]
            AdminDash["admin_dashboard.html"]
            AdminContacts["admin_contacts.html"]
            AdminEnroll["admin_enrollments.html"]
            AdminVisitors["admin_visitors.html"]
            AdminPassword["admin_password.html"]
        end
    end
    class AppPy,AppInst,Main,Routes,Forms,Data,TemplateEngine,Base,Home,Contact,Enrollment,Success,ITCourses,StockMarket,Accounts,AdminDash,AdminContacts,AdminEnroll,AdminVisitors,AdminPassword backend

    subgraph "Static Assets"
        CSS["style.css"]
        JS["main.js"]
        Images["stock-market-slideshow/"]
        PDFs["pdfs/"]
        Attached["attached_assets/"]
    end
    class CSS,JS,Images,PDFs,Attached static

    subgraph "Config & Dependencies"
        Req["requirements.txt"]
        PyProj["pyproject.toml"]
        GitIgnore[".gitignore"]
        README["README.md"]
    end
    class Req,PyProj,GitIgnore,README config

    SMTP["SMTP Service"]
    class SMTP external

    Browser -->|HTTP GET| NGINX
    Browser -->|Static GET| CSS
    Browser -->|Static GET| JS
    Browser -->|Static GET| Images
    Browser -->|Static GET| PDFs
    Browser -->|Request Assets| Attached

    Browser -->|HTTP POST| NGINX
    NGINX -->|WSGI| Gunicorn
    Gunicorn -->|invoke| AppPy
    AppPy -->|factory| AppInst
    AppInst -->|register| Main
    AppInst -->|register| Routes

    Routes -->|"uses data module"| Data
    Routes -->|"uses form module"| Forms
    Routes -->|"renders via"| TemplateEngine
    TemplateEngine --> Templates

    Routes -->|SMTP POST| SMTP

    TemplateEngine -->|HTML Response| Gunicorn
    Gunicorn -->|WSGI Response| NGINX
    NGINX -->|HTTP Response| Browser

    click AppPy "https://github.com/akboxer/sacdap_clean/blob/main/app.py"
    click AppInst "https://github.com/akboxer/sacdap_clean/blob/main/app_instance.py"
    click Main "https://github.com/akboxer/sacdap_clean/blob/main/main.py"
    click Routes "https://github.com/akboxer/sacdap_clean/blob/main/routes.py"
    click Forms "https://github.com/akboxer/sacdap_clean/blob/main/forms.py"
    click Data "https://github.com/akboxer/sacdap_clean/blob/main/data.py"
    click Base "https://github.com/akboxer/sacdap_clean/blob/main/templates/base.html"
    click Home "https://github.com/akboxer/sacdap_clean/blob/main/templates/home.html"
    click Contact "https://github.com/akboxer/sacdap_clean/blob/main/templates/contact.html"
    click Enrollment "https://github.com/akboxer/sacdap_clean/blob/main/templates/enrollment.html"
    click Success "https://github.com/akboxer/sacdap_clean/blob/main/templates/success.html"
    click ITCourses "https://github.com/akboxer/sacdap_clean/blob/main/templates/it_courses.html"
    click StockMarket "https://github.com/akboxer/sacdap_clean/blob/main/templates/stock_market.html"
    click Accounts "https://github.com/akboxer/sacdap_clean/blob/main/templates/accounts.html"
    click AdminDash "https://github.com/akboxer/sacdap_clean/blob/main/templates/admin_dashboard.html"
    click AdminContacts "https://github.com/akboxer/sacdap_clean/blob/main/templates/admin_contacts.html"
    click AdminEnroll "https://github.com/akboxer/sacdap_clean/blob/main/templates/admin_enrollments.html"
    click AdminVisitors "https://github.com/akboxer/sacdap_clean/blob/main/templates/admin_visitors.html"
    click AdminPassword "https://github.com/akboxer/sacdap_clean/blob/main/templates/admin_password.html"
    click CSS "https://github.com/akboxer/sacdap_clean/blob/main/static/css/style.css"
    click JS "https://github.com/akboxer/sacdap_clean/blob/main/static/js/main.js"
    click Images "https://github.com/akboxer/sacdap_clean/tree/main/static/images/stock-market-slideshow/"
    click PDFs "https://github.com/akboxer/sacdap_clean/tree/main/static/pdfs/"
    click Attached "https://github.com/akboxer/sacdap_clean/tree/main/attached_assets/"
    click Req "https://github.com/akboxer/sacdap_clean/blob/main/requirements.txt"
    click PyProj "https://github.com/akboxer/sacdap_clean/blob/main/pyproject.toml"
    click GitIgnore "https://github.com/akboxer/sacdap_clean/blob/main/.gitignore"
    click README "https://github.com/akboxer/sacdap_clean/blob/main/README.md"
    click Venv "https://github.com/akboxer/sacdap_clean/tree/main/venv/"

    classDef frontend fill:#ADD8E6,stroke:#000
    classDef infra fill:#D3D3D3,stroke:#000
    classDef backend fill:#90EE90,stroke:#000
    classDef static fill:#FFD700,stroke:#000
    classDef config fill:#FFA500,stroke:#000
    classDef external fill:#FFB6C1,stroke:#000
```
