# night-master/sdlc_python architecture

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

- Interactive diagram: https://gitdiagram.com/night-master/sdlc_python
- Repository: https://github.com/night-master/sdlc_python

## Overview

##### Project type and purpose
- This is a full-stack, front-end/back-end separated DevSecOps web platform (“sdlc_python”).
- Purpose: simulate common vulnerabilities for security training and perform AI-powered code audits (shift security left in SDLC).

##### File structure
- Top-level “sdlc_python_front” folder: Vue 3 single-page application (SPA) – components, views, router, store, assets, config, public.
- Top-level “sdlc_python_backend” folder: Flask application – app.py entrypoint, middleware, routes, utilities, vulnerability modules, SQLite database, uploads.
- “data” folder holds sample screenshots.
- Deployment: start.bat runs backend (Flask) and serves front-end (built Vue assets).

##### Main components
a. Client Browser (User’s web browser with SPA)
b. Front-End Application (Vue 3):
- Modules: router, state management (Vuex or Pinia), views, components, HTTP client for API calls.
- Built static assets (HTML/CSS/JS) served by web server or Flask static endpoint.
c. Back-End Application (Flask API):
- API Layer (routes/routes.py): login, vulnerability demos, code scanning endpoints.
- Middleware (authentication, request preprocessing).
- Vulnerability Simulation Modules (bac.py, xss.py, rce.py, etc.)
- Code Audit Module (integrates with large language model via utils/get_code.py)
- Utilities (database connection, JWT utils, HTTP client utils)
d. Database (SQLite test.db): stores users, sessions, scan reports.
e. File Storage (uploads directory): holds code samples for scanning, file uploads for demos.
f. External Service: Large Language Model API (for AI code audit)

##### Relationships and data flows
- User Browser → HTTP(S) → Vue SPA (served via Nginx/Flask)
- Vue SPA → HTTP API calls → Flask API
- Login → Flask Auth middleware → SQLite
- Fetch vulnerability demo pages → Flask static/templates
- Submit code for scan → Flask code-audit handler → LLM API → audit results → Flask returns JSON → Vue displays results
- Flask → SQLite (reads/writes users, scan results)
- Flask → File Storage (reads demo assets, writes uploads)
- Flask → External LLM API (code audit)

##### Architectural patterns and design principles
- Front-end/Back-end separation with RESTful API.
- Modular Flask structure:
- “middleware” layer for cross-cutting concerns (auth, logging).
- “routes” layer as controller.
- “vulnerabilities” modules as business logic.
- “utils” for shared services (DB, JWT, HTTP).
- Vue component-based UI, central state management, router guard for auth.
- Lightweight SQLite for prototype, easily replaceable with other RDBMS.

- Major components (browser, front-end, back-end, database, file store, external AI).
- Related sub-modules in each component.
- Clear, legible labels and directional flow.
- “shift-left code audit” flow: front-end → Flask → LLM → results → front-end.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Front-End Layer
    subgraph "Front-End (Vue SPA)" 
        direction TB
        Browser["Client Browser"]:::frontend
        SPA["Vue 3 SPA"]:::frontend
        Router["Router Module"]:::frontend
        Store["State Management (Store)"]:::frontend
        Views["Views"]:::frontend
        Components["Components"]:::frontend
        HTTPClient["HTTP Client Utilities"]:::frontend
    end

    %% Back-End Layer
    subgraph "Back-End (Flask API)"
        direction TB
        Entrypoint["app.py Entrypoint"]:::backend
        Middleware["Middleware Layer"]:::backend
        Routes["API Layer (routes.py)"]:::backend
        subgraph "Vulnerability Modules"
            direction TB
            BAC["bac.py"]:::backend
            XSS["xss.py"]:::backend
            RCE["rce.py"]:::backend
            SQL["sql.py"]:::backend
            FileHandle["file_handle.py"]:::backend
            LogicalBug["logical_bug_buy.py"]:::backend
        end
        subgraph "Utils"
            direction TB
            GetCode["Code Audit Module (get_code.py)"]:::backend
            Utils["General Utilities (ultils.py)"]:::backend
        end
        DB[(SQLite test.db)]:::datastore
        Uploads[/uploads/]:::datastore
    end

    %% External Services
    LLM["External LLM API"]:::external

    %% Data Flows
    Browser -->|"loads SPA over HTTP(S)"| SPA
    SPA -->|"uses Router"| Router
    SPA -->|"uses Store"| Store
    SPA -->|"renders Views"| Views
    SPA -->|"uses Components"| Components
    SPA -->|"calls API via HTTP Client"| HTTPClient
    HTTPClient -->|"API calls (JSON)"| Routes
    Routes -->|"passes through"| Middleware
    Middleware -->|"invokes"| Routes
    Routes -->|"login, demos, scan"| DB
    Routes -->|"read/write demos"| Uploads
    Routes -->|"calls vulnerabilities"| BAC
    Routes -->|"calls vulnerabilities"| XSS
    Routes -->|"calls vulnerabilities"| RCE
    Routes -->|"calls vulnerabilities"| SQL
    Routes -->|"calls vulnerabilities"| FileHandle
    Routes -->|"calls vulnerabilities"| LogicalBug
    Routes -->|"calls code audit"| GetCode
    GetCode -->|"invokes LLM API"| LLM
    GetCode -->|"uses utils"| Utils
    LLM -->|"audit results"| GetCode
    GetCode -->|"returns results"| Routes
    Routes -->|"JSON response"| HTTPClient
    HTTPClient -->|"renders results"| SPA

    %% Click Events
    click SPA "https://github.com/night-master/sdlc_python/tree/main/sdlc_python_front/"
    click Router "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_front/src/router/index.ts"
    click Store "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_front/src/store/index.ts"
    click Store "https://github.com/night-master/sdlc_python/tree/main/sdlc_python_front/src/store/modules/"
    click Views "https://github.com/night-master/sdlc_python/tree/main/sdlc_python_front/src/views/"
    click Components "https://github.com/night-master/sdlc_python/tree/main/sdlc_python_front/src/components/"
    click HTTPClient "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_front/src/utils/request.js"
    click HTTPClient "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_front/src/utils/request_ai_code.js"
    click Entrypoint "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/app.py"
    click Middleware "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/middleware/middleware.py"
    click Routes "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/routes/routes.py"
    click BAC "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/vulnerabilities/bac.py"
    click XSS "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/vulnerabilities/xss.py"
    click RCE "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/vulnerabilities/rce.py"
    click SQL "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/vulnerabilities/sql.py"
    click FileHandle "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/vulnerabilities/file_handle.py"
    click LogicalBug "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/vulnerabilities/logical_bug_buy.py"
    click GetCode "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/utils/get_code.py"
    click Utils "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/utils/ultils.py"
    click DB "https://github.com/night-master/sdlc_python/blob/main/sdlc_python_backend/test.db"
    click Uploads "https://github.com/night-master/sdlc_python/tree/main/sdlc_python_backend/uploads/"

    %% Styles
    classDef frontend fill:#e0f7e9,stroke:#34a853,color:#000
    classDef backend fill:#e8f0fe,stroke:#1a73e8,color:#000
    classDef datastore fill:#f1f3f4,stroke:#5f6368,color:#000
    classDef external fill:#fff3e0,stroke:#f9ab00,color:#000
```
