https://github.com/federicofanini/gymbrah.com
Build better tiny habits to get fit and healthy.
https://github.com/federicofanini/gymbrah.com
fitness health workout
Last synced: 7 months ago
JSON representation
Build better tiny habits to get fit and healthy.
- Host: GitHub
- URL: https://github.com/federicofanini/gymbrah.com
- Owner: federicofanini
- License: other
- Created: 2025-01-02T23:45:07.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-28T10:59:29.000Z (7 months ago)
- Last Synced: 2025-04-09T15:01:18.364Z (7 months ago)
- Topics: fitness, health, workout
- Language: TypeScript
- Homepage: https://gymbrah.com
- Size: 30.3 MB
- Stars: 82
- Watchers: 1
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# GymBrah
Build better tiny habits to get fit and healthy.
[💬 Discord](https://discord.gg/) [🚀 Join](https://www.gymbrah.com)
## Database Flow
This documentation outlines the database architecture and flow within the GymBrah application, focusing on the athlete onboarding process facilitated by the `athlete_code` system. The following diagram illustrates the interaction between key tables:
```mermaid
graph TD
business["business
- id (UUID)
- user_id (FK)
- name"]
athlete["athlete
- id (UUID)
- user_id (FK)
- athlete_code (U)
- invited_by (FK)
- email
- phone"]
user["user
- id (UUID)
- email (U)
- full_name
- avatar_url
- created_at"]
workout["workout
- id (UUID)
- name
- user_id (FK)
- athlete_id (FK)
- selected"]
waitlist["waitlist
- id (UUID)
- email (U)
- created_at"]
workout_athlete["workout_athlete
- id (UUID)
- workout_id (FK)
- athlete_id (FK)
- business_id (FK)"]
business -->|Registers Athlete| athlete
user --> athlete
user --> workout
athlete --> workout
workout --> workout_athlete
athlete --> workout_athlete
business --> workout_athlete
user --> waitlist
```
## 📌 How the Flow Works
1️⃣ **Gym Registers an Athlete**
- Creates a new athlete record with a unique `athlete_code`.
- Sends an invitation email/SMS containing the `athlete_code` for the athlete to join.
2️⃣ **Athlete Signs Up**
- If the athlete's email matches an existing invite, the user is automatically linked to the athlete record.
- If not, the athlete can manually enter the `athlete_code` to associate their account.
3️⃣ **Workout Assignment & Tracking**
- The `workout_athlete` table manages the association between workouts and athletes.
- Gyms can assign workouts to athletes even before the athletes have completed their signup process.
## 🔧 Useful Tips for Managing the App
### Database Schema Management
- **Prisma Migrate:** Use Prisma Migrate to handle schema changes smoothly. Run `npx prisma migrate dev` to apply migrations.
- **Client Generation:** After updating the schema, generate the Prisma client with `npx prisma generate` to ensure type safety and access to the latest models.
### Data Integrity
- **Relations:** Utilize Prisma's relational mappings to maintain referential integrity between tables.
- **Transactions:** Use transactions for bulk operations to ensure atomicity and consistency.
### Athlete Onboarding
- **Unique Codes:** Ensure `athlete_code` uniqueness by enforcing constraints in the Prisma schema.
- **Validation:** Implement front-end and back-end validation for `athlete_code` during the signup process to prevent errors.
### Performance Optimization
- **Indexing:** Index frequently queried fields such as `user_id`, `athlete_code`, and foreign keys to enhance query performance.
- **Lazy Loading:** Utilize Prisma's lazy loading features to fetch related records only when necessary, reducing initial load times.
### Security Best Practices
- **Authentication & Authorization:** Protect sensitive endpoints with robust authentication mechanisms and ensure proper authorization checks.
- **Input Sanitization:** Sanitize and validate all inputs, especially user-generated content and `athlete_code`, to prevent injection attacks.
### Monitoring & Maintenance
- **Database Backups:** Regularly back up your PostgreSQL database to prevent data loss. Consider automated backup solutions.
- **Performance Monitoring:** Use tools like PgAdmin or other PostgreSQL monitoring solutions to keep an eye on database performance and identify bottlenecks.
### Development Workflow
- **Version Control:** Keep your Prisma schema and migrations under version control to track changes and collaborate effectively.
- **Environment Management:** Use environment variables to manage different configurations for development, staging, and production environments.
By adhering to these guidelines, you can ensure a robust, secure, and maintainable database structure that supports the GymBrah application's growth and scalability.
```
```