This is a full-stack NBA Fantasy League application, designed to allow users to build and manage their fantasy basketball teams, compete in leagues, and track player performance.
- User Registration & Login: Secure user authentication.
- Profile Management: Users can update their nickname and change their password.
- Admin Panel: Administrative users can manage all registered users (delete, reset password) and trigger player data synchronization.
- Player Browsing: View a list of all available NBA players with their positions, teams, and average fantasy points.
- Search & Filter: Easily find players by name.
- My Team: Users can add and remove players from their fantasy team, with validation for position limits (e.g., max 4 Guards, 4 Forwards, 2 Centers, max 10 total players).
- Fantasy Points: Player statistics include last game fantasy points and average fantasy points.
- Create Leagues: Users can create their own private leagues.
- Join Leagues: Users can join existing leagues using a unique invite code.
- View Leagues: See a list of all leagues you are a member of. Admins can view all leagues in the system.
- League Details: View members of a specific league, including their nicknames/emails and total fantasy points.
- Delete Leagues: League owners or admins can delete leagues.
- Elegant NBA-Styled Dark Theme: A consistent and visually appealing dark theme across the application using Material-UI and Tailwind CSS.
- Global Notifications: Non-intrusive success/error messages via Material-UI Snackbar.
- Responsive Design: Optimized for various screen sizes (mobile, tablet, desktop).
Follow these steps to set up and run the NBA Fantasy App locally.
- Python 3.8+: For the FastAPI backend.
- Node.js (LTS recommended) & npm (or Yarn): For the React frontend.
The backend is built with FastAPI and uses SQLAlchemy for database interaction (SQLite by default).
-
Navigate to the backend directory:
cd backend -
Create and activate a Python virtual environment:
python3 -m venv venv source venv/bin/activate # On macOS/Linux # venv\Scripts\activate # On Windows (Command Prompt) # venv\Scripts\Activate.ps1 # On Windows (PowerShell)
-
Install backend dependencies:
pip install -r requirements.txt
-
Initialize the database:
- Important: If you've made significant schema changes (like adding new tables or columns), you should delete the old database file to ensure a clean setup.
- Delete existing database file (if any, this will erase all data):
rm data/nba_fantasy.db
- Create database tables:
python3 models.py
- Note: For production environments, consider using a proper migration tool like Alembic.
-
Run the backend server:
uvicorn main:app --reload
The backend API will be available at
http://localhost:8000.
The frontend is a React application built with TypeScript, Material-UI, and Tailwind CSS.
-
Open a new terminal window and navigate to the frontend directory:
cd frontend -
Install frontend dependencies:
npm install # or yarn install -
Run the frontend development server:
npm start # or yarn startThe frontend application will open in your browser at
http://localhost:3000.
- Access: Open your browser to
http://localhost:3000. - Register First User (Admin): The very first user to register will automatically be assigned the
adminrole. Use this account to access the Admin Panel. - Explore Features: Log in, build your team, create/join leagues, and check the leaderboard.