# mohammad-oghli/travel-site-flask architecture

> Architecture diagram of the GitHub repository mohammad-oghli/travel-site-flask, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohammad-oghli/travel-site-flask
- Repository: https://github.com/mohammad-oghli/travel-site-flask

## Overview

##### Project type and purpose
- This is a simple full-stack web application built with Flask (a Python microframework).
- Purpose: A travel planning site that lets users register, log in, view and add travel destinations, and log out.

##### File structure
- Top-level files:
- app.py – Application factory and Flask config
- routes.py – URL routes and view functions
- models.py – Database models (SQLAlchemy)
- forms.py – WTForms definitions for registration/login/destination forms
- my_database.db – SQLite file
- Procfile – Deployment instructions (Heroku)
- requirements.txt – Python dependencies
- templates/ – Jinja2 HTML templates (base.html, landing_page.html, login.html, register.html, user.html)
- No separate frontend framework—templating is server-side.
- __pycache__ and .idea are development artefacts.

##### README for insights
- Confirms SQLite + SQLAlchemy, Flask command setup, core features, and deployment on localhost (5000).
- No external APIs or microservices; purely monolithic.

##### Main components and interactions
a. Client (Web Browser)
- Sends HTTP(S) requests to the Flask application
b. Flask Application Server
- app.py: Initializes Flask app and database
- routes.py: Defines endpoints (/register, /login, /user, /add-destination, /logout)
- forms.py: Validates and processes form data
- models.py: Defines User and Destination ORM models
- Templates: Renders HTML pages with Jinja2
c. Database
- SQLite file (my_database.db) accessed via SQLAlchemy
d. Deployment Layer (optional)
- Procfile indicates Gunicorn or built-in server on Heroku

##### Relationships and data flow
- Browser → (HTTP POST/GET) → Flask routes
- Flask routes ↔ forms.py for validation
- Flask routes ↔ models.py → SQLAlchemy sessions
- SQLAlchemy → SQLite DB → persistence of users and destinations
- Flask routes → templates → HTML response → Browser

##### Architectural patterns and design principles
- MVC-style separation:
- Models: models.py
- Views/Controllers: routes.py + app.py
- Templates (Views): Jinja2 files in /templates
- Layered architecture:
- Presentation (templates),
- Application logic (routes/forms),
- Data access (models/SQLite)

##### Relevant technologies/frameworks
- Python 3.x, Flask, Flask-WTForms, Flask-SQLAlchemy, Jinja2, SQLite, Gunicorn (Heroku via Procfile), pip for dependencies

##### Detail
- How the session/cookie authentication fits in (Flask-Login or custom check)
- Procfile as a secondary deployment component if diagramming production

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Browser["Web Browser"]:::presentation

    %% Application Layer
    subgraph "Flask Application"
        direction TB
        AppInit["app.py\n(Application Init)"]:::logic
        Controllers["routes.py\n(Controllers/Views)"]:::logic
        Validation["forms.py\n(Validation)"]:::logic
        Models["models.py\n(ORM Models)"]:::data
        subgraph "Templates (Jinja2)"
            direction TB
            BaseT["base.html"]:::presentation
            LandingT["landing_page.html"]:::presentation
            LoginT["login.html"]:::presentation
            RegisterT["register.html"]:::presentation
            UserT["user.html"]:::presentation
        end
    end

    %% Persistence & Deployment
    DB["my_database.db\n(SQLite DB)"]:::data
    Proc["Procfile\n(Deployment)"]:::infra
    Req["requirements.txt"]:::infra
    Docs["readme.md"]:::infra

    %% Data Flows
    Browser -->|HTTP GET/POST| Controllers
    Controllers -->|calls| Validation
    Controllers -->|uses| Models
    Models -->|SQL Query| DB
    Controllers -->|renders| BaseT
    Controllers -->|renders| LandingT
    Controllers -->|renders| LoginT
    Controllers -->|renders| RegisterT
    Controllers -->|renders| UserT
    BaseT -->|HTML Response| Browser
    LandingT -->|HTML Response| Browser
    LoginT -->|HTML Response| Browser
    RegisterT -->|HTML Response| Browser
    UserT -->|HTML Response| Browser

    AppInit --> Controllers
    AppInit --> Models
    AppInit --> Validation

    %% Documentation & Config
    Proc --> AppInit
    Req --> AppInit
    Docs --> AppInit

    %% Click Events
    click AppInit "https://github.com/mohammad-oghli/travel-site-flask/blob/main/app.py"
    click Controllers "https://github.com/mohammad-oghli/travel-site-flask/blob/main/routes.py"
    click Validation "https://github.com/mohammad-oghli/travel-site-flask/blob/main/forms.py"
    click Models "https://github.com/mohammad-oghli/travel-site-flask/blob/main/models.py"
    click DB "https://github.com/mohammad-oghli/travel-site-flask/blob/main/my_database.db"
    click Proc "https://github.com/mohammad-oghli/travel-site-flask/tree/main/Procfile"
    click Req "https://github.com/mohammad-oghli/travel-site-flask/blob/main/requirements.txt"
    click Docs "https://github.com/mohammad-oghli/travel-site-flask/blob/main/readme.md"
    click BaseT "https://github.com/mohammad-oghli/travel-site-flask/blob/main/templates/base.html"
    click LandingT "https://github.com/mohammad-oghli/travel-site-flask/blob/main/templates/landing_page.html"
    click LoginT "https://github.com/mohammad-oghli/travel-site-flask/blob/main/templates/login.html"
    click RegisterT "https://github.com/mohammad-oghli/travel-site-flask/blob/main/templates/register.html"
    click UserT "https://github.com/mohammad-oghli/travel-site-flask/blob/main/templates/user.html"

    %% Styles
    classDef presentation fill:#f9f,stroke:#333,stroke-width:1px
    classDef logic fill:#bbf,stroke:#333,stroke-width:1px
    classDef data fill:#bfb,stroke:#333,stroke-width:1px
    classDef infra fill:#ffeb99,stroke:#333,stroke-width:1px
```
