Skip to content

DannyRivasDev/Fitmax-Smart-Gym

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

smart-gym-logo

Smart Gym

Coordinating and organizing operations for a gym to make life easier for staff and members.

An app that serves as a center for membership management, class scheduling, ordering from the cafe and analytics for membership growth and usage.

Technologies Used

Next.js logo React logo TypeScript logo Supabase logo Tailwind CSS logo Shadcn logo Stripe logo Figma logo Eleven Labs Vercel

Docs for this project

Team Contributors To The Project

Joe Aguado Profile Picture
Joe Aguado
Joe Gallego Profile Picture
Joe Gallego
Danny Rivas Profile Picture
Danny Rivas
Diego Espino Profile Picture
Diego Espino
Raja Krishna Profile Picture
Raja Krishna
(Tech Lead)
Belle Duran Profile Picture
Belle Duran
(Tech Lead)

πŸ’ͺ Smart Gym Documentation

πŸ“‘ Table of Contents


πŸ“Œ Introduction

Smart Gym is a modern operations hub for gyms and fitness studios. It streamlines daily workflows for staff and members, centralizing membership management, class scheduling and enrollment, cafe purchasing, messaging, and analytics. The app also includes an AI member assistant powered by Vercel AI SDK with Gemini, plus optional voice responses via ElevenLabs.


πŸ—οΈ Architecture Overview

The application is built with a modular Next.js (App Router) architecture. UI is rendered with React, shadcn/ui, and Tailwind CSS. Server-side functionality is implemented via Next.js Route Handlers under app/api, integrating with Supabase for data and auth, Stripe for payments, and AI services for chat and optional voice.

