# ramilevi1/website-template architecture

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

- Interactive diagram: https://gitdiagram.com/ramilevi1/website-template
- Repository: https://github.com/ramilevi1/website-template

## Overview

##### Main Components
- Client Layer: Represent the end-user devices (browsers) which interact with the website.
- Frontend: This includes static assets (HTML, CSS, JavaScript, images) served under the “static” and “templates” directories. The frontend is responsible for rendering the pages (e.g., index.html, blog.html, sign-in.html) and interacting with the backend via Ajax.
- Backend (Flask Application): The heart of the project, represented by app.py and other supporting modules like models.py, database.py, and migrations. This is where business logic, routing, user authentication, and REST API endpoints reside.
- Database: The SQLite databases (site.db in the project root, the “db” and “instance” directories) are managed via Flask’s SQLAlchemy and migrate scripts. This layer is crucial for user data, blog posts, newsletter subscribers, etc.
- Microservice Candidates/Future Services: Although currently all integrated, plan placeholders (or separate components) for:
- Newsletter Service: Indicated by newletterScript.py, which handles scheduled sending of newsletters.
- Blog Parsing Service: Handled via parse_blogs.py, dedicated to dynamically parsing blog content.
- Future Microservices for offerRide and searchRide: Mark these for later separation.
- Testing and CI/CD: Inclusion of the “my_playwright_tests” directory (e2e tests) and other unit tests (test_app.py, test_config.py) shows there is a testing framework. Also, GitHub Actions workflows (.github/workflows) tie into continuous integration setups.

##### Relationships and Data Flow
- Web clients issue HTTP/HTTPS requests to the Flask application.
- The Flask application serves dynamic pages by combining routes/components defined in app.py and templates.
- For authentication, the backend interacts with a user and session management mechanism.
- The Flask app interacts with the SQLite databases to persist user, blog, and newsletter data.
- Background processes (like newsletter dispatch and blog parsing) operate either directly or via asynchronous job queues (future RabbitMQ integration).

##### Architectural Patterns and Design Principles
- MVC (or “MVT” in Flask terminology): View templates in the “templates” folder, static frontend assets, and controllers in the Flask app.
- Separation of Concerns: Distinct modules for handling database interactions (models.py, database.py), migrations for database schema evolution (migrations folder), and frontend assets (static folder).
- Planned Microservices: Although not fully decoupled, the design anticipates an N-tier/microservices split, where authentication, content rendering, email handling, and possibly blog search functionalities could be split into distinct services.

##### Relevant Technologies
- Flask for the backend, with Flask extensions (Flask-Login, Flask-Migrate, Flask-Mail, etc.).
- SQLite3 as the database.
- HTML5, CSS3, JavaScript (vanilla and jQuery) for the frontend.
- Bootstrap and MixItUp for styling and interactive elements.
- Playwright for basic end-to-end tests.
- Future plans involving RabbitMQ, MongoDB, containerization techniques, and deployment options like uWSGI with Nginx/Apache should be noted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Client("Client (Browser)"):::client
        Frontend("Frontend<br>Static Assets & Templates"):::frontend
        Static["static"]:::frontendAsset
        Templates["templates"]:::frontendAsset
    end

    %% Application Layer
    subgraph "Application Layer"
        Backend("Flask Application"):::backend
        App["app.py"]:::fileBackend
        Models["models.py"]:::fileBackend
        DatabaseLogic["database.py"]:::fileBackend
        Migrations["migrations"]:::folderBackend
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["SQLite Database<br>site.db, db/site.db, instance/site.db"]:::database
    end

    %% Microservices & Background Services (Planned)
    subgraph "Microservices & Background Services (Planned)"
        Newsletter("Newsletter Service"):::service
        NewsletterFile["newletterScript.py"]:::fileBackend
        BlogParser("Blog Parsing Service"):::service
        BlogParserFile["parse_blogs.py"]:::fileBackend
        FutureMS("Offer/Search Ride Service (Planned)"):::serviceFuture
    end

    %% Testing & CI/CD
    subgraph "Testing & CI/CD"
        Playwright("Playwright Tests<br>my_playwright_tests"):::tests
        UnitTest1["test_app.py"]:::testsFile
        UnitTest2["test_config.py"]:::testsFile
        CI("CI Workflows<br>.github/workflows"):::ci
    end

    %% Connections from Presentation to Application
    Client -->|"HTTP/HTTPS"| Frontend
    Frontend -->|"serves"| Static
    Frontend -->|"renders"| Templates
    Frontend -->|"AJAX/HTTP"| Backend

    %% Internal Backend Components
    Backend -->|"routes/control"| App
    Backend -->|"business logic"| Models
    Backend -->|"data operations"| DatabaseLogic
    Backend -->|"migrations"| Migrations

    %% Database interaction
    Backend -->|"read/write"| DB

    %% Background Service Invocations
    Backend -->|"trigger send"| Newsletter
    Newsletter -->|"executes"| NewsletterFile
    Backend -->|"initiate parse"| BlogParser
    BlogParser -->|"executes"| BlogParserFile

    %% Future Microservices indication
    Backend ---|"planned separation"| FutureMS

    %% Testing & CI/CD connections
    Playwright ---|"E2E tests"| Backend
    UnitTest1 ---|"unit tests"| Backend
    UnitTest2 ---|"unit tests"| Backend
    CI ---|"runs"| Playwright

    %% Click Events
    click Static "https://github.com/ramilevi1/website-template/tree/master/static"
    click Templates "https://github.com/ramilevi1/website-template/tree/master/templates"
    click App "https://github.com/ramilevi1/website-template/blob/master/app.py"
    click Models "https://github.com/ramilevi1/website-template/blob/master/models.py"
    click DatabaseLogic "https://github.com/ramilevi1/website-template/blob/master/database.py"
    click Migrations "https://github.com/ramilevi1/website-template/tree/master/migrations"
    click DB "https://github.com/ramilevi1/website-template/blob/master/site.db"
    click NewsletterFile "https://github.com/ramilevi1/website-template/blob/master/newletterScript.py"
    click BlogParserFile "https://github.com/ramilevi1/website-template/blob/master/parse_blogs.py"
    click Playwright "https://github.com/ramilevi1/website-template/tree/master/my_playwright_tests"
    click UnitTest1 "https://github.com/ramilevi1/website-template/blob/master/test_app.py"
    click UnitTest2 "https://github.com/ramilevi1/website-template/blob/master/test_config.py"
    click CI "https://github.com/ramilevi1/website-template/tree/master/.github/workflows"

    %% Styles
    classDef client fill:#ffefd5,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ffe4e1,stroke:#333,stroke-width:2px;
    classDef frontendAsset fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef backend fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef fileBackend fill:#87cefa,stroke:#333,stroke-width:2px;
    classDef folderBackend fill:#4682b4,stroke:#fff,stroke-width:2px;
    classDef database fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef service fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef serviceFuture fill:#ee82ee,stroke:#333,stroke-width:2px;
    classDef tests fill:#fafad2,stroke:#333,stroke-width:2px;
    classDef testsFile fill:#ffe4b5,stroke:#333,stroke-width:2px;
    classDef ci fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
