Skip to content

Sprint4

Hamsini Sivalenka edited this page Apr 22, 2025 · 4 revisions

Sprint 4 Report - Sportify

Work Completed in Sprint 4

In Sprint 4, we focused on enhancing the user interaction features and making the platform more integrated and intuitive. We implemented chat functionality for event participants, enabling smoother communication within events. The backend was refined to better support frontend needs, such as adding missing participant and owner details in the event queries and fixing endpoint inconsistencies. Additionally, Google SSO was finally integrated for login, and the frontend was synced with backend APIs to bring full-stack functionality to the platform.


Issues for Sprint 4

Issue Number Title Objective Status
74 Enable Chat for Event Participants Allow users to chat within events they joined Completed
75 Simplified GET Events Endpoint Create new GET endpoint without requiring body Completed
78 Add Participants to Event List Modify query to include participant details Completed
79 Include Owner Details in Events Fetch event owner info in GET all events Completed
80 Simplify Profile API Payload Use middleware context to fetch user email Completed
82 Frontend-Backend Event Integration Complete integration of event-related APIs on frontend Completed
12 Implement Google SSO Add Google login for streamlined authentication Completed
81 Update DB Migrations for Google SSO Modify database to support Google SSO user model Completed

1. Chat Feature for Events

We introduced a real-time chat feature that enables participants of an event to communicate with each other directly through the platform. This supports:

  • Pre-event coordination (timing, equipment, etc.)
  • Quick Q&A between attendees
  • Last-minute changes or cancellations

Each event now has a dedicated chatroom, accessible once a user joins the event.


2. Backend API Improvements

Event API Enhancements

  • Created a new lightweight GET /events-simple endpoint, which returns all the events without needing a request body.
  • Enhanced the original GET /events to include:
    • Event participants list
    • Event owner's details (name, email, etc.)

Profile API Fixes

  • Previously required email in PUT/POST payload. Now, email is fetched from middleware context, ensuring data security and consistency.

3. Google SSO Integration

We finally rolled out Google Single Sign-On (SSO) to simplify the login process and reduce signup friction. This feature:

  • Allows users to log in with their Google account
  • Stores relevant user data via updated migrations
  • Works seamlessly with our existing auth middleware

4. Full Frontend Integration

We completed the frontend integration with all event endpoints, including:

  • Displaying participant info
  • Owner info on event tiles
  • Updating profile without needing user email
  • Ensuring chat, join, and leave functionalities are fully synced with backend
  • integrating google sso

5. Database Migrations

To support Google SSO, we made several database updates:

  • Added new fields for OAuth authentication in our auth tables
  • Updated user model and login flow to handle both email/password and Google login methods

6. API Documentation & Backend Endpoints

Event APIs

GET /events/all

  • Description: Retrieves a list of events with full detail.
  • Response (200 OK):
[
  {
    "id": 1,
    "event_owner": 2,
    "owner_first_name": "Alice",
    "owner_last_name": "Smith",
    "owner_email": "alice@example.com",
    "sport": "Basketball",
    "event_datetime": "2025-05-10T14:00:00Z",
    "max_players": 10,
    "location_name": "Community Center",
    "latitude": 40.712776,
    "longitude": -74.005974,
    "description": "Pickup basketball game",
    "title": "Weekend Hoops",
    "is_full": false,
    "created_at": "2025-04-18T10:00:00Z",
    "updated_at": "2025-04-18T10:00:00Z",
    "registered_count": 3,
    "participants": [
      {
        "id": 101,
        "event_id": 1,
        "user_id": 4,
        "first_name": "John",
        "last_name": "Doe",
        "joined_at": "2025-04-18T12:00:00Z"
      },
      {
        "id": 102,
        "event_id": 1,
        "user_id": 5,
        "first_name": "Jane",
        "last_name": "Smith",
        "joined_at": "2025-04-18T12:30:00Z"
      }
    ]
  }
]

GET /events/:id/chat

  • Description: Retrieves chat messages for a specific event ID.
  • Headers:
Authorization: Bearer JWT_TOKEN_HERE
  • Response: Returns a list of chat messages (structure varies based on implementation).

GET /auth/google

  • Description: Initiates Google SSO login.
  • Response: Redirects to Google OAuth.

GET /auth/google/callback

  • Description: Handles callback from Google SSO and processes the login.
  • Response: Creates user session or returns JWT token.

7. Backend Unit Tests

WebSocket and Chat Tests

The backend includes comprehensive unit tests for the WebSocket and chat functionality, ensuring reliable real-time communication:

WebSocket Hub Tests (backend/internal/websocket/websocket_test.go):

  1. TestNewHub: Verifies proper hub initialization with all required channels and maps
  2. TestHubRun: Tests the hub's main event loop, including:
    • Client registration
    • Client unregistration
    • Message broadcasting
  3. TestHandleWebSocket: Tests WebSocket connection handling:
    • Connection establishment
    • Message sending/receiving
    • Client registration in the hub
  4. TestMessageBroadcast: Validates message broadcasting between multiple clients:
    • Message delivery to all connected clients
    • Proper message formatting
    • Correct sender information
  5. TestMessageHistory: Ensures new clients receive message history when joining:
    • Message storage
    • History retrieval
    • Proper message ordering
  6. TestMessageJSON: Verifies proper JSON serialization/deserialization of chat messages

Event Integration Tests (backend/cmd/api/events_test.go):

  1. TestEventStore_Join: Tests event joining functionality:
    • Successful join operation
    • Duplicate join prevention
    • Invalid event handling
  2. TestCreateEventHandler: Validates event creation with WebSocket support
  3. TestGetEventHandler: Tests event retrieval with participant information
  4. TestUpdateEventHandler: Ensures proper event updates
  5. TestDeleteEventHandler: Verifies event deletion and cleanup

Authentication Tests (backend/internal/auth/jwt_test.go):

  1. TestJWTAuthenticator_GenerateToken: Validates token generation for WebSocket authentication
  2. TestJWTAuthenticator_ValidateToken_Success: Tests successful token validation
  3. TestJWTAuthenticator_ValidateToken_InvalidToken: Verifies rejection of invalid tokens
  4. TestJWTAuthenticator_ValidateToken_WrongSecret: Ensures token security

These tests ensure the reliability and security of our chat and WebSocket implementation, covering:

  • Connection handling
  • Message broadcasting
  • Authentication and authorization
  • Error handling
  • Data persistence
  • Real-time communication
  • Client management

8. Github Repository Link

Here's our Github Repository for Sportify - Sportify Repo

9. Github Project

Here's our Github Project Board - Sportify Project Board

10. Docs

This document is also available in our Github Wiki Page

We have also updated our Design Docs with the latest architecture and changes in this sprint.


Clone this wiki locally