Skip to content

serger777/sportbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SportBase

Full-stack fitness tracking platform built with modern web technologies and Feature-Sliced Design architecture

πŸ“‹ Table of Contents

🎯 Overview

SportBase is a comprehensive fitness tracking application that allows users to:

  • Track and analyze their athletic activities
  • Monitor progress with detailed statistics and charts
  • Manage user profiles and settings
  • Admin panel for system management
  • OAuth integration with Google
  • Real-time application status monitoring

πŸ— Architecture

The project follows Feature-Sliced Design (FSD) methodology for scalable and maintainable code organization.

FSD Layers

src/
β”œβ”€β”€ app/                 # Application initialization & providers
β”œβ”€β”€ app-pages/          # Page components (business logic)
β”œβ”€β”€ widgets/            # Composite UI blocks
β”œβ”€β”€ features/           # User interactions & business features
β”œβ”€β”€ entities/           # Business entities
└── shared/             # Reusable resources

Key Principles

  • Named exports throughout the codebase (no default exports)
  • Path aliases for clean imports (@/shared, @/features, etc.)
  • Separation of concerns with clear layer boundaries
  • Type safety with TypeScript
  • State management with Zustand stores

πŸ›  Technology Stack

Frontend (sportbase-client)

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • UI Library: React 18
  • Styling: Tailwind CSS
  • State Management: Zustand
  • Data Fetching: Apollo Client (GraphQL)
  • Forms: React Hook Form + Yup validation
  • Date/Time: Moment.js
  • Code Quality: ESLint, Prettier, Husky
  • UI Components: Flowbite-inspired design system

Backend (sportbase-server)

  • Framework: NestJS
  • Language: TypeScript
  • API: REST + GraphQL
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT + Google OAuth 2.0
  • Password Hashing: BcryptJS
  • Utilities: Lodash
  • Deployment: Kubernetes + AWS
  • Code Quality: Husky pre-commit hooks

πŸ“ Project Structure

