# ponnamsrisai/parking_app architecture

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

- Interactive diagram: https://gitdiagram.com/ponnamsrisai/parking_app
- Repository: https://github.com/ponnamsrisai/parking_app

## Overview

1. **Overall shape**
   - This is a small **monolithic Flask web application** for parking management.
   - All major concerns live in one repo: request handling (`app.py`), data models (`models/`), form validation (`controllers/forms.py`), database bootstrap (`db_schema.py`), and server-rendered UI (`templates/` + `static/`).

2. **Primary runtime boundary**
   - The browser talks to the Flask server over HTTP.
   - Flask renders HTML using **Jinja2 templates**, so the frontend is not a separate SPA; it is server-side rendered pages with some client-side styling/visualization.

3. **Request handling layer**
   - `app.py` is the application entry point and likely contains:
     - Flask app configuration
     - route definitions
     - login/session handling
     - role-based redirects for admin vs user
     - business logic for booking, releasing, and summary pages
   - This is the main orchestration layer that connects web requests to the database and templates.

4. **Domain/data layer**
   - `models/models.py` defines the persistent entities and relationships:
     - `User`
     - `Admin`
     - `ParkingLot`
     - `ParkingSpot`
     - `Booking`
   - The schema supports:
     - one parking lot to many parking spots
     - users creating bookings against spots
     - booking history with timestamps and cost calculation
   - Persistence is through **Flask-SQLAlchemy** with a local **SQLite** database.

5. **Authentication and authorization**
   - The app uses **Flask-Login** for session-based authentication.
   - Passwords are stored as hashes using **Flask-Bcrypt**.
   - The system is role-based:
     - **Admin** can manage lots, spots, users, and summaries
     - **User** can book/release spots and view personal history
   - Unauthorized access is handled by a dedicated `error_403.html` page, indicating explicit access control boundaries.

6. **Form validation boundary**
   - `controllers/forms.py` contains the WTForms/Flask-WTF definitions for user input.
   - This is the validation layer between browser-submitted data and the database/business logic.
   - It likely covers login/signup, parking lot creation, booking/release actions, and profile editing.

7. **Admin subsystem**
   - The admin-facing pages are:
     - `admin_dashboard.html`
     - `admin_summary.html`
     - `admin_users.html`
     - `admin_parking_spot.html`
     - `add_parking_lot.html`
   - This subsystem is responsible for:
     - creating and managing parking lots
     - observing occupancy and utilization
     - viewing registered users
     - seeing aggregated statistics

8. **User subsystem**
   - The user-facing pages are:
     - `user_dashboard.html`
     - `user_book.html`
     - `user_release.html`
     - `user_summary.html`
     - `edit_profile.html`
   - This subsystem handles:
     - account creation and sign-in
     - booking an available parking spot
     - releasing an occupied spot
     - showing individual parking history, duration, and total price

9. **Data flow for booking and release**
   - User action starts in a template form.
   - Flask-WTF validates the request.
   - `app.py` checks the authenticated user and spot availability.
   - The ORM updates:
     - spot status
     - occupancy counts in the parking lot
     - booking record with entry/exit time and price
   - The response is a redirected dashboard or summary page.

10. **Reporting and visualization**
   - The summary pages (`admin_summary.html`, `user_summary.html`) are the reporting boundary.
   - The README mentions **Chart.js**, so charts are likely embedded in these templates to visualize parking usage and statistics.
   - This is a read-heavy flow that aggregates data from bookings/lots rather than creating new entities.

11. **Database initialization**
   - `db_schema.py` is separate from the runtime app and is used to create the schema and seed the initial admin account.
   - That makes the architecture split between:
     - **startup/bootstrap concerns** in `db_schema.py`
     - **operational request handling** in `app.py`

12. **Presentation layer**
   - `templates/base.html` is the shared layout, with other pages extending it.
   - `static/css/styles.css` provides custom styling, while Bootstrap is used for responsive layout.
   - `static/images/` contains branding/assets, not core logic.

13. **Key architectural boundaries to show in a diagram**
   - Browser/UI → Flask routes
   - Routes → form validation
   - Routes → ORM models/database
   - Admin-only flows vs user-only flows
   - Initialization script → database schema/seed data
   - Summary/reporting views → aggregated booking and occupancy data

14. **Implementation style**
   - This repo is a traditional **server-rendered CRUD-style application** with role-based access control.
   - There are no separate microservices, message queues, or external APIs in the visible structure.
   - The main architectural idea is a clean separation between web pages, validation, persistence, and role-specific workflows.

