Skip to main content
The GitHub Activity section displays real-time contribution data from GitHub, showcasing coding activity, commit streaks, and contribution patterns through beautiful visualizations.

Overview

Located in src/components/GithubActivity.tsx, this component provides:
  • Activity graph showing contributions over time
  • Streak statistics tracking consecutive contribution days
  • Snake animation visualizing contribution grid
  • Automatic updates from GitHub’s public API
  • Error handling with graceful fallbacks
All GitHub data is pulled live from public GitHub APIs and third-party services. No backend configuration is required.

Component Structure

import React, { useState } from 'react';
import ScrollReveal from './ScrollReveal';

const GithubActivity: React.FC = () => {
  const username = 'AndreRuperto';
  const theme = 'merko';  // Color scheme

  const [showGraph, setShowGraph] = useState(true);
  const [showSnake, setShowSnake] = useState(true);

  return (
    <section className="w-full py-16 px-4 bg-background">
      {/* Activity visualizations */}
    </section>
  );
};

Visualizations

1. Activity Graph

The main contribution graph displays commit activity over time:
{showGraph && (
  <ScrollReveal className="w-full" delay={100}>
    <div className="w-full glass rounded-lg p-4 hover-lift">
      <img
        src={`https://github-readme-activity-graph.vercel.app/graph?username=${username}&theme=${theme}`}
        alt="Gráfico de atividade do GitHub"
        className="w-full rounded-lg"
        onError={() => setShowGraph(false)}
      />
    </div>
  </ScrollReveal>
)}
Features:
  • Shows contribution frequency
  • Color-coded by activity level
  • Displays recent months
  • Automatically updates daily

Activity Graph

The graph uses GitHub’s contribution data to show coding patterns, highlighting periods of high activity and consistent contributions.

2. Streak Statistics

Tracks consecutive days of contributions:
{showSnake && (
  <ScrollReveal delay={200}>
    <div className="w-full max-w-2xl glass rounded-lg p-4 hover-lift">
      <a
        href="https://git.io/streak-stats"
        target="_blank"
        rel="noopener noreferrer"
      >
        <img
          src={`https://randolph-santos.vercel.app?user=${username}&theme=${theme}`}
          alt="GitHub Streak"
          className="w-full rounded-lg"
        />
      </a>
    </div>
  </ScrollReveal>
)}
Displays:
  • Current streak (consecutive days)
  • Longest streak achieved
  • Total contributions
  • Last contribution date

3. Snake Animation

Animated snake that “eats” contributions from the grid:
{showSnake && (
  <ScrollReveal delay={300}>
    <div className="w-full mt-8 glass rounded-lg p-6">
      <img
        src={`https://raw.githubusercontent.com/${username}/${username}/output/github-contribution-grid.svg`}
        alt="Snake animation"
        className="w-full"
        onError={() => setShowSnake(false)}
      />
    </div>
  </ScrollReveal>
)}
The snake animation requires a GitHub Action to generate the SVG. See Setup Guide for configuration instructions.

Section Header

<div className="text-center mb-16">
  <span className="section-title">Github</span>
  <h2 className="heading-md">
    Atividade <span className="text-gradient">Github</span>
  </h2>
</div>

Error Handling

The component gracefully handles missing or failed images:
const [showGraph, setShowGraph] = useState(true);
const [showSnake, setShowSnake] = useState(true);

// On image load error
<img
  onError={() => setShowGraph(false)}
/>
If an image fails to load:
  1. Error event is triggered
  2. State is updated to hide that visualization
  3. Other visualizations remain visible
  4. No error message is shown to users
If all three visualizations fail to load, the section will appear empty. Ensure your GitHub username is correct and the profile is public.

Theme Configuration

The component uses the “merko” theme for consistent styling:
const theme = 'merko';
Available themes:
  • default - GitHub’s default colors
  • dark - Dark mode friendly
  • radical - Vibrant purple/pink
  • merko - Green/yellow (currently used)
  • gruvbox - Retro color scheme
  • tokyonight - Blue/purple theme
  • onedark - Atom One Dark
  • cobalt - Blue theme
  • synthwave - Neon/retro
  • highcontrast - High contrast
To change the theme, simply update the theme constant:
const theme = 'dark'; // or any other theme name

Scroll Animations

