How frozsgy/gezenti works
Project type and purpose
• This is a full-stack web application: a daily travel game (“Gezenti”) featuring Turkish cities.
• Frontend is a single-page, vanilla-JS UI with a map, autocomplete, and modal dialogs.
• Backend is a Python/Flask service that serves static assets and supplies game data via JSON.
• The “data” folder also contains preprocessing scripts that generate JSON input for the game.
File structure
Top-level files and folders:
• Procfile, build.sh – deployment configuration (Heroku).
• README.md, LICENSE – documentation.
• data/ – Python scripts + city and permutation data and JSON outputs.
• frontend/ – static web assets (HTML, CSS, JS).
data/ sub-structure:
• backend.py – Flask application entry point (serves API and static files).
• calculate.py, shuffle_permutations.py, etc. – data-generation scripts.
• *.json, *.txt – preprocessed city lists, distances, permutations.
frontend/ sub-structure:
• index.html – main UI.
• css/ – style, autocomplete, SVG-map styles.
• js/ – game logic, map interactions, autocomplete integration.
Insights from README
• Backend: Python + Flask.
• Frontend: vanilla JS, using three external libs:
• svg-turkiye-haritasi (map).
• autoComplete.js (autocomplete).
• tingle (modal).
• build.sh automates bundling of frontend + backend.py + dependencies for Heroku.
Main components
A. Browser / Client
• index.html, style.css, game.js, svg-turkiye-haritasi.js, autocomplete.js, tingle.js.
• User interactions: map clicks, text input, submissions.
B. Web Server / API Layer
• Flask app (data/backend.py).
• Routes:
– GET / → serves index.html and static assets.
– GET /api/game or similar → returns today’s city-pair data JSON.
C. Data Layer
• Preprocessed JSON under data/ (cities.json, permutations.json, etc.).
• Python model classes (city.py, distance.py, game.py) used both for preprocessing and live logic.
D. Build & Deployment
• build.sh bundles everything under a deployable directory.
• Procfile instructs Heroku to run: “python backend.py”.
• Rendering library.
• Autocomplete library.
• Modal/dialog library.
Relationships and interactions
• The Browser requests index.html from Flask → Flask serves static file.
• Browser loads CSS and JS assets → renders UI.
• On page load or on button click, Browser sends AJAX request to Flask (/api/game).
• Flask reads JSON data, applies any game-logic via game.py, returns JSON response.
• Browser updates UI (map, suggestions, modal) based on JSON.
• build.sh reads frontend/ and data/backend.py + requirements.txt → produces final bundle.
• Deployment on Heroku uses Procfile to start the Flask process.
Architectural patterns and principles
• Monolithic architecture: a single Flask application handling both static assets and API.
• Layered separation:
• Presentation layer (frontend).
• Application/API layer (Flask).
• Data layer (JSON files + Python models).
• Preprocessing step decouples heavy data generation from runtime.
Elements
• From Browser → Flask (HTTP GET/POST).
• From Flask → JSON files (read).
• From build.sh → bundle directory.