How kmoore1616/gunnison-gps-tour works
Project type & purpose (what you’re diagramming)
This is a single-service monolithic Flask web application that:
• Serves server-rendered HTML pages (Jinja templates) for browsing Tours/Places and viewing a tour-specific walking route.
• Uses SQLite as the system of record for tours/places/reviews (including ordering stops via tour_places).
• Uses the Google Maps JS API in the browser to render an interactive map, and the backend exposes an endpoint (/get_tour_poly/<tour_id>) that returns encoded polylines (route geometry) for drawing.
• Browser → Flask app (HTTP routes)
• Flask app → SQLite (CRUD & relationships)
• Browser → Google Maps (JS API) and/or Flask app → Google services (if routes are computed server-side; at minimum the API key is injected for client-side usage)
• Admin pages as a separate “role” and route group, but still within the same Flask service.
File structure analysis (how the code is organized)
From the tree:
• app.py
The entire backend is likely here: Flask app creation, route handlers, SQLAlchemy models (or at least DB access), authentication (hinted by flask-login dependency), and the /get_tour_poly/<tour_id> endpoint.
• instance/gps-database.sqlite
• templates/*.html
Jinja templates (server-rendered UI). Notable groups:
• Visitor: home.html, tour_list.html, places.html, viewTour.html, onTour.html, contact.html, nav templates (visitornav.html)
• Admin: adminlogin.html, adminhome.html, edittours.html, adminfeedback.html, adminreviews.html, nav (adminnav.html)
• static/*.js, *.css
Frontend behavior and styling:
• static/map.js and static/index.js likely drive map rendering + AJAX/fetch calls to /get_tour_poly/<tour_id>.
• CSS files for layout/branding.
Architectural implication: this is a classic Flask MVC-ish setup:
• “Views” = templates/
• “Controller/routes” = app.py
• “Model/persistence” = SQLite (+ SQLAlchemy)
README insights (runtime and dependencies)
Key dependencies called out:
• flask, flask-sqlalchemy → web + ORM/persistence
• flask-login → admin authentication/session management
• python-dotenv → configuration via .env (MAPS_API_KEY)
• requests → indicates backend may call external HTTP services (potentially Google Directions API, or something else)
Key endpoints / pages called out:
• Visitor routes: /, /Tours, /Places, /Tour, /Contact, /viewTour/<tour_id>
• Admin: /adminhome, /edittours, /adminfeedback, /adminreviews
• Data endpoint: /get_tour_poly/<tour_id> (polyline payload for map drawing)
• Page rendering endpoints (HTML)
• JSON/data endpoint(s) consumed by JS
• Authentication boundary for admin routes
• External API key/config injection
Client / Browser
• “Visitor User”
• “Admin User” (same browser tech, different role/permissions)
Flask Web App (app.py)
• Route Handlers (HTTP): visitor pages + admin pages + /get_tour_poly/<tour_id>
• Auth/Session: Flask-Login (admin login, session cookie)
• DB Access Layer: SQLAlchemy (models/queries)
• Polyline/Route Service: the logic that produces encoded polylines (may be DB-backed or computed/cached)
SQLite Database (instance/gps-database.sqlite)
• tours
• places
• reviews
• tour_places (join table that orders stops)
Google Maps Platform (External)
• Google Maps JavaScript API (loaded by browser using MAPS_API_KEY)
Configuration / Secrets
• .env providing MAPS_API_KEY to server-side template rendering or runtime config (represent this as “Environment/Config” feeding the Flask app)
Browser → Flask
• GET / /Tours /Places /Contact /viewTour/<tour_id>
• Admin:
• GET/POST /adminlogin (implied by template)
• GET /adminhome, /edittours, /adminfeedback, /adminreviews
• Data:
• GET /get_tour_poly/<tour_id>
Flask → SQLite
• For visitor pages: read tours, places, ordered stops
• For admin pages: CRUD tours/places, moderate reviews/feedback
Browser → Google Maps
• Loads Maps JS + tiles + renders map
(Optional/if applicable) Flask → Google Web Service
• If the backend computes routes, it might call Directions API and then store/return encoded polyline
Flask ↔ Config (.env)
• At startup: loads MAPS_API_KEY via dotenv
Important patterns / principles used
• Server-rendered web app (Jinja templates)
• Role-based admin vs visitor flows (same service, different endpoints + auth)
• Thin JS client that fetches route polyline and draws on Google Map
• Relational data model with an ordering join table (tour_places) as a key domain concept
Relevant technologies in labels
• “Flask (Python)”
• “Flask-SQLAlchemy”
• “Flask-Login”
• “SQLite”
• “Jinja2 templates”
• “Google Maps JavaScript API”
• “dotenv (.env)”