MainPage Component - jonasyr/gitray GitHub Wiki

   ██████╗ ██╗████████╗██████╗  █████╗ ██╗   ██╗
  ██╔════╝ ██║╚══██╔══╝██╔══██╗██╔══██╗╚██╗ ██╔╝
  ██║  ███╗██║   ██║   ██████╔╝███████║ ╚████╔╝ 
  ██║   ██║██║   ██║   ██╔══██╗██╔══██║  ╚██╔╝  
  ╚██████╔╝██║   ██║   ██║  ██║██║  ██║   ██║   
   ╚═════╝ ╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝   
    Official Wiki of the GitRay Repository!

Table of Contents

Description

Overview of MainPage:

  • Main application page that serves as the central hub for GitRay's repository visualization functionality.
  • Orchestrates repository input and displays commit information with interactive visualizations.
  • Provides a responsive layout with header, main content area, and footer.
  • Features dynamic switching between commit list and activity heatmap views.
  • Handles loading states, error management, and user interactions for repository data visualization.

Implementation

What does this component exactly do:

  • The MainPage component serves as the primary interface for users to analyze Git repositories.
  • A user can enter a repository URL.

Trigger:

  • User input of a repository URL through the RepoInput component, followed by clicking the "Visualize" button.

What happens with the GUI:

  • Displays a loading animation (RiveLoader) while fetching data.
  • Shows error messages in red-bordered containers if requests fail.
  • Renders navigation buttons to switch between "Commit List" and "Activity Heatmap" views.
  • Dynamically displays either the CommitList or ActivityHeatmap component based on user selection.
  • Shows placeholder explanation buttons when no repository data is loaded.

What happens in the background/Backend:

  • Calls the getRepositoryFullData API endpoint with the repository URL and 'day' time period.
  • Fetches comprehensive repository data including commits and heatmap information in a single optimized request.
  • Updates component state with received commit data.
  • Handles error cases and displays appropriate user feedback.

Structure

Project path and file name

MainPage Component:

  • File name: MainPage.tsx
  • Project path: gitray/apps/frontend/src/pages/MainPage.tsx

Unit-Test:

  • File name: MainPage.test.tsx
  • Project path: gitray/apps/frontend/__tests__/pages/MainPage.test.tsx

Related files

  1. RepoInput Component: gitray/apps/frontend/src/components/RepoInput.tsx
    • Handles repository URL input form
  2. CommitList Component: gitray/apps/frontend/src/components/CommitList.tsx
    • Displays commits in list format
  3. ActivityHeatmap Component: gitray/apps/frontend/src/components/ActivityHeatmap.tsx
    • Visualizes commit activity as heatmap
  4. RiveLoader Component: gitray/apps/frontend/src/components/RiveLoader.tsx
    • Animated loading indicator
  5. RiveLogo Component: gitray/apps/frontend/src/components/RiveLogo.tsx
    • Animated logo component
  6. API Service: gitray/apps/frontend/src/services/api.ts
    • Contains getRepositoryFullData function
  7. Shared Types: gitray/packages/shared-types/src/index.ts
    • Defines Commit interface and related types

Technology

List of Technologies:

  • React (Functional Component with Hooks)
  • TypeScript
  • Tailwind CSS (for styling and responsive design)
  • React State Management (useState hooks)
  • Axios (for API calls via api service)
  • Rive (for animated logo and loader components)
  • Vitest (for unit testing)
  • React Testing Library (for component testing)

UML-Diagrams

Package diagram

MainPage Package Diagram

Activity diagram

MainPage Activity Diagram

Object diagram

MainPage Object Diagram

Class diagram

MainPage Class Diagram