Skip to content

Backend for Cornell Sports Event Management Application providing real-time college sports schedules, filtering, and ticket purchasing.

Notifications You must be signed in to change notification settings

3TTemi/sportify-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 

Repository files navigation

Introduction

Welcome to Sportify, your go-to app for staying updated on upcoming and current sports matches hosted by Cornell University! Whether you're a passionate Cornell student hoping to support school spirit or just someone who loves the thrill of Cornell sports, this app is designed to keep you in the loop.

Description

Sportify is an API that allows its clients to:

  • Access a database storing Cornell University's home games, in which the client can view all current and future games or modify their search by selecting qualities that specific games might have in common (referred to as identifiers)
  • Register, Login, and Lougout of an account using an inputted email and password
  • Edit the Configuration of the Account (Adding Funds, Changing Username)
  • Purchase tickets for one or more games

Data Models:

  • Game Model, representing a sports match betweeen two universities
  • User Model, represening a user to login and view the available games
  • Ticket Model, representing a ticket to that is bought by a user for a specific sports game
  • School Model, representing a university instituion that is participating in sports games
  • Player Model, representing students that are apart of univierites sports roster

Model Relationships:

  • Many-to-Many Relationship : Users and Games (Attending Users)
  • Many-to-Many Relationship : Games and Players (Home Roster and Away Roster)
  • One-to-Many Relationship : User and Tickets
  • One-to-Many Relationship : Game and Tickets
  • One-to-Many Relationship : School and Games (Home and Away Games)

How to Use

GET: Get all games /games/

Response:

<HTTP STATUS CODE 200>

[
        {
            "id": <GAME ID>,
            "sport": <SPORT OF GAME>,
            "sex": <SEX OF GAME>,
            "date-time": <DATE-TIME OF GAME>,
            "location": <LOCATION OF GAME>,
            "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
            "away_team_name": <NAME OF AWAY TEAM OF GAME>,
            "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
            "tickets": [<SERIALIZED TICKET>, ...],
            "users_attending": [<SERIALIZED USER>, ...],
            "home_roster": [<SERIALIZED PLayer>, ...],
            "away_roster": [<SERIALIZED PLayer>, ...]
        },
        // Other Games Here 
        {},{},{}
]

GET: Get all current games /games/current/

<HTTP STATUS CODE 200>
[
        {
            "id": <GAME ID>,
            "sport": <SPORT OF GAME>,
            "sex": <SEX OF GAME>,
            "date-time": <DATE-TIME OF GAME>,
            "location": <LOCATION OF GAME>,
            "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
            "away_team_name": <NAME OF AWAY TEAM OF GAME>,
            "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
            "tickets": [<SERIALIZED TICKET>, ...],
            "users_attending": [<SERIALIZED USER>, ...],
            "home_roster": [<SERIALIZED PLayer>, ...],
            "away_roster": [<SERIALIZED PLayer>, ...]
        },
        // Other Games Here 
        {},{},{}
]

GET: Get all future games /games/future/

<HTTP STATUS CODE 200>
[
        {
            "id": <GAME ID>,
            "sport": <SPORT OF GAME>,
            "sex": <SEX OF GAME>,
            "date-time": <DATE-TIME OF GAME>,
            "location": <LOCATION OF GAME>,
            "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
            "away_team_name": <NAME OF AWAY TEAM OF GAME>,
            "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
            "tickets": [<SERIALIZED TICKET>, ...],
            "users_attending": [<SERIALIZED USER>, ...],
            "home_roster": [<SERIALIZED PLayer>, ...],
            "away_roster": [<SERIALIZED PLayer>, ...]
        },
        // Other Games Here 
        {},{},{}
]

GET: Get game by id number /games/{game id}}/

<HTTP STATUS CODE 200>

{
    "id": <GAME ID>,
    "sport": <SPORT OF GAME>,
    "sex": <SEX OF GAME>,
    "date-time": <DATE-TIME OF GAME>,
    "location": <LOCATION OF GAME>,
    "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
    "away_team_name": <NAME OF AWAY TEAM OF GAME>,
    "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
    "tickets": [<SERIALIZED TICKET>, ...],
    "users_attending": [<SERIALIZED USER>, ...],
    "home_roster": [<SERIALIZED PLayer>, ...],
    "away_roster": [<SERIALIZED PLayer>, ...]
}
 

GET: Get all games by identifier /games/{identifier}/

<HTTP STATUS CODE 200>

[
        {
            "id": <GAME ID>,
            "sport": <SPORT OF GAME>,
            "sex": <SEX OF GAME>,
            "date-time": <DATE-TIME OF GAME>,
            "location": <LOCATION OF GAME>,
            "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
            "away_team_name": <NAME OF AWAY TEAM OF GAME>,
            "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
            "tickets": [<SERIALIZED TICKET>, ...],
            "users_attending": [<SERIALIZED USER>, ...]
        },
        // Other Games Here 
        {},{},{}
]

POST: Insert game into database /games/

<HTTP STATUS CODE 201>

{
    "id": <GAME ID>,
    "sport": <SPORT OF GAME>,
    "sex": <SEX OF GAME>,,
    "date_time": <DATE-TIME OF GAME>,
    "location": <LOCATION OF GAME>,
    "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
    "away_team_name": <NAME OF AWAY TEAM OF GAME>,
    "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
    "tickets": [<SERIALIZED TICKET>, ...],
    "users_attending": [<SERIALIZED USER>, ...],
    "home_roster": [<SERIALIZED PLayer>, ...],
    "away_roster": [<SERIALIZED PLayer>, ...]
}
    

POST: Update a game's information with new variables /games/{game id}/

<HTTP STATUS CODE 201>

