Skip to content

Repository files navigation

🏏 CricMate - Cricket Match Management System

A full-stack cricket match management application with real-time ball-by-ball commentary, comprehensive statistics, and admin controls.

Tech Stack Spring Boot PostgreSQL Supabase

πŸ“‹ Table of Contents

✨ Features

🎯 Core Features

  • Match Management: Create and manage cricket matches with detailed information
  • Ball-by-Ball Commentary: Real-time ball tracking with comprehensive statistics
  • Team Management: Organize teams and player rosters
  • Tournament System: Create and manage cricket tournaments
  • Innings Tracking: Detailed innings-level data and analytics
  • Player Profiles: Comprehensive player statistics and information

πŸ” Admin Features

  • Secure Authentication: Supabase-powered authentication with admin role management
  • Protected Routes: Page-level and component-level access control
  • Admin Dashboard: Dedicated admin controls for data management
  • Edit Capabilities: Modify match data, balls, and statistics

🎨 UI/UX

  • Modern Design: Sleek dark theme with gradient accents (orange-red-purple)
  • Responsive Layout: Mobile-first design that works on all devices
  • Real-time Updates: Live commentary and score updates
  • Toast Notifications: User-friendly feedback for all actions

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 16 with React 19
  • Language: TypeScript
  • Styling: Tailwind CSS 4
  • UI Components: Radix UI primitives
  • Icons: Lucide React
  • Authentication: Supabase Auth
  • Notifications: React Hot Toast

Backend

  • Framework: Spring Boot 3.3.4
  • Language: Java 21
  • Database: PostgreSQL
  • ORM: Spring Data JPA
  • Build Tool: Maven
  • Dev Tools: Spring DevTools, Lombok

Database & Auth

  • Database: PostgreSQL (via Supabase)
  • Authentication: Supabase Auth
  • Storage: Supabase Storage

πŸ“ Project Structure

cricmate/
β”œβ”€β”€ backend/                    # Spring Boot backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”‚   β”œβ”€β”€ java/com/cricmate/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ controller/    # REST API controllers
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ model/         # JPA entities
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ repository/    # Data repositories
β”‚   β”‚   β”‚   β”‚   └── service/       # Business logic
β”‚   β”‚   β”‚   └── resources/
β”‚   β”‚   β”‚       └── application.properties
β”‚   β”‚   └── test/
β”‚   └── pom.xml
β”‚
β”œβ”€β”€ nextfront/                  # Next.js frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                   # App router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ addmatch/          # Add match page
β”‚   β”‚   β”‚   β”œβ”€β”€ addplayer/         # Add player page
β”‚   β”‚   β”‚   β”œβ”€β”€ addteam/           # Add team page
β”‚   β”‚   β”‚   β”œβ”€β”€ addtournament/     # Add tournament page
β”‚   β”‚   β”‚   β”œβ”€β”€ addinnings/        # Add innings page
β”‚   β”‚   β”‚   β”œβ”€β”€ add-ball-by-ball/  # Ball-by-ball entry
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/             # Admin authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ matches/           # Match pages
β”‚   β”‚   β”‚   β”œβ”€β”€ players/           # Player pages
β”‚   β”‚   β”‚   β”œβ”€β”€ teams/             # Team pages
β”‚   β”‚   β”‚   └── tournaments/       # Tournament pages
β”‚   β”‚   β”œβ”€β”€ components/            # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/                # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Commentary.tsx     # Ball-by-ball commentary
β”‚   β”‚   β”‚   β”œβ”€β”€ Scorecard.tsx      # Match scorecard
β”‚   β”‚   β”‚   β”œβ”€β”€ MatchDetails.tsx   # Match information
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ hooks/                 # Custom React hooks
β”‚   β”‚   β”‚   └── useIsAdmin.ts      # Admin check hook
β”‚   β”‚   β”œβ”€β”€ lib/                   # Utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ supabaseClient.ts  # Supabase config
β”‚   β”‚   β”‚   └── utils.ts           # Helper functions
β”‚   β”‚   └── types/                 # TypeScript types
β”‚   β”œβ”€β”€ public/                    # Static assets
β”‚   └── package.json
β”‚
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js 20+ and npm
  • Java 21+
  • Maven 3.6+
  • PostgreSQL database (or Supabase account)

