Track your favorite NBA players with style
- Overview
- Features
- Design
- Quick Start
- Installation Guide
- Deployment Workflow
- Authentication System
- Database Schema
- API Routes
- Technologies
- Troubleshooting
- Security
NBA POCKET is a full-stack web application that allows basketball fans to search for NBA players, save their favorites, and add personal notes. Built with a premium black/white/silver/gold design theme featuring smooth animations and a dynamic basketball court background.
Live Site: https://nba-pocket.onrender.com
- π Search for any NBA player by name
- β Favorite players to track them
- π Add notes and comments about your favorite players
- π¨ Enjoy a premium, animated user interface
- π Secure authentication with encrypted passwords
- Signup with username, email, and password
- Login with username and password
- Secure session management with encrypted cookies
- Password hashing with bcrypt
- Premium styled forms with animations
- Modern landing page with hero section
- Navigation bar with Login/Sign Up buttons
- Animated basketball court background
- Floating gold particles effect
- Responsive design for all devices
- Player search functionality
- Real-time search results
- Add players to favorites
- Sidebar navigation
- Welcome message with username
- View all favorited players
- Player cards with team information
- Remove players from favorites
- Comments section for each player
- Add, edit, and delete notes
- PostgreSQL database integration
- BallDontLie NBA API for player data
- Proper table relationships
- Error handling
Premium Black/White/Silver/Gold Theme
| Color | Hex Code | Usage |
|---|---|---|
| Black | #0a0a0a, #1a1a1a |
Primary background |
| Gold | #FFD700, #FFA500 |
Accent colors, buttons |
| Silver | #C0C0C0 |
Secondary text, borders |
| White | #ffffff |
Primary text |
- β¨ Animated basketball court background with zoom effect
- π Floating gold particles
- π Smooth page transitions
- π« Micro-animations on hover
- πΌοΈ Modern glassmorphism effects
- π± Fully responsive design
Before you begin, ensure you have:
- Node.js (v14 or higher)
- PostgreSQL (v12 or higher)
- Git
- A code editor (VS Code recommended)
# 1. Clone the repository
git clone https://github.com/ikarabag1/NBA-POCKET.git
cd NBA-POCKET
# 2. Install dependencies
npm install
# 3. Create database
createdb nba_pocket
# 4. Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# 5. Run migrations
npx sequelize-cli db:migrate
# 6. Start the application
node server.jsVisit http://localhost:8000 in your browser!
git clone https://github.com/ikarabag1/NBA-POCKET.git
cd NBA-POCKETnpm installThis installs all required packages:
- Express.js (web framework)
- Sequelize (ORM)
- bcrypt (password hashing)
- EJS (templating)
- And more...
# Create the database
createdb nba_pocket-- Open psql
psql postgres
-- Create database
CREATE DATABASE nba_pocket;
-- Exit psql
\qnpx sequelize-cli db:migrateThis creates all necessary tables:
- users
- players
- user_players (join table)
- comments
Create a .env file in the root directory:
# Database Configuration
DATABASE_URL=postgres://username:password@localhost:5432/nba_pocket
# Session Secret (use a strong random string)
SECRET=your_secret_key_here_make_it_long_and_random
# NBA API Key (get from https://app.balldontlie.io/signup)
BALLDONTLIE_API_KEY=your_api_key_here
# Server Port
PORT=8000
# Environment
NODE_ENV=development- Visit BALLDONTLIE API
- Create a free account
- Copy your API key
- Add it to your
.envfile
Free Tier Limits: 5 requests per minute
# Development mode
node server.js
# Or with nodemon (auto-restart on changes)
npm install -g nodemon
nodemon server.jsThe app will be running at http://localhost:8000
This project uses a two-branch strategy for controlled deployments:
| Branch | Purpose | Deploys To |
|---|---|---|
| main | Development & testing | Not deployed |
| deploy | Production-ready code | Render (live site) |
main branch (development)
β
merge when ready
β
deploy branch (production)
β
auto-deploy to Render
β
Live Site π
# Ensure you're on main
git checkout main
# Make your changes
# ... edit files ...
# Commit changes
git add .
git commit -m "Add new feature"
# Push to GitHub
git push origin mainWhen your changes are tested and ready:
# Switch to deploy branch
git checkout deploy
# Merge all new commits from main
git merge main
# Push to GitHub (triggers Render deployment)
git push origin deploy
# Switch back to main for continued development
git checkout maingit checkout deploy && git merge main && git push origin deploy && git checkout mainOne-time setup:
- Go to Render Dashboard
- Select your NBA-POCKET service
- Navigate to Settings β Build & Deploy
- Change Branch from
maintodeploy - Click Save Changes
Now Render will only deploy when you push to the deploy branch!
If a deployment causes issues:
# Switch to deploy branch
git checkout deploy
# View commit history
git log --oneline
# Reset to last working commit
git reset --hard <COMMIT_HASH>
# Force push to trigger redeployment
git push --force origin deploy
# Switch back to main
git checkout mainβ
Control - Deploy only when ready
β
Safety - Test on main before deploying
β
Rollback - Easy to revert if needed
β
Clarity - Clear dev/prod separation
1. User visits /users/new
β
2. Fills form: Username, Email, Password
β
3. System checks if username is unique
β
4. Password is hashed with bcrypt (10 rounds)
β
5. User record created in database
β
6. Session cookie set (encrypted with AES)
β
7. Redirect to /users/profile
1. User visits /users/login
β
2. Enters: Username, Password
β
3. System finds user by username
β
4. Password verified with bcrypt.compare()
β
5. If valid: Session cookie set
β
6. Redirect to /users/profile
1. User clicks Logout button
β
2. Session cookie cleared
β
3. Redirect to home page
- π Password Hashing - bcrypt with 10 salt rounds
- π Session Encryption - AES encryption for user IDs
- πͺ HTTP-only Cookies - Prevents XSS attacks
- β Input Validation - Required fields checked
- π‘οΈ SQL Injection Prevention - Sequelize ORM parameterization
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββ
β Users β β User_Players β β Players β
βββββββββββββββ€ β (Join Table) β βββββββββββββββ€
β id (PK) βββββββββ<β userId (FK) β>βββββββββ id (PK) β
β username β β playerId (FK) β β name β
β email β β createdAt β β team β
β password β β updatedAt β β position β
β createdAt β ββββββββββββββββββββ β api_id β
β updatedAt β β createdAt β
βββββββββββββββ β updatedAt β
β βββββββββββββββ
β β
β ββββββββββββββββββββ β
β β Comments β β
β ββββββββββββββββββββ€ β
βββββββββ<β userId (FK) β β
β playerId (FK) β>ββββββββββββββββββββββ
β content β
β createdAt β
β updatedAt β
ββββββββββββββββββββ
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | INTEGER | PRIMARY KEY, AUTO INCREMENT | Unique user ID |
| username | VARCHAR(255) | UNIQUE, NOT NULL | Login username |
| VARCHAR(255) | NOT NULL | User email | |
| password | VARCHAR(255) | NOT NULL | Hashed password |
| createdAt | TIMESTAMP | NOT NULL | Account creation date |
| updatedAt | TIMESTAMP | NOT NULL | Last update date |
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | INTEGER | PRIMARY KEY, AUTO INCREMENT | Unique player ID |
| name | VARCHAR(255) | NOT NULL | Player full name |
| team | VARCHAR(255) | Team name | |
| position | VARCHAR(50) | Player position | |
| api_id | INTEGER | UNIQUE | BallDontLie API ID |
| createdAt | TIMESTAMP | NOT NULL | Record creation date |
| updatedAt | TIMESTAMP | NOT NULL | Last update date |
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | INTEGER | PRIMARY KEY, AUTO INCREMENT | Unique record ID |
| userId | INTEGER | FOREIGN KEY β users.id | User reference |
| playerId | INTEGER | FOREIGN KEY β players.id | Player reference |
| createdAt | TIMESTAMP | NOT NULL | Favorite added date |
| updatedAt | TIMESTAMP | NOT NULL | Last update date |
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | INTEGER | PRIMARY KEY, AUTO INCREMENT | Unique comment ID |
| userId | INTEGER | FOREIGN KEY β users.id | User who wrote comment |
| playerId | INTEGER | FOREIGN KEY β players.id | Player being commented on |
| content | TEXT | NOT NULL | Comment text |
| createdAt | TIMESTAMP | NOT NULL | Comment creation date |
| updatedAt | TIMESTAMP | NOT NULL | Last edit date |
| Method | Path | Purpose | Auth Required |
|---|---|---|---|
| GET | /users/new |
Signup form | No |
| POST | /users |
Create new user | No |
| GET | /users/login |
Login form | No |
| POST | /users/login |
Authenticate user | No |
| GET | /users/logout |
Logout user | Yes |
| GET | /users/profile |
User dashboard | Yes |
| PUT | /users/profile |
Update password | Yes |
| Method | Path | Purpose | Auth Required |
|---|---|---|---|
| GET | /players/search |
Search form | Yes |
| POST | /players/search |
Search API | Yes |
| GET | /players/results |
Display results | Yes |
| POST | /players/favorites |
Add to favorites | Yes |
| GET | /players/favorites |
View favorites | Yes |
| DELETE | /players/favorites/:id |
Remove favorite | Yes |
| Method | Path | Purpose | Auth Required |
|---|---|---|---|
| POST | /comments/favorites |
Add comment | Yes |
| PUT | /comments/favorites/:id |
Edit comment | Yes |
| DELETE | /comments/favorites/:id |
Delete comment | Yes |
| Technology | Version | Purpose |
|---|---|---|
| Node.js | 14+ | JavaScript runtime |
| Express.js | 4.x | Web framework |
| PostgreSQL | 12+ | Database |
| Sequelize | 6.x | ORM |
| bcrypt | 5.x | Password hashing |
| crypto-js | 4.x | Session encryption |
| axios | 1.x | HTTP client |
| cookie-parser | 1.x | Cookie handling |
| Technology | Purpose |
|---|---|
| EJS | Templating engine |
| CSS3 | Styling & animations |
| JavaScript | Client-side interactivity |
| API | Purpose | Limits |
|---|---|---|
| BallDontLie API | NBA player data | 5 req/min (free) |
| Platform | Service |
|---|---|
| Render | Web hosting + PostgreSQL |
| GitHub | Version control |
Error: ECONNREFUSED or database does not exist
Solutions:
# Check if PostgreSQL is running
pg_isready
# If not running, start it
# macOS:
brew services start postgresql
# Linux:
sudo service postgresql start
# Windows:
# Start PostgreSQL service from Services app
# Verify database exists
psql -l | grep nba_pocket
# If not exists, create it
createdb nba_pocketError: SequelizeDatabaseError during migration
Solutions:
# Reset all migrations
npx sequelize-cli db:migrate:undo:all
# Run migrations again
npx sequelize-cli db:migrate
# If still failing, check config/config.json
# Ensure database credentials are correctError: 429 Too Many Requests
Solution:
- Free tier limit: 5 requests/minute
- Wait 60 seconds before trying again
- Consider upgrading API plan for higher limits
Error: EADDRINUSE: address already in use :::8000
Solutions:
# Find process using port 8000
# macOS/Linux:
lsof -i :8000
# Kill the process
kill -9 <PID>
# Or use a different port in .env
PORT=3000Problem: Can't log in or session expires immediately
Solutions:
- Check
.envfile hasSECRETset - Clear browser cookies
- Verify database has user record:
psql nba_pocket SELECT * FROM users;
Problem: Site shows 502 Bad Gateway
Solutions:
- Check Render logs for errors
- Verify environment variables are set
- Ensure
DATABASE_URLis correct - Check if migrations ran successfully
- Verify build command completed
Problem: Site is slow to load
Solution:
- Free tier spins down after 15 minutes
- First request takes 30-60 seconds to wake up
- Use UptimeRobot to ping every 14 minutes
β
Never commit .env files - Already in .gitignore
β
Use strong passwords - Minimum 6 characters enforced
β
Hash passwords - bcrypt with 10 salt rounds
β
Encrypt sessions - AES encryption for cookies
β
Validate input - Required fields checked server-side
β
Prevent SQL injection - Sequelize parameterized queries
β
HTTPS in production - Render provides SSL certificates
Before deploying:
- All API keys in environment variables
-
.envfile not committed to Git - Strong
SECRETvalue set (32+ characters) - Database uses strong password
- HTTPS enabled (automatic on Render)
- Input validation on all forms
- Error messages don't expose sensitive info
If you discover a security vulnerability:
- DO NOT open a public GitHub issue
- Email the repository owner directly
- Include detailed description and steps to reproduce
- Allow 48 hours for initial response
ISC License - See LICENSE file for details
ikarabag1
- GitHub: @ikarabag1
- Repository: NBA-POCKET
Contributions are welcome! Here's how:
# Fork the repo on GitHub, then:
git clone https://github.com/YOUR_USERNAME/NBA-POCKET.git
cd NBA-POCKETgit checkout -b feature/your-feature-name- Follow existing code style
- Add comments for complex logic
- Test your changes locally
git add .
git commit -m "Add: your feature description"
git push origin feature/your-feature-name- Go to GitHub
- Click "New Pull Request"
- Describe your changes
- Wait for review
- β User authentication
- β Player search
- β Favorites management
- β Comments system
- β Premium UI design
- β Deployment workflow
- Player statistics and career info
- Team filtering and sorting
- Player comparison feature
- Dark mode toggle
- Mobile app (React Native)
- Social features (share favorites)
- Notifications for player updates
- BallDontLie API for providing free NBA data
- Render for free hosting
- NBA for the amazing sport and players
- Open source community for the tools and libraries
Need help? Here's how to get support:
- Check Documentation - Read this README thoroughly
- Search Issues - Check GitHub Issues
- Open New Issue - If problem persists, create a new issue with:
- Detailed description
- Steps to reproduce
- Expected vs actual behavior
- Screenshots if applicable
- Your environment (OS, Node version, etc.)
Enjoy tracking your favorite NBA players! πβ
Last Updated: December 4, 2024