Component Description
Frontend Next.js 15 + React with shadcn/ui and Tailwind CSS; component-driven UI, client/server components as appropriate.
Backend API Next.js Route Handlers in app/api/* for REST-style endpoints; TypeScript-first; integrates Supabase, Stripe, and AI providers.
Database Supabase (PostgreSQL). Core tables include users, classes, enrollments, cafe products, messages, invoices, and check-ins.
Authentication Supabase Auth for user management and sessions.
AI Assistant Vercel AI SDK using Google Gemini models exposed via /api/gemini for member Q&A and guidance.
Voice AI ElevenLabs for text-to-speech responses in the client where voice is enabled.
Payments Stripe for cafe purchases and invoicing flows.

πŸ› οΈ Technology Stack

πŸ–₯️ Frontend

Technology Version/Description
Framework Next.js 15
UI Library shadcn/ui
AI Vercel AI SDK (Gemini)
Voice AI ElevenLabs
Icons Lucide, Radix Icons
Styling Tailwind CSS v4

βš™οΈ Backend

Technology Version/Description
API Framework Next.js API Routes
Database Client Supabase JS SDK
Database Supabase
Authentication Supabase Auth

🧰 Development Tools

Tool Purpose
TypeScript Type checking and static analysis
Prettier Code formatting and style consistency
ESLint Code linting and enforcing best practices
Husky Git hooks for pre-commit checks
Commitlint Enforces commit message conventions

πŸ’Ύ Database Schema

The application uses a PostgreSQL(Supabase) database. Below is the ERD (Entity Relationship Diagram) illustrating the key models and their relationships:

ERD Image


✨ Key Features

πŸ“… 1. Member class scheduling

  • Browse classes by date and category
  • View details (category, time, capacity, coach)
  • Enroll with confirmation modal flow

πŸ› οΈ 2. Admin class management

  • Create, update, cancel classes
  • View enrolled and waitlisted members
  • Sort and filter schedules by date/time

β˜• 3. Cafe catalog and orders

  • Create, update, delete cafe products
  • View top purchases analytics
  • Fetch product detail and full catalog

πŸ’¬ 4. Messaging

  • Create messages tied to a user ID
  • Fetch all messages or by message ID
  • Retrieve messages by user ID

πŸ€– 5. AI assistant (chatbot)

  • Member Q&A via /api/gemini
  • Class guidance, FAQs, and tips
  • Powered by Vercel AI SDK using Gemini models

πŸ”Š 6. Voice responses (optional)

  • ElevenLabs text-to-speech playback
  • Optional voice responses in client UI
  • Per-session/user toggling

πŸ“ˆ 7. Analytics dashboard

  • Membership growth and attendance charts
  • Revenue target progress tracking
  • Cafe insights (e.g., top purchases)

🧾 8. Invoices and purchases

  • Create invoices and add purchases
  • Update invoice totals on purchase
  • Retrieve invoices by user

πŸ”Œ API Details

The application uses Next.js API Routes organized by feature:

API Overview

API Endpoint Purpose
/api/cafe/create create a cafe item
/api/cafe/delete delete a cafe item
/api/cafe/edit edit a cafe item
/api/cafe/getAll get all cafe items
/api/cafe/[productId] get a single cafe item
/api/cafe/items/topPurchases get top 5 cafe purchases
/api/classes/[classId] get a single class
/api/classes/create creates class
/api/classes/delete deletes class
/api/classes/enrolled/[classId] get all members enrolled in a class
/api/classes/getAll get classes
/api/classes/update updates class
/api/classes/memberdash get daily classes
/api/classes/waitlisted/[classId] get all members waitlisted in a class
/api/coaches/getAll get all coaches
/api/gemini/ member AI assistant
/api/gemini/aiCheckin checks to see last ai checkin time
/api/gemini/mood checksi or updates user mood
/api/messages/create creates msg associated w user ID
/api/messages/delete deletes msg associated w msg ID
/api/messages/getAll get all msgs
/api/messages/getByMessageId gets msg by msg ID
/api/messages/getByUserId gets msgs by user ID
/api/users/[userId] gets user by user ID
/api/users/create creates user
/api/users/getAll get all users
/api/users/update updates user
/api/users/enrolled/[userId]. gets user classes or cancel
/api/checkins gets all checkins by user ID
/api/invoices/add adds invoice to user_invoice table
/api/invoices/[userId] gets all invoices by user ID
/api/invoices/purchase + invoice, updates total, supports +1
/api/profile/[userId] gets all profile data by user ID
/api/adminMemberProfile/[userId] gets profile data by user ID admin

API Endpoints

  • API Endpoint: /api/[endpoint1]

  • Purpose: [Purpose description]

  • Triggered by: [Triggered by description]

  • Steps:

    • [Step 1]
    • [Step 2]
    • [Step 3]
    • [Step 4]
  • API Endpoint: /api/classes/memberdash

  • Purpose: Get Gym classes by date and categories

  • Triggered by: Gym Member

  • Steps:

    • Gym Member logs in
    • System fetches all gym classes to display or mock fallback
  • API Endpoint: /api/messages/getAll

  • Purpose: Get all messages

  • Triggered by: Admin user

  • Steps:

    • Admin user logs in
    • Admin user navigates to messages page
    • System fetches all messages from database
  • API Endpoint: /api/messages/getById

  • Purpose: Get messages relating to a specific user by user ID

  • Triggered by: Admin user

  • Steps:

    • Admin user selects a specific message
    • System queries database for messages associated with user ID
    • User-specific messages are returned and displayed in the admin UI
  • API Endpoint: /api/messages/create

  • Purpose: Create message associated with user ID

  • Triggered by: Admin user

  • Steps:

    • Admin user logs in
    • Admin user navigates to messages page
    • Admin user hits create new message button
    • Admin user fills out the form
    • System creates message record in database
    • Message is associated with specified user ID
  • API Endpoint: /api/cafe/getAll

  • Purpose: Get all cafe items

  • Triggered by: User/Admin

  • Steps:

    • User/Admin accesses cafe page
    • System fetches all product records from database
    • Cafe items are displayed with prices and availability + other data (e.g. description, image, etc.)
  • API Endpoint: /api/cafe/[productId]

  • Purpose: Get a single cafe item

  • Triggered by: User/Admin

  • Steps:

    • User/Admin selects specific product
    • System queries database using product ID
    • Individual product details are returned and displayed
  • API Endpoint: /api/cafe/create

  • Purpose: Create a cafe item

  • Triggered by: Admin user

  • Steps:

    • Admin user logs in
    • Admin user navigates to cafe page
    • Admin user navigates to product creation form
    • Admin user fills in product details and pricing + other data (e.g. description, image, etc.)
    • Admin user hits create new product button
    • System validates and saves new product to database
    • Product becomes available for purchase in the cafe
  • API Endpoint: /api/cafe/update

  • Purpose: Update a cafe item

  • Triggered by: Admin user

  • Steps:

    • Admin user logs in
    • Admin user navigates to cafe page
    • Admin user selects product to modify
    • Admin user updates product information
    • System validates changes and updates database record
    • Updated product information is reflected in cafe
  • API Endpoint: /api/cafe/delete

  • Purpose: Delete a cafe item

  • Triggered by: Admin user

  • Steps:

    • Admin user logs in
    • Admin user navigates to cafe page
    • Admin user selects product to remove
    • System confirms deletion request
    • Product record is removed from database
    • Product is no longer available for purchase
  • API Endpoint: /api/cafe/items/topPurchases

  • Purpose: Get top 5 cafe purchases

  • Triggered by: Admin user

  • Steps:

    • Admin user logs in
    • Admin user navigates to dashboard page
    • System fetches top 5 cafe purchases from database
    • Top 5 cafe purchases are displayed in the dashboard
  • API Endpoint: /api/gemini/

  • Purpose: Member AI assistant

  • Triggered by: Member

  • Steps:

    • Member logs in
    • Member clicks on the AI assistant button in the navbar
    • Modal opens with AI assistant
    • Member interacts with AI assistant

🧩 Component Structure

The application uses a component-based architecture with the following key components:

πŸ“ Layout Components

  • Admin Sidebar: Sidebar for the admin dashboard with links to the different pages
  • Pre Auth Navbar: Navbar for the pre-auth landing page with links to different spots on the landing page and a login button
  • Post Auth Navbar: Navbar for the post-auth dashboard with links to the user's barcode, profile, and notification.
  • Mobile Bottom Navbar: Bottom navbar for the mobile app with links to the user's barcode, profile, and notification.

πŸ“„ Page Components

  • [Component]: [Description]
  • Admin Dashboard Page: Page for the admin to view the dashboard with top 5 cafe purchases and other metrics
  • Admin Messages Page: Page for the admin to view all messages from the users + initiate a new message to the user
  • Admin View Message Page: Page for the admin to view a specific message and its details
  • Admin View Class Page: Page for the admin to view a specific class and its details
  • Admin View Analytics Page: Page for the admin to view the analytics of the gym
  • Admin View Member Page: Page for the admin to view a specific member and their information
  • Admin Members Page: Page for the admin to view all members and their information + sign up new members
  • Admin View Member Page: Page for the admin to view a specific member and their information
  • Admin Cafe Page: Page for the admin to view all products in the cafe + add new products + view all transactions

βš™οΈ Feature Components

  • Send Admin Message Modal: Modal for the admin to send a message to a user
  • Update Cafe Product Modal: Modal for the admin to update a product in the cafe
  • Create Cafe Product Modal: Modal for the admin to create a new product in the cafe
  • Admin Class Calendar: Calendar for the admin to view all classes and their details
  • Admin Class Card: Card for the admin to view a specific class and its details and holds cancel and view enrolled members buttons
  • Create Class Modal: Modal for the admin to create a new class
  • Update Class Modal: Modal for the admin to update a class
  • Cancel and Update Class Modal: Modal for the admin to cancel a class or update a class

🎨 UI Components

  • ActiveGymHours: pie chart with darkest/most active hour slices popping out
  • AnalyticsStatCard: generic card component for statistics at top of admin analytics page
  • TargetRevenueCard: shows progress to goal revenue
  • MembershipGrowthCard: bar graph showing growth or decline in gym memberships
  • ClassAttendanceCard: horizontal bar chart showing how many users attending each class
  • [Component]: [Description]

πŸš€ Deployment

The application is designed to be deployed using Vercel and Supabase:

Component Deployment Solution
Frontend and API Vercel
Database Supabase (PostgreSQL)
Authentication Supabase Auth
File Storage Supabase Storage
Environment Variables Vercel Environment Manager

πŸ“ Commitlint Configuration

This project uses commitlint to enforce consistent commit message conventions. The configuration extends the conventional commit standards with custom rules.

Configuration File

The commitlint configuration is defined in .commitlintrc.json:

{
  "extends": ["@commitlint/config-conventional"],
  "rules": {
    "type-enum": [2, "always", ["feat", "fix", "chore", "docs", "style", "refactor", "revert", "build", "ci"]],
    "header-max-length": [2, "always", 120],
    "body-max-line-length": [2, "always", 200],
    "footer-max-line-length": [2, "always", 200],
    "subject-case": [0, "never", "sentence-case"]
  }
}

Allowed Commit Types

Type Description
feat New feature
fix Bug fix
chore Changes to build process or auxiliary tools
docs Documentation only changes
style Changes that do not affect the meaning of code
refactor A code change that neither fixes a bug nor adds a feature
revert Reverts a previous commit
build Changes that affect the build system or external dependencies
ci Changes to CI configuration files and scripts

Example Commit Messages

feat: add user authentication system (PROJ-123)
fix: resolve navigation menu display issue (PROJ-456)
docs: update API documentation (PROJ-789)
chore: update dependencies to latest versions (PROJ-101)
style: format code according to prettier rules (PROJ-202)
refactor: simplify user profile component (PROJ-303)

πŸ’» Jira/Git Workflow

Choose a Jira ticket

  • In Jira, find a ticket to work on.
  • Assign it to yourself and mark it as 'In Progress'.

Create a branch from JIRA

  • Use the JIRA interface to create a branch directly from the ticket. This will generate a branch name based on the ticket number and description.
  • Follow the prompts to select the repository and branch source (usually master).
  • Once the branch is created, copy the branch name.

Local work

  • Fetch the branch you created in Jira from the remote repository:

    git fetch origin [BRANCH-NAME]
  • Check out the new branch:

    git checkout -b [BRANCH-NAME] origin/[BRANCH-NAME]
  • Make your changes and then stage them. All commit messages must follow the project commitlint rules (see Commitlint Configuration section above):

    • Start with one of the allowed commit types: feat, fix, chore, docs, style, refactor, revert, build or ci
    • Keep the header under 120 characters
    • The Jira ticket number should be at the end in parentheses

    Example commit commands:

    git commit -m "feat: add new button to dashboard (PROJ-123)"
    git commit -m "fix: resolve user fetch bug (PROJ-123)"
    git commit -m "chore: update dependencies (PROJ-123)"

Push to GitHub and make a pull request

  • Sync the remote repo with your local repo and your new branch:

    git push origin [TICKET-NUMBER]
  • Under [GITHUB_REPO_URL/branches] you should find the branch you just pushed. Click on it.

  • Click "Compare & pull request".

  • Make sure base is set to master at the top.

  • Adjust the title as needed and add a description.

  • Add reviewers (2) by clicking the gear.

  • Click "Create pull request".

  • Once the PR is approved, the assignee (you) should complete the pull request by merging to master and delete the branch.

  • Go back to Jira and change ticket status to done.

🎨 Design System

In order to use the in-line color schema within any front-end component, under className, use one of the following color configuration names:

  • primary-[color]
  • secondary-[color]
  • accent-[color]
  • neutral-[color]
  • [additional-color-names]

These can be applied to background colors, text colors and border colors using [CSS framework]'s utility classes.

Example Usage

Background Color

<div className='bg-primary-[color] p-4'>This div has a primary [color] background.</div>

πŸ“ Code Organization & Best Practices

Directory / File Description
app/ Main application directory containing pages, API routes and entry points.
app/api/ API route handlers (e.g., REST endpoints for client-server comms).
components/ Reusable React components and UI building blocks.
constants/ Constants.
constants/labels.ts All hardcoded strings, labels and configuration values.
constants/icons.ts Icon imports and icon component references.
context/ React createContext, useContext hooks.
hooks/ Custom React hooks.
types/ TypeScript type definitions and interfaces.
types/shared.ts Shared types/interfaces used across client and server.
utils/ Utility functions.
public/ Static assets (images, fonts, etc.) served directly by the app.
README.md Project documentation and guidelines.

Tip: Keep files and directories focused and organized according to their purpose for maintainability.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.7%
  • CSS 1.2%
  • JavaScript 0.1%