Each visualization appears with a staggered delay:
<ScrollReveal delay={100}>  {/* Activity graph */}
<ScrollReveal delay={200}>  {/* Streak stats */}
<ScrollReveal delay={300}>  {/* Snake animation */}
This creates a smooth, progressive reveal as users scroll to the section.

Responsive Design

Mobile

  • Full-width visualizations
  • Stacked layout
  • Maintained aspect ratios
  • Touch-friendly sizing

Desktop

  • Centered max-width container
  • Generous padding
  • Hover effects on cards
  • Optimal viewing size

Integration

Add the GitHub Activity section to your portfolio:
import GithubActivity from '@/components/GithubActivity';

function App() {
  return (
    <>
      <HeroSection />
      <ProjectsSection />
      <GithubActivity />  {/* Place where desired */}
      <ContactSection />
    </>
  );
}

Customization

Change Username

const username = 'YourGitHubUsername';

Adjust Container Styles

<div className="max-w-6xl mx-auto">  {/* Change max width */}
  {/* Content */}
</div>

Modify Card Appearance

<div className="glass rounded-lg p-4 hover-lift">  {/* Custom classes */}
  <img src="..." />
</div>

External Services Used

Activity Graph Service

Provider: github-readme-activity-graph.vercel.app
Endpoint: https://github-readme-activity-graph.vercel.app/graph
Parameters:
  • username - GitHub username
  • theme - Color theme name

Streak Stats Service

Provider: randolph-santos.vercel.app (GitHub Readme Streak Stats)
Endpoint: https://randolph-santos.vercel.app
Parameters:
  • user - GitHub username
  • theme - Color theme name

Snake Animation

Provider: GitHub Actions (self-hosted)
Location: https://raw.githubusercontent.com/{username}/{username}/output/github-contribution-grid.svg

Setting Up Snake Animation

The snake animation requires a GitHub Action in your profile repository. See the GitHub Snake Setup Guide for step-by-step instructions.

Privacy Considerations

All data displayed is already public on your GitHub profile. No private repository information or sensitive data is exposed.
What’s visible:
  • Public repository contributions
  • Public commit activity
  • Contribution streaks
  • Total contribution counts
What’s NOT visible:
  • Private repository activity
  • Organization private repos
  • Commit messages or code
  • Repository names or details

Performance

The component loads images from external services: Optimization tips:
  • Images are cached by browser
  • Loading is non-blocking
  • Failed images don’t break layout
  • Lazy loading via ScrollReveal
Load times:
  • Activity graph: ~1-2 seconds
  • Streak stats: ~1 second
  • Snake animation: ~500ms (if pre-generated)

Troubleshooting

Visualizations Not Appearing

  1. Check username: Ensure username variable is correct
  2. Verify profile is public: Private profiles won’t work
  3. Check browser console: Look for 404 or CORS errors
  4. Test image URLs directly: Open image URLs in browser

Snake Animation Missing

  1. Setup GitHub Action: Required for snake generation
  2. Check repository name: Should match username exactly
  3. Verify action ran: Check Actions tab in GitHub
  4. Wait for generation: Initial setup takes a few minutes

Theme Not Applying

  1. Check theme name: Ensure it’s spelled correctly
  2. Try different theme: Some services support different themes
  3. Clear cache: Hard refresh to see changes

Images Look Broken on Mobile

  1. Check responsive classes: Ensure w-full is applied
  2. Test on real device: Not just browser dev tools
  3. Verify image aspect ratio: Some themes have fixed dimensions

Alternative Services

If the default services are slow or unavailable, consider alternatives: Activity Graphs:
  • github-readme-stats.vercel.app
  • github-profile-summary-cards.vercel.app
Streak Stats:
  • github-readme-streak-stats.herokuapp.com
  • Custom implementation with GitHub API
Snake Animation:
  • github-readme-activity-graph (different output)
  • Custom D3.js visualization
When changing services, update image URLs and verify the API parameters are compatible.

Advanced: Custom GitHub Integration

For more control, you can use the GitHub GraphQL API:
// Fetch contribution data directly
const query = `
  query($username: String!) {
    user(login: $username) {
      contributionsCollection {
        contributionCalendar {
          totalContributions
          weeks {
            contributionDays {
              date
              contributionCount
            }
          }
        }
      }
    }
  }
`;
This allows:
  • Custom visualizations
  • Real-time updates
  • Additional data points
  • Complete styling control
See GitHub API Guide for implementation details.

Build docs developers (and LLMs) love