Backend Setup

  1. Clone the repository

    git clone https://github.com/MuhammadMustafa18/CricMateDbProject.git
    cd cricmate/backend
  2. Configure database

    Create a .env file in the backend directory:

    SPRING_DATASOURCE_URL=jdbc:postgresql://your-db-host:5432/your-db-name
    SPRING_DATASOURCE_USERNAME=your-username
    SPRING_DATASOURCE_PASSWORD=your-password
  3. Run the backend

    mvn spring-boot:run

    The API will be available at http://localhost:8080

Frontend Setup

  1. Navigate to frontend directory

    cd ../nextfront
  2. Install dependencies

    npm install
  3. Configure Supabase

    Create a .env.local file:

    NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
  4. Run the development server

    npm run dev

    The app will be available at http://localhost:3000

Database Setup

Run the SQL schema to create the necessary tables:

  • teams
  • players
  • tournaments
  • matches
  • innings
  • balls
  • profiles (for admin management)

πŸ” Authentication & Authorization

User Roles

  • Public Users: Can view matches, teams, players, and statistics
  • Admin Users: Full access to create, edit, and delete data

Admin Setup

  1. Create a user account via Supabase Auth
  2. In the profiles table, set is_admin = true for admin users
  3. Admin users can access:
    • All /add* routes (addmatch, addplayer, addteam, etc.)
    • Ball-by-ball entry forms
    • Edit buttons on commentary

Protected Routes

All admin routes use session-based authentication:

  • Session check via Supabase
  • Admin role verification from profiles table
  • Toast notifications for unauthorized access
  • Automatic redirects to login or home page

Component-Level Protection

Use the useIsAdmin hook for conditional rendering:

import { useIsAdmin } from "@/hooks/useIsAdmin";

export default function MyComponent() {
  const { isAdmin, loading } = useIsAdmin();

  return (
    <div>
      {isAdmin && (
        <button>Admin Only Action</button>
      )}
    </div>
  );
}

πŸ“‘ API Documentation

Base URL

http://localhost:8080

Endpoints

Teams

  • GET /teams - Get all teams
  • GET /teams/{id} - Get team by ID
  • GET /teams/full/{id} - Get team with players
  • POST /teams/create - Create new team

Players

  • GET /players - Get all players
  • GET /players/{id} - Get player by ID
  • POST /players - Create new player

Matches

  • GET /matches - Get all matches
  • GET /matches/{id} - Get match by ID
  • GET /matches/full/{id} - Get match with full details
  • POST /matches - Create new match

Tournaments

  • GET /tournaments - Get all tournaments
  • GET /tournaments/{id} - Get tournament by ID
  • GET /tournaments/{id}/matches - Get tournament matches
  • POST /tournaments - Create new tournament

Innings

  • GET /innings - Get all innings
  • GET /innings/{id} - Get innings by ID
  • POST /innings - Create new innings

Balls

  • GET /balls - Get all balls
  • GET /balls/{id} - Get ball by ID
  • POST /balls - Create new ball
  • PATCH /balls/{id} - Update ball

πŸ—„οΈ Database Schema

Core Tables

teams

  • team_id (PK)
  • team_name

players

  • player_id (PK)
  • player_name
  • full_name
  • date_of_birth
  • batting_style
  • bowling_style
  • playing_role

matches

  • match_id (PK)
  • team_a_id (FK)
  • team_b_id (FK)
  • tournament_id (FK)
  • match_date
  • match_state
  • match_format
  • venue

innings

  • innings_id (PK)
  • match_id (FK)
  • batting_team_id (FK)
  • bowling_team_id (FK)

balls

  • ball_id (PK)
  • innings_id (FK)
  • over_number
  • ball_number
  • batsman_id (FK)
  • bowler_id (FK)
  • runs
  • wicket

profiles (Supabase)

  • id (PK, FK to auth.users)
  • is_admin

🎨 Screenshots

Add screenshots of your application here

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is open source and available under the MIT License.

πŸ‘¨β€πŸ’» Author

Muhammad Mustafa

πŸ™ Acknowledgments

  • Next.js team for the amazing framework
  • Spring Boot for the robust backend framework
  • Supabase for authentication and database services
  • Radix UI for accessible component primitives
  • Tailwind CSS for the utility-first CSS framework

Built with ❀️ for cricket enthusiasts

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages