A web application for ordinary basketball enthusiasts who often play together in teams. It can add players, record game results, rating for players, AI groupings, leadership boards.
Since this is for daily playing practice, we won't record advanced data such as individual scores, assists, rebounds, etc. Instead, we will only record the game results. Then, the players will rate each other after the game, and the next time, the groups will be formed based on the ratings.
The project is built with Next.js 14, Tailwind CSS, shadcn/ui, and SAP HANA Cloud. If you want to change the data base to sqlite or other DBs, reach the part Switching to SQLite Database
- Clone the repository:
git clone <repository-url>
cd RBAStats- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env.localEdit .env.local and fill in your credentials:
HANA_HOST: Your HANA Cloud instance hostHANA_USER: Your HANA database usernameHANA_PASSWORD: Your HANA database passwordADMIN_SECRET: A secure secret string for admin authentication
- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
This is just a simple software designed for ordinary basketball enthusiasts who often play together in teams. Its purpose is to record their performance in each game. The usage is very simple and no special tutorials are required.
The application uses SAP HANA Cloud as the database. Main tables:
- players: Stores player information and statistics
- games: Stores game results and scores
- game_players: Junction table linking players to games and teams
- player_ratings: Player performance ratings
- player_tags: Player tags/labels
- tag_votes: Tag voting records
- game_share_links: Shareable game links
- leaderboard_config: Leaderboard configuration
If you need to switch to SQLite for local development, you can send the following instructions to an AI assistant:
Please help me add SQLite support to this project. Key changes needed:
Create a database abstraction layer in
lib/:
db-adapter.js- unified interfacedb-hana.js- current HANA implementationdb-sqlite.js- new SQLite implementation usingbetter-sqlite3SQL syntax differences to handle:
CREATE COLUMN TABLE→CREATE TABLENVARCHAR(n)→TEXTINTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY→INTEGER PRIMARY KEY AUTOINCREMENT- HANA uses uppercase table/column names, SQLite is case-insensitive
- Last insert ID: HANA uses
SELECT MAX(ID), SQLite useslast_insert_rowid()Files that contain direct SQL queries (need to be refactored):
lib/db.js- database connection and table creationlib/players.js- player CRUD operationslib/games.js- game CRUD operationsapp/api/rate-game/[secret]/route.js- rating logicapp/api/tags/[tagId]/vote/route.js- tag votingapp/api/players/[id]/tags/route.jsapp/api/players/[id]/comprehensive-rating/route.jsapp/api/games/[id]/share/route.jsapp/api/games/[id]/ratings/route.jsapp/api/leaderboard-config/route.jsEnvironment variable: Add
DB_TYPE=hana|sqliteto switch between databases.
RBAStats/
├── app/
│ ├── api/ # API routes
│ ├── games/ # Games pages
│ ├── players/ # Players pages
│ ├── globals.css # Global styles
│ ├── layout.js # Root layout
│ └── page.js # Home page
├── components/
│ └── ui/ # UI components
├── lib/
│ ├── db.js # Database setup (HANA Cloud)
│ ├── players.js # Player queries
│ ├── games.js # Game queries
│ └── utils.js # Utility functions
└── .env.local # Environment variables (not in git)
The app includes simple authentication to protect game recording operations.
- Admin Credential: Set via
ADMIN_SECRETenvironment variable in.env.local - Protected Operations: Recording and deleting games, managing leaderboard configuration
- Public Access: Adding/editing players, viewing all data, rating players via shared links
Security Note: Make sure to use a strong, unique secret for ADMIN_SECRET in production environments.
GPL