{
    "id": <GAME ID>,
    "sport": <SPORT OF GAME>,
    "sex": <SEX OF GAME>,,
    "date_time": <DATE-TIME OF GAME>,
    "location": <LOCATION OF GAME>,
    "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
    "away_team_name": <NAME OF AWAY TEAM OF GAME>,
    "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
    "tickets": [<SERIALIZED TICKET>, ...],
    "users_attending": [<SERIALIZED USER>, ...],
    "home_roster": [<SERIALIZED PLayer>, ...],
    "away_roster": [<SERIALIZED PLayer>, ...]
}

DELETE: Delete a specific game from database /games/{game id}/

<HTTP STATUS CODE 200>

{
    "id": <GAME ID>,
    "sport": <SPORT OF GAME>,
    "sex": <SEX OF GAME>,,
    "date_time": <DATE-TIME OF GAME>,
    "location": <LOCATION OF GAME>,
    "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
    "away_team_name": <NAME OF AWAY TEAM OF GAME>,
    "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
    "tickets": [<SERIALIZED TICKET>, ...],
    "users_attending": [<SERIALIZED USER>, ...],
    "home_roster": [<SERIALIZED PLayer>, ...],
    "away_roster": [<SERIALIZED PLayer>, ...]
} 


DELETE: Delete all games from database /games/

<HTTP STATUS CODE 200>
[
    {
        "id": <GAME ID>,
        "sport": <SPORT OF GAME>,
        "sex": <SEX OF GAME>,,
        "date_time": <DATE-TIME OF GAME>,
        "location": <LOCATION OF GAME>,
        "away_team_logo": <LOGO OF AWAY TEAM OF GAME>,
        "away_team_name": <NAME OF AWAY TEAM OF GAME>,
        "num_tickets": <NUMBER OF TICKET REMAINING FOR GAME>,
        "tickets": [<SERIALIZED TICKET>, ...],
        "users_attending": [<SERIALIZED USER>, ...],
        "home_roster": [<SERIALIZED PLayer>, ...],
        "away_roster": [<SERIALIZED PLayer>, ...]
    } 
    // Other Games Here 
     {},{},{}

]

POST: Register user into database /user/register/

<HTTP STATUS CODE 201>
{
    "session_token": <USER SESSION TOKEN>,
    "session_expiration": <DATE OF USER SESSION EXPIRATION>,
    "refresh_token": <USER REFRESH TOKEN> 
}

POST: Refresh user's session token /session/

<HTTP STATUS CODE 200>
{       
    "session_token": <USER SESSION TOKEN>,
    "session_expiration": <DATE OF USER SESSION EXPIRATION>,
    "refresh_token": <USER REFRESH TOKEN> 
}

POST: Login user /user/login/

<HTTP STATUS CODE 200>
{
    "session_token": <USER SESSION TOKEN>,
    "session_expiration": <DATE OF USER SESSION EXPIRATION>,
    "refresh_token": <USER REFRESH TOKEN> 
}

POST: Logout user /user/logout/

<HTTP STATUS CODE 200>
"You have been logged out"

GET: Get user by user id /user/{user id}/

<HTTP STATUS CODE 200>
{
    "id": <USER ID>,
    "username": <USER USERNAME>,
    "email": <USER EMAIL>,
    "balance": <USER BALANCE>
}

POST: Update user username user/{user id}/username/

<HTTP STATUS CODE 201>
<USER UPDATED USERNAME> 

POST: Update funds on user's account /user/{user id}/funds/

<HTTP STATUS CODE 201>
<USER UPDATED BALANCE>

POST: Purchase tickets and add to respective tables /user/{user id}/tickets/

<HTTP STATUS CODE 201>
{
    "id": <TICKKET ID>,
    "cost": <TICKET COST>,
    "user_id": <ID OF USER WHO PURCHASED TICKET>,
    "game_id": <ID OF GAME TICKET IS ASSOCIATED WITH>
}

POST: Add school to database /schools/

<HTTP STATUS CODE 201>
{
    "id": <SCHOOL ID>,
    "name": <SCHOOL NAME>,
    "logo_image": <SCHOOL SPORTS LOGO>
}

GET: Get school by school id /schools/{school id}

<HTTP STATUS CODE 200>
{
    "id": <SCHOOL ID>,
    "name": <SCHOOL NAME>,
    "logo_image": <SCHOOL SPORTS LOGO>
}

DELETE: Remove school from database /schools/{school id}/

<HTTP STATUS CODE 200>
{
    "id": <SCHOOL ID>,
    "name": <SCHOOL NAME>,
    "logo_image": <SCHOOL SPORTS LOGO>
}

GET: Get all schools /schools/

<HTTP STATUS CODE 200>

[
    {
    "id": <SCHOOL ID>,
    "name": <SCHOOL NAME>,
    "logo_image": <SCHOOL SPORTS LOGO>
    },
    // Other Schools
     {},{},{}
]

POST: Add player to database /players/

<HTTP STATUS CODE 201>
{
    "id": <PLAYER ID>,
    "name": <PLAYER NAME>,
    "age": <PLAYER AGE>,
    "picture": <PLAYER PROFILE PICTURE>,
    "bio": <PLAYER BIO>
}

POST: Insert school into database /schools/

<HTTP STATUS CODE 201>
{
    "id": <SCHOOL ID>,
    "name": <SCHOOL NAME>,
    "logo_image": <SCHOOL SPORTS LOGO>
}

Feedback

Feel free to let us know if you would like us to include any other features to our app, or if there is something in our code that we could improve! Thank you for trying Sportify!

About

Backend for Cornell Sports Event Management Application providing real-time college sports schedules, filtering, and ticket purchasing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published