How fitlogic-gymapp/gympro works
1. System boundary
- GymPro is a three-part system: a Flask REST backend, a Flutter cross-platform member app, and a browser-based admin panel.
- All user-facing clients communicate with the backend over HTTP/JSON; the clients do not talk to the database directly.
2. Backend core
- The backend is the central orchestration layer in backend/app.py.
- It exposes REST endpoints for authentication, gym membership data, workouts, turnstile events, and admin CRUD operations.
- CORS is enabled so both the Flutter app and the admin panel can call the API from different origins.
3. Persistence layer
- The backend uses MySQL via ODBC/pyodbc.
- backend/createDB.sql defines the schema; backend/populate_saas.py seeds sample SaaS-style tenant data.
- backend/.env.example shows environment-based DB configuration, including host, database name, user, and password.
4. Multi-tenant data model
- The repo is built around a single global member account plus per-gym membership records.
- The key boundary is the Membership table, which links a member to one or more gyms and allows gym-specific access, occupancy, and workout context.
- Gym-specific entities include trainers, admins, and settings tied to a gym ID.
5. Mobile app
- frontend/ is a Flutter app targeting Android, iOS, web, desktop, and mobile shells from one codebase.
- Its architecture is split into core/, features/, and shared/, with Provider-based state management and GoRouter-style navigation implied by the README and file layout.
- The mobile app is the member-facing client for login, gym selection, home dashboard, trainers, workouts, profile, and QR turnstile actions.
6. Frontend data flow
- UI screens call feature-specific providers, which call shared services, which then call the backend API.
- frontend/lib/core/services/api_service.dart is the main HTTP abstraction; auth_service.dart and turnstile_service.dart are specialized integrations.
- This layering keeps UI widgets separate from network logic and authentication/session concerns.
7. Member experience features
- The Flutter app contains distinct feature slices for:
- authentication and gym selection,
- home/dashboard,
- trainers,
- workouts,
- profile,
- QR entry/exit turnstile screens.
- home_provider.dart, trainers_provider.dart, and workouts_provider.dart indicate the app is state-driven, likely refreshing server data into UI models.
8. Turnstile subsystem
- The turnstile flow is a separate functional area, not just a UI screen.
- qr_entry_screen.dart and qr_exit_screen.dart feed check-in/check-out requests to the backend, which records TurnstileEvent rows and updates occupancy-related views/data.
- This subsystem is central to “real-time gym occupancy” in the product description.
9. Admin panel
- admin-panel/ is a lightweight web UI built with HTML + vanilla JavaScript.
- It likely consumes the same REST API to manage exercises, workout programs, trainers, members, and gym settings.
- This is an operational back-office boundary separate from the member-facing Flutter app.
10. Reporting and derived data
- The database includes views such as ActiveMembersView, TrainersInGymView, GymStatsView, TodayEntriesView, and MemberWorkoutSummaryView.
- These suggest the backend often reads precomputed or SQL-aggregated data for dashboards and list screens rather than assembling everything in application code.
11. Security and identity
- Authentication is handled centrally via POST /api/register and POST /api/login.
- The same authenticated identity is then reused across gym membership selection, workout data, and turnstile operations.
- The architecture implies role separation between members and gym admins, with admin endpoints grouped under /api/admin/....
12. Supporting tooling
- backend/test_api.py provides API-level testing for the Flask service.
- The Flutter tree includes platform shells for Android, iOS, web, macOS, Windows, and Linux, but the architectural center remains the shared Dart app code.
- The overall deployment model is simple: a locally run Flask API, a MySQL database, and independently launched client apps.
Main entry points: app.py Flask API · auth_provider.dart State providers · login_screen.dart Feature screens · main_navigation_shell.dart Navigation shell
Components 22
Backend
Flask API, persistence, and derived reporting.
- Flask API · Central REST orchestration layer exposing auth, membership, workouts, turnstile, and admin endpoints.
backend/app.py - CORS · Enables browser and Flutter clients to call the API from different origins.
backend/app.py - Auth routes · Register and login entry points for the shared user identity.
backend/app.py - Membership routes · Gym selection and member-to-gym access context.
backend/app.py - Workout routes · Workout program and member workout data served to the app.
backend/app.py - Turnstile routes · Check-in and check-out endpoints that record gym entry events.
backend/app.py - Admin routes · Gym administration endpoints for CRUD-style operations.
backend/app.py - MySQL access · Database connectivity through ODBC/pyodbc from the Flask service.
backend/app.py
Flutter app
Shared Dart app for gym members across platforms.
- Flutter app · Shared member-facing app for mobile and desktop/web shells.
frontend/lib/main.dart - Navigation shell · Main navigation and routing container for the member experience.
frontend/lib/shared/navigation/main_navigation_shell.dart - API service · Primary HTTP abstraction used by feature providers.
frontend/lib/core/services/api_service.dart - Auth service · Specialized authentication and session flow handling.
frontend/lib/core/services/auth_service.dart - Turnstile service · QR entry and exit request integration for check-in workflows.
frontend/lib/core/services/turnstile_service.dart - State providers · Provider-based state for auth, home, trainers, workouts, and turnstile flows.
frontend/lib/core/providers/auth_provider.dart - Feature screens · Member-facing screens for login, gym selection, home, trainers, workouts, profile, and QR actions.
frontend/lib/features/auth/screens/login_screen.dart - Feature models · Typed data models for home, trainers, and workouts.
frontend/lib/features/home/models/home_models.dart
Admin panel
Browser-based back-office UI.
- Admin UI · Lightweight browser interface for back-office gym management.
admin-panel/index.html - Admin script · Client-side JavaScript wiring for the admin panel.
admin-panel/app.js
Data layer
MySQL schema, seed data, and reporting views.
- Schema SQL · Defines tables, relations, and reporting views for the SaaS-style gym data model.
backend/createDB.sql - Seed data · Populates sample tenant and membership data.
backend/populate_saas.py - DB config · Environment-based connection settings for host, database, user, and password.
backend/.env.example - Reporting views · Precomputed views for active members, trainers, stats, today entries, and workout summaries.
backend/createDB.sql
Connections 24
- Flask API → CORS: enables · API is exposed with cross-origin access for both clients.
- Flask API → Auth routes: serves · Handles register and login requests.
- Flask API → Membership routes: serves · Exposes gym selection and membership context.
- Flask API → Workout routes: serves · Returns workout-related member and program data.
- Flask API → Turnstile routes: serves · Records entry and exit events.
- Flask API → Admin routes: serves · Provides admin CRUD endpoints.
- Flask API → MySQL access: reads/writes · Uses MySQL through ODBC/pyodbc.
- MySQL access → Schema SQL: uses · Persists to the defined schema.
- MySQL access → Reporting views: queries · Reads aggregated reporting views for dashboards and lists.
- Seed data → Schema SQL: loads · Seeds data into the defined tables.
- DB config → MySQL access: configures · Supplies connection parameters for the database layer.
- Flutter app → Navigation shell: uses · Entrypoint hands off to the shared navigation shell.
- Navigation shell → Feature screens: hosts · Switches between member screens and feature areas.
- Feature screens → State providers: reads state · Screens consume provider-driven app state.
- State providers → API service: calls · Feature state loads and refreshes server data through the API service.
- State providers → Auth service: uses · Authentication and session logic is centralized.
- State providers → Turnstile service: uses · QR check-in and check-out flows call the specialized service.
- API service → Flask API: HTTP/JSON · Member app communicates with the Flask backend over REST.
- Auth service → Auth routes: HTTP/JSON · Login and registration requests go to auth endpoints.
- Turnstile service → Turnstile routes: HTTP/JSON · Entry and exit scans are submitted to turnstile endpoints.
- Feature screens → Feature models: shapes data · Feature screens render typed home, trainer, and workout models.
- Admin UI → Admin script: runs · HTML shell loads the browser-side admin logic.
- Admin script → Flask API: HTTP/JSON · Admin panel consumes the same REST API as the mobile app.
- Turnstile routes → Reporting views: updates/readers · Turnstile events feed occupancy and today-entry reporting.