Skip to content

Fer-r/racehub

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

220 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RaceHub API Documentation

Table of Contents

Project Overview

RaceHub is a comprehensive platform for managing racing events, including cycling, running, and trail running competitions. Built with Symfony 7.2, it provides a robust API for event management and participant tracking.

Features

  • Multi-sport event management
  • User authentication and authorization
  • Participant registration system
  • Race results tracking
  • Admin dashboard

Installation

Prerequisites

  • PHP 8.2+
  • Composer
  • MySQL
  • Symfony CLI

Setup Steps

  1. Clone the repository:
git clone https://github.com/yourusername/racehub.git
cd racehub
  1. Install dependencies:
composer install
  1. Configure environment:
cp .env.example .env
  1. Set up database:
php bin/console doctrine:database:create
php bin/console doctrine:migrations:migrate
  1. Generate JWT keys:
php bin/console lexik:jwt:generate-keypair
  1. Start server:
symfony server:start

API Documentation

Base URL

https://api.racehub.com

Authentication

Login

Endpoint: POST /api2/auth/login_check

Description: Authenticate user and get JWT token.

Request Body:

{ 
  "email": "string", 
  "password": "string" 
}

Response:

{ 
  "user": 
        { 
          "id": 1, 
          "email": "user@example.com", 
          "roles": ["ROLE_USER"] 
        }, 
        "message": "Login successful" 
}

Logout

Endpoint: POST /api/auth/logout

Description: Ends user session.

Response:

{ 
  "message": "Logout successful" 
}

User Management

Get All Users

Endpoint: GET /api/user

Response:

[ 
  { 
    "id": 1, 
    "email": "john@example.com", 
    "roles": ["ROLE_USER"], 
    "name": "John Doe", 
    "banned": false 
  } 
]

Get User by ID

Endpoint: GET /api/user/:id

Response:

{ 
  "id": 1, 
  "email": "john@example.com", 
  "roles": ["ROLE_USER"], 
  "name": "John Doe", 
  "banned": false 
}

Edit User

Endpoint: PUT /api/user/:id/edit

Request Body:

{ 
  "email": "new@example.com", 
  "roles": ["ROLE_ADMIN"], 
  "name": "John Updated", 
  "oldpassword": "oldpass", 
  "newpassword": "newpass", 
  "banned": false 
}

Response:

{ 
  "success": true 
}

Race Events

Get All Cycling Events

Endpoint: GET /api/cycling

Response:

[ 
  { 
    "id": 1, "name": "Tour de Example", 
    "description": "Annual cycling event", 
    "date": "2024-06-15T09:00:00Z", 
    "distance_km": 150, 
    "location": "Paris", 
    "image": "url-to-image" 
  } 
]

Get Cycling Event by ID

Endpoint: GET /api/cycling/:id

Response:

{ 
  "id": 1, 
  "name": "Tour de Example", 
  "description": "Annual cycling event", 
  "date": "2024-06-15T09:00:00Z", 
  "distance_km": 150, 
  "location": "Paris", 
  "image": "url-to-image" 
}

Participants

Get All Participants

Endpoint: GET /api/cycling_participant/

Response:

[ 
  { 
    "id": 1, 
    "user": 1, 
    "cycling": 1, 
    "time": "02:30:00", 
    "dorsal": 101, 
    "banned": false 
  } 
]

Register for Cycling Event

Endpoint: POST /api/cycling_participant/new

Request Body:

{ 
  "user": 1, 
  "cycling": 1, 
  "time": "02:30:00", 
  "dorsal": 101, 
  "banned": false 
}

Response:

{ 
  "id": 1, 
  "user": 1, 
  "cycling": 1, 
  "time": "02:30:00", 
  "dorsal": 101, 
  "banned": false 
}

Delete Participant

Endpoint: DELETE /api/cycling_participant/:id

Response:

{ 
  "success": true 
}

API Response Codes

Code Meaning
200 Success
201 Created
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
422 Validation Error
500 Server Error

Error Response Format:

{ 
  "status": "error", 
  "code": 400, 
  "message": "Error description", 
  "errors": 
    [ 
      { 
        "field": "username", 
        "message": "Username is required" 
      } 
    ] 
}

Contributing

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

Coding Standards

  • Follow PSR-12
  • Write unit tests
  • Document new features

Support

  • Issues: GitHub Issues
  • Email: support@racehub.com
  • Documentation: [Link to detailed documentation]

Last Updated: 2025
Version: 1.0.0

RaceHub

RaceHub is a web application for managing running, cycling, and trail running races with participant registration and management.

Prerequisites

  • Docker and Docker Compose
  • Git
  • PHP 8.1+ (for local development without Docker)
  • Composer (for local development without Docker)

Getting Started

Clone the Repository

git clone https://your-repository-url/racehubJWT.git
cd racehub

Prepare the Environment

Before starting the Docker containers:

  1. If you're on Windows, open Git Bash and run:
dos2unix ./backend/entrypoint.sh ./nginx/certs.sh
  1. If you're on Linux, install dos2unix first and then run the same command:
sudo apt-get install dos2unix
dos2unix ./backend/entrypoint.sh ./nginx/certs.sh
  1. Make sure there is no ./backend/composer.lock file the first time you start the project:
rm -f ./backend/composer.lock

Running with Docker

  1. Start the Docker containers:
docker-compose up --build
  1. To run in detached mode (background):
docker-compose up -d

Accessing the Application

Project Structure

  • backend/ - Symfony backend with API Platform
  • nginx/ - Nginx configuration for serving the application
  • docker-compose.yml - Docker configuration

Authentication

The application uses JWT (JSON Web Token) for authentication. Tokens are valid for 7 days.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • PHP 44.2%
  • Twig 35.5%
  • CSS 10.4%
  • JavaScript 8.4%
  • Other 1.5%