Main entry points: [`app.py`](https://github.com/ponnamsrisai/parking_app/blob/main/app.py) (Flask App), [`templates/admin_dashboard.html`](https://github.com/ponnamsrisai/parking_app/blob/main/templates/admin_dashboard.html) (Admin Dashboard), [`templates/user_dashboard.html`](https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_dashboard.html) (User Dashboard), [`templates/base.html`](https://github.com/ponnamsrisai/parking_app/blob/main/templates/base.html) (Base Layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_app["Flask App<br/>web entry<br/>[app.py]"]
  node_forms["Forms<br/>validation<br/>[forms.py]"]
  node_dbschema["Schema Init<br/>bootstrap<br/>[db_schema.py]"]
end

subgraph group_ui["Presentation"]
  node_base["Base Layout<br/>template layout<br/>[base.html]"]
  node_index["Home<br/>template page<br/>[index.html]"]
  node_login["Login<br/>template page<br/>[login.html]"]
  node_signup["Signup<br/>template page<br/>[signup.html]"]
  node_admin_dash["Admin Dashboard<br/>admin page"]
  node_admin_manage["Admin Manage<br/>admin page"]
  node_admin_users["Users View<br/>admin page<br/>[admin_users.html]"]
  node_admin_summary["Admin Summary<br/>report page<br/>[admin_summary.html]"]
  node_user_dash["User Dashboard<br/>user page"]
  node_user_book["Book Spot<br/>user page<br/>[user_book.html]"]
  node_user_release["Release Spot<br/>user page<br/>[user_release.html]"]
  node_user_summary["User Summary<br/>report page<br/>[user_summary.html]"]
  node_profile["Edit Profile<br/>user page<br/>[edit_profile.html]"]
  node_forbidden["403 Page<br/>error page<br/>[error_403.html]"]
  node_styles["Styles<br/>static assets<br/>[styles.css]"]
end

subgraph group_domain["Domain"]
  node_models[("Models<br/>[models.py]")]
  node_sqlite[("SQLite DB<br/>database")]
end

node_browser(("Browser<br/>client"))

node_browser -->|"HTTP"| node_app
node_app -->|"validate"| node_forms
node_app -->|"ORM"| node_models
node_models -->|"persist"| node_sqlite
node_dbschema -->|"create/seed"| node_sqlite
node_app -->|"render"| node_base
node_base -->|"style"| node_styles
node_app -->|"render"| node_index
node_app -->|"render"| node_login
node_app -->|"render"| node_signup
node_app -->|"render"| node_admin_dash
node_app -->|"render"| node_admin_manage
node_app -->|"render"| node_admin_users
node_app -->|"render"| node_admin_summary
node_app -->|"render"| node_user_dash
node_app -->|"render"| node_user_book
node_app -->|"render"| node_user_release
node_app -->|"render"| node_user_summary
node_app -->|"render"| node_profile
node_app -->|"deny"| node_forbidden
node_admin_dash -.->|"navigate"| node_admin_manage
node_admin_dash -.->|"navigate"| node_admin_users
node_admin_dash -.->|"navigate"| node_admin_summary
node_user_dash -.->|"navigate"| node_user_book
node_user_dash -.->|"navigate"| node_user_release
node_user_dash -.->|"navigate"| node_user_summary

click node_app "https://github.com/ponnamsrisai/parking_app/blob/main/app.py"
click node_forms "https://github.com/ponnamsrisai/parking_app/blob/main/controllers/forms.py"
click node_dbschema "https://github.com/ponnamsrisai/parking_app/blob/main/db_schema.py"
click node_models "https://github.com/ponnamsrisai/parking_app/blob/main/models/models.py"
click node_base "https://github.com/ponnamsrisai/parking_app/blob/main/templates/base.html"
click node_index "https://github.com/ponnamsrisai/parking_app/blob/main/templates/index.html"
click node_login "https://github.com/ponnamsrisai/parking_app/blob/main/templates/login.html"
click node_signup "https://github.com/ponnamsrisai/parking_app/blob/main/templates/signup.html"
click node_admin_dash "https://github.com/ponnamsrisai/parking_app/blob/main/templates/admin_dashboard.html"
click node_admin_manage "https://github.com/ponnamsrisai/parking_app/blob/main/templates/add_parking_lot.html"
click node_admin_users "https://github.com/ponnamsrisai/parking_app/blob/main/templates/admin_users.html"
click node_admin_summary "https://github.com/ponnamsrisai/parking_app/blob/main/templates/admin_summary.html"
click node_user_dash "https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_dashboard.html"
click node_user_book "https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_book.html"
click node_user_release "https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_release.html"
click node_user_summary "https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_summary.html"
click node_profile "https://github.com/ponnamsrisai/parking_app/blob/main/templates/edit_profile.html"
click node_forbidden "https://github.com/ponnamsrisai/parking_app/blob/main/templates/error_403.html"
click node_styles "https://github.com/ponnamsrisai/parking_app/blob/main/static/css/styles.css"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_forms,node_dbschema toneBlue
class node_base,node_index,node_login,node_signup,node_admin_dash,node_admin_manage,node_admin_users,node_admin_summary,node_user_dash,node_user_book,node_user_release,node_user_summary,node_profile,node_forbidden,node_styles toneAmber
class node_models,node_sqlite toneMint
class node_browser toneNeutral
```

## Components

### Runtime

Flask request handling and startup/bootstrap boundaries

- [Flask App](https://github.com/ponnamsrisai/parking_app/blob/main/app.py): web entry · Main application entry point with routes, session handling, and workflow orchestration · `app.py`
- [Forms](https://github.com/ponnamsrisai/parking_app/blob/main/controllers/forms.py): validation · WTForms and Flask-WTF input validation boundary · `controllers/forms.py`
- [Schema Init](https://github.com/ponnamsrisai/parking_app/blob/main/db_schema.py): bootstrap · Database creation and initial admin seeding · `db_schema.py`

### Presentation

Server-rendered templates and static assets

- [Base Layout](https://github.com/ponnamsrisai/parking_app/blob/main/templates/base.html): template layout · Shared Jinja2 layout extended by all pages · `templates/base.html`
- [Home](https://github.com/ponnamsrisai/parking_app/blob/main/templates/index.html): template page · Landing page for unauthenticated visitors · `templates/index.html`
- [Login](https://github.com/ponnamsrisai/parking_app/blob/main/templates/login.html): template page · Sign-in page · `templates/login.html`
- [Signup](https://github.com/ponnamsrisai/parking_app/blob/main/templates/signup.html): template page · Account registration page · `templates/signup.html`
- [Admin Dashboard](https://github.com/ponnamsrisai/parking_app/blob/main/templates/admin_dashboard.html): admin page · Admin home for managing the parking system · `templates/admin_dashboard.html`
- [Admin Manage](https://github.com/ponnamsrisai/parking_app/blob/main/templates/add_parking_lot.html): admin page · Parking lot and spot management views · `templates/add_parking_lot.html`
- [Users View](https://github.com/ponnamsrisai/parking_app/blob/main/templates/admin_users.html): admin page · Registered users listing and administration · `templates/admin_users.html`
- [Admin Summary](https://github.com/ponnamsrisai/parking_app/blob/main/templates/admin_summary.html): report page · Aggregated parking utilization and statistics · `templates/admin_summary.html`
- [User Dashboard](https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_dashboard.html): user page · Authenticated user landing page · `templates/user_dashboard.html`
- [Book Spot](https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_book.html): user page · Booking flow for an available parking spot · `templates/user_book.html`
- [Release Spot](https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_release.html): user page · Release flow for an occupied parking spot · `templates/user_release.html`
- [User Summary](https://github.com/ponnamsrisai/parking_app/blob/main/templates/user_summary.html): report page · Personal booking history, duration, and cost summary · `templates/user_summary.html`
- [Edit Profile](https://github.com/ponnamsrisai/parking_app/blob/main/templates/edit_profile.html): user page · User profile editing view · `templates/edit_profile.html`
- [403 Page](https://github.com/ponnamsrisai/parking_app/blob/main/templates/error_403.html): error page · Unauthorized access response page · `templates/error_403.html`
- [Styles](https://github.com/ponnamsrisai/parking_app/blob/main/static/css/styles.css): static assets · Custom CSS and visual styling assets · `static/css/styles.css`

### Domain

Persistent models and database-backed business state

- [Models](https://github.com/ponnamsrisai/parking_app/blob/main/models/models.py): orm models · SQLAlchemy entities and relationships for users, lots, spots, and bookings · `models/models.py`
- **SQLite DB**: database · Local persistent storage for parking data and history

### Other components

- **Browser**: client · Users interact with the app through the web UI

## Connections

- Browser → Flask App: HTTP · Browser requests are handled by Flask
- Flask App → Forms: validate · Route handlers validate submitted user input
- Flask App → Models: ORM · Business actions read and write parking data through SQLAlchemy models
- Models → SQLite DB: persist · Models store application state in SQLite
- Schema Init → SQLite DB: create/seed · Bootstrap script creates the schema and initial admin record
- Flask App → Base Layout: render · All server-rendered pages extend the shared base layout
- Base Layout → Styles: style · Templates pull in shared styling and assets
- Flask App → Home: render · Public landing page
- Flask App → Login: render · Authentication page
- Flask App → Signup: render · Registration page
- Flask App → Admin Dashboard: render · Admin-only dashboard flow
- Flask App → Admin Manage: render · Admin lot and spot management flow
- Flask App → Users View: render · Admin user management flow
- Flask App → Admin Summary: render · Admin reporting and aggregation flow
- Flask App → User Dashboard: render · Authenticated user dashboard
- Flask App → Book Spot: render · Booking flow for users
- Flask App → Release Spot: render · Release flow for users
- Flask App → User Summary: render · Personal usage and cost summary
- Flask App → Edit Profile: render · Profile editing flow
- Flask App → 403 Page: deny · Unauthorized requests resolve to a 403 page
- Admin Dashboard → Admin Manage: navigate · Admin dashboard links to management views
- Admin Dashboard → Users View: navigate · Admin dashboard links to user administration
- Admin Dashboard → Admin Summary: navigate · Admin dashboard links to reporting
- User Dashboard → Book Spot: navigate · User dashboard leads to booking
- User Dashboard → Release Spot: navigate · User dashboard leads to release
- User Dashboard → User Summary: navigate · User dashboard leads to history and totals
