Files
gymflow/specs/requirements.md

144 lines
7.5 KiB
Markdown

# Application Requirements
This document outlines the functional requirements of the GymFlow application, derived from an analysis of its React components and backend services.
## I. Core & Authentication
### A. Login (`Login.tsx`)
- **User Authentication:** Users must be able to log in using their email and password.
- **First-Time Password Change:** On their initial login, users are required to change their temporary password.
- **Language Selection:** The interface language can be toggled between English and Russian directly on the login screen.
### B. Navigation (`Navbar.tsx`)
- **Primary Navigation:** A persistent navigation bar (bottom on mobile, side rail on desktop) allows access to the main sections of the application:
- Tracker
- Plans
- History
- Stats
- AI Coach
- Profile
## II. Workout Management
### A. Workout Plans (`Plans.tsx`)
- **CRUD Operations:** Users can create, view, update, and delete their workout plans.
- **Plan Composition:** A plan consists of a name, a descriptive text (for preparation/instructions), and an ordered list of exercises.
- **Exercises List Reordering:** Exercises within a plan can be reordered via a drag-and-drop interface.
- **Starting a Session:** Users can initiate a workout session from a selected plan in the list.
### B. Exercise Library (`Plans.tsx`, `Profile.tsx`)
- **Custom Exercise Creation:** Users can define new exercises, specifying:
- Name: The input field should suggest capitalizing each word for mobile users.
- Type (e.g., Strength, Bodyweight, Cardio)
- For bodyweight exercises, a percentage of body weight to be used in calculations.
- **Exercise Management:** From the profile section, users can view all their created exercises, edit their names, and archive or unarchive them.
## III. Workout Tracking
### A. Tracker Hub (`Tracker/index.tsx`)
- **Central Control:** This component orchestrates the tracking experience, displaying the appropriate view based on the current state (idle, in-session, or sporadic logging).
### B. Idle State (`Tracker/IdleView.tsx`)
- **Session Initiation:** From the idle screen, users can:
- Start a "Free Workout" without a predefined plan.
- Begin a "Quick Log" session for sporadic, one-off sets.
- Select and start a workout from their list of saved plans.
- **Session Body Weight Entry:** Users can input their current body weight before starting a session; the default value comes from user profile; this weight is associated with the active session for accurate calculations.
- **Plan Preview:** If a plan includes a description, it is displayed to the user for review before the session begins.
### C. Active Session (`Tracker/ActiveSessionView.tsx`)
- **Real-Time Timer:** A running timer displays the elapsed time for the current workout.
- **Exercise Selection:** Users can search for and select the exercise they are performing. The search field filters available exercises as the user types and clears its content automatically when focused. New exercises can be created on-the-fly.
- **Set Logging:** Users can log completed sets, with input fields dynamically adjusting based on the selected exercise's type (e.g., weight/reps for strength, duration/distance for cardio).
- **Session Body Weight:** The body weight entered before the session is displayed and used for calculations within the active session.
- **Session History:** A chronological list of sets logged during the current session is displayed.
- **Set Management:** Logged sets can be edited to correct data or deleted entirely.
- **Plan Progression:** When following a plan, the interface highlights the current exercise. Users can view the full plan and jump to different steps if needed.
- **Session Control:** Users can finish the session (saving the data) or quit without saving.
### D. Sporadic Logging (`Tracker/SporadicView.tsx`)
- **Ad-Hoc Tracking:** Enables logging of individual sets outside of a structured workout session.
- **Quick Access:** Optimized for quickly selecting an exercise, entering metrics, and logging the set. The exercise selection field filters available exercises as the user types and clears its content automatically when focused.
- **Daily History:** Displays a list of all sporadic sets logged on the current day.
## IV. Data & Progress
### A. Session History (`History.tsx`)
- **Workout Review:** Provides a comprehensive list of all past workout sessions and sporadic sets, grouped by day.
- **Detailed View:** Users can inspect the details of each session, including all sets performed.
- **Data Correction:** Past sessions and their individual sets can be edited or deleted.
### B. Performance Statistics (`Stats.tsx`)
- **Visualizations:** The application generates and displays charts to track progress over time, including:
- **Total Volume:** The total weight lifted in each session.
- **Set Count:** The number of sets performed per session.
- **Body Weight:** A line graph of the user's body weight over time.
## V. User & System Management
### A. User Profile (`Profile.tsx`)
- **Personal Information:** Users can view and update their personal data, including weight, height, birth date, and gender.
- **Dedicated Daily Weight Logging:** Users can log their body weight daily, and view a history of these records.
- **Account Management:** Users can change their password and (if not an admin) delete their own account.
- **Language Preference:** The application language can be changed.
### B. AI Coach (`AICoach.tsx`)
- **Conversational AI:** Provides an interactive chat interface with an AI fitness expert.
- **Contextual Awareness:** The AI is primed with the user's workout history, plans, and profile data to provide personalized advice and analysis.
### C. Admin Panel (within `Profile.tsx`)
- **User Administration:** Admin-level users have access to a special panel to manage the user base.
- **User CRUD:** Admins can create new users, view a list of all users, block/unblock, and delete users.
- **Password Resets:** Admins can reset the passwords for non-admin users.
## VI. User Interface & Experience
### A. Adaptive GUI
- **Responsive Navigation:**
- On mobile devices, the application displays a bottom navigation bar.
- On desktop devices, a vertical navigation rail is displayed on the left side.
- **Fluid Layout:** The application's content layout adapts to different screen sizes, ensuring usability across a wide range of devices.
- **Responsive Charts:** Data visualizations in the statistics section are responsive and scale to fit the available screen space.
## VII. Backend API Endpoints
The frontend components interact with a backend service through the following conceptual endpoints:
- **Authentication:**
- `POST /auth/login`
- `POST /auth/change-password`
- `GET /auth/me`
- **Users (Admin):**
- `GET /users`
- `POST /users/create`
- `DELETE /users/:id`
- `PUT /users/toggle-block/:id`
- `POST /users/admin-reset-password`
- **User Profile:**
- `PUT /users/profile/:id`
- **Workout Plans:**
- `GET /plans`
- `POST /plans`
- `DELETE /plans/:id`
- **Exercises:**
- `GET /exercises`
- `POST /exercises`
- **Workout Sessions:**
- `GET /sessions`
- `POST /sessions/start`
- `POST /sessions/end`
- `POST /sessions/quit`
- `POST /sessions/active/log-set`
- `PUT /sessions/:id`
- `DELETE /sessions/:id`
- **Sporadic Sets:**
- `GET /sporadic-sets`
- `POST /sporadic-sets`
- `PUT /sporadic-sets/:id`
- `DELETE /sporadic-sets/:id`
- **Weight Logging:**
- `GET /weight`
- `POST /weight`
- **AI Service:**
- `POST /ai/chat`