sportbase/
β”œβ”€β”€ sportbase-client/          # Frontend application
β”‚   β”œβ”€β”€ app/                   # Next.js App Router pages
β”‚   β”‚   β”œβ”€β”€ (guest)/          # Guest routes (landing, login)
β”‚   β”‚   β”œβ”€β”€ admin/            # Admin panel routes
β”‚   β”‚   β”œβ”€β”€ auth/             # Authentication routes
β”‚   β”‚   β”œβ”€β”€ activity/         # Activity tracking
β”‚   β”‚   β”œβ”€β”€ home/             # User dashboard
β”‚   β”‚   β”œβ”€β”€ profile/          # User profile
β”‚   β”‚   β”œβ”€β”€ progress/         # Progress analytics
β”‚   β”‚   β”œβ”€β”€ settings/         # User settings
β”‚   β”‚   └── user/             # User management
β”‚   β”‚
β”‚   β”œβ”€β”€ src/                   # FSD structure
β”‚   β”‚   β”œβ”€β”€ app/              # App layer
β”‚   β”‚   β”‚   β”œβ”€β”€ providers/    # React providers (Apollo, Auth)
β”‚   β”‚   β”‚   └── styles/       # Global styles
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ app-pages/        # Pages layer
β”‚   β”‚   β”‚   β”œβ”€β”€ activity/     # Activity page logic
β”‚   β”‚   β”‚   β”œβ”€β”€ admin-apps/   # Admin apps management
β”‚   β”‚   β”‚   β”œβ”€β”€ admin-users/  # Admin users management
β”‚   β”‚   β”‚   β”œβ”€β”€ admin-app-issues/  # Admin issues
β”‚   β”‚   β”‚   β”œβ”€β”€ app-home/     # Home page logic
β”‚   β”‚   β”‚   β”œβ”€β”€ landing/      # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ profile/      # Profile page
β”‚   β”‚   β”‚   β”œβ”€β”€ progress/     # Progress analytics
β”‚   β”‚   β”‚   └── user/         # User page
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ widgets/          # Widgets layer
β”‚   β”‚   β”‚   β”œβ”€β”€ latest-monthly-activity/  # Activity widget
β”‚   β”‚   β”‚   β”œβ”€β”€ layout-header/            # Header component
β”‚   β”‚   β”‚   └── user-menu/                # User dropdown menu
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ features/         # Features layer
β”‚   β”‚   β”‚   β”œβ”€β”€ admin-apps/              # Admin apps management
β”‚   β”‚   β”‚   β”œβ”€β”€ admin-users/             # Admin users management
β”‚   β”‚   β”‚   β”œβ”€β”€ admin-app-issues/        # Admin issues management
β”‚   β”‚   β”‚   β”œβ”€β”€ app-issues/              # User app issues
β”‚   β”‚   β”‚   β”œβ”€β”€ app-management/          # App CRUD operations
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                    # Authentication
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ login/               # Login feature
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ register/            # Registration
β”‚   β”‚   β”‚   β”‚   └── permission/          # Access control
β”‚   β”‚   β”‚   └── user-profile/            # Profile management
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ entities/         # Entities layer
β”‚   β”‚   β”‚   β”œβ”€β”€ activity/     # Activity entity
β”‚   β”‚   β”‚   β”œβ”€β”€ app/          # Application entity
β”‚   β”‚   β”‚   └── user/         # User entity
β”‚   β”‚   β”‚
β”‚   β”‚   └── shared/           # Shared layer
β”‚   β”‚       β”œβ”€β”€ ui/           # UI components
β”‚   β”‚       β”‚   β”œβ”€β”€ Badge/
β”‚   β”‚       β”‚   β”œβ”€β”€ Button/
β”‚   β”‚       β”‚   β”œβ”€β”€ Dropdown/
β”‚   β”‚       β”‚   β”œβ”€β”€ Heading/
β”‚   β”‚       β”‚   β”œβ”€β”€ Input/
β”‚   β”‚       β”‚   β”œβ”€β”€ Message/     # Toast notifications
β”‚   β”‚       β”‚   β”œβ”€β”€ Sidepanel/   # Side panels
β”‚   β”‚       β”‚   └── Spinner/
β”‚   β”‚       β”œβ”€β”€ lib/          # Utilities & helpers
β”‚   β”‚       β”‚   β”œβ”€β”€ apollo/       # GraphQL client
β”‚   β”‚       β”‚   β”œβ”€β”€ hooks/        # Custom hooks
β”‚   β”‚       β”‚   β”œβ”€β”€ message/      # Message system
β”‚   β”‚       β”‚   β”œβ”€β”€ sidepanel/    # Sidepanel system
β”‚   β”‚       β”‚   └── utils/        # Helper functions
β”‚   β”‚       └── types/        # Shared TypeScript types
β”‚   β”‚
β”‚   β”œβ”€β”€ public/               # Static assets
β”‚   β”œβ”€β”€ .env                  # Environment variables
β”‚   β”œβ”€β”€ tsconfig.json         # TypeScript config with path aliases
β”‚   β”œβ”€β”€ tailwind.config.ts    # Tailwind configuration
β”‚   └── package.json
β”‚
└── sportbase-server/         # Backend application
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ modules/          # Feature modules
    β”‚   β”œβ”€β”€ common/           # Shared utilities
    β”‚   └── main.ts           # Application entry
    β”œβ”€β”€ .env                  # Environment variables
    └── package.json

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Docker (for MongoDB)
  • MongoDB Compass (recommended)

Installation

  1. Clone the repository
git clone <repository-url>
cd sportbase
  1. Setup Database
# Pull MongoDB Docker image
docker pull mongo

# Run MongoDB container
docker run -d --name mongodb \
  -p 27017:27017 \
  -e MONGO_INITDB_ROOT_USERNAME=root \
  -e MONGO_INITDB_ROOT_PASSWORD=root \
  mongo:latest
  1. Setup Backend
cd sportbase-server
npm install

# Create .env file
cat > .env << EOF
MONGO_CONNECTION_STRING=mongodb://root:root@localhost:27017/sportbase?authSource=admin
JWT_SECRET=your-jwt-secret-key
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-google-client-secret
CLIENT_ORIGIN=http://localhost:3500
GOOGLE_CALLBACK_URL=http://localhost:2500/auth/google/redirect
EOF

# Start server (port 2500)
npm run start:dev
  1. Setup Frontend
cd ../sportbase-client
npm install

# Create .env file
cat > .env << EOF
NEXT_PUBLIC_SERVER_ORIGIN=http://localhost:2500
NEXT_PUBLIC_CLIENT_ORIGIN=http://localhost:3500
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
CLIENT_ORIGIN=http://localhost:3500
EOF

# Start development server (port 3500)
npm run dev
  1. Access the application

πŸ’» Development

Frontend Commands

# Development server
npm run dev

# Production build
npm run build

# Start production server
npm start

# Code formatting
npm run format

# Linting
npm run lint

# Type checking
npm run typecheck

Code Quality

The project uses:

  • Husky for pre-commit hooks
  • Prettier for code formatting
  • ESLint for linting (includes Tailwind CSS plugin)
  • TypeScript for type checking

All commits are automatically checked for:

  • Code formatting
  • Linting errors
  • Type errors

Path Aliases

import { Button } from '@/shared/ui/Button';
import { useAuthStore } from '@/features/auth';
import { ActivityCard } from '@/entities/activity';
import { Header } from '@/widgets/layout-header';
import { ActivityPage } from '@/app-pages/activity';

πŸ” Environment Variables

Frontend (.env)

NEXT_PUBLIC_SERVER_ORIGIN=http://localhost:2500
NEXT_PUBLIC_CLIENT_ORIGIN=http://localhost:3500
NEXT_PUBLIC_GOOGLE_CLIENT_ID=<your-client-id>.apps.googleusercontent.com
CLIENT_ORIGIN=http://localhost:3500

Backend (.env)

MONGO_CONNECTION_STRING=mongodb://root:root@localhost:27017/sportbase?authSource=admin
JWT_SECRET=your-jwt-secret-key
GOOGLE_CLIENT_ID=<your-client-id>.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=<your-client-secret>
CLIENT_ORIGIN=http://localhost:3500
GOOGLE_CALLBACK_URL=http://localhost:2500/auth/google/redirect

✨ Features

User Features

  • Authentication: Email/password and Google OAuth
  • Activity Tracking: Log and manage fitness activities
  • Progress Analytics: Visualize progress with charts and statistics
  • Profile Management: Update user information and settings
  • Application Management: Create and manage personal applications

Admin Features

  • User Management: View and edit user roles
  • Application Monitoring: Monitor all applications and their status
  • Issue Tracking: View and manage user-reported issues
  • Real-time Updates: SSE-based status updates

Technical Features

  • Responsive Design: Mobile-first approach with Tailwind CSS
  • Type Safety: Full TypeScript coverage
  • State Management: Zustand stores with immutable updates
  • Real-time Updates: Server-Sent Events (SSE)
  • Form Validation: React Hook Form + Yup schemas
  • GraphQL Integration: Apollo Client for efficient data fetching
  • Permission System: Role-based access control
  • Toast Notifications: User feedback system
  • Side Panels: Dynamic UI panels for forms

🎨 Design System

The application uses a custom design system based on Tailwind CSS with:

  • Color Palette: Primary (blue), Secondary (gray), Success (green), Error (red)
  • Typography: System font stack with responsive sizing
  • Components: Buttons, Badges, Inputs, Dropdowns, Spinners, etc.
  • Layouts: Container, Grid, Flex utilities
  • Responsive: Mobile-first breakpoints (sm, md, lg, xl, 2xl)

πŸ§ͺ Testing

# Frontend
npm run typecheck  # TypeScript validation

# Backend
npm run test       # Unit tests
npm run test:e2e   # E2E tests

πŸ“¦ Building for Production

Frontend

npm run build
npm start

Backend

npm run build
npm run start:prod

🀝 Contributing

  1. Follow the FSD architecture principles
  2. Use named exports (no default exports)
  3. Write type-safe TypeScript code
  4. Follow the existing code style (enforced by Prettier/ESLint)
  5. Update documentation for new features
  6. Test your changes before committing

Commit Convention

feat: add new feature
fix: bug fix
refactor: code refactoring
docs: documentation updates
style: formatting changes
test: add tests
chore: maintenance tasks

πŸ“ License

[Add your license here]

πŸ‘₯ Team

[Add team information here]

πŸ”— Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages