Skip to content

backend: implement GitHub platform auto-discovery from GitHub API #32

Description

@ShantKhatri

Summary

Product doc section 5.10 specifies 'Platform Auto-Discovery' — when a user enters their GitHub username, DevCard should attempt to auto-discover their linked social profiles from GitHub public metadata and pre-fill the link form.

Context

The GitHub connect OAuth flow already exists in apps/backend/src/routes/connect.ts. After a successful GitHub OAuth, the backend receives an access token. Use this to call the GitHub user API and extract linked profiles.

Tasks

  • after successful GitHub OAuth in connect.ts, call GET https://api.github.com/user using the received token.
  • extract blog, twitter_username, company, bio, and html_url fields.
  • create a new route GET /api/connect/github/autodiscover (authenticated) that:
    • calls GitHub API with the stored token for the user.
    • returns discovered platforms as { platform: string, username: string, confidence: 'high' | 'low' }[].
    • twitter_usernametwitter (high confidence).
    • blog URL → portfolio (high) or infer npm/hashnode/devto from URL pattern (low).
  • do NOT auto-add links — only suggest. The client UI confirms.
  • cache the discovery result for 1 hour per user in Redis (apps/backend/src/plugins/redis.ts if it exists, or add it).
  • write tests mocking the GitHub API response and asserting discovery output.

Acceptance Criteria

  • endpoint returns structured suggestions based on real GitHub API data.
  • no links are auto-added without user confirmation.
  • caching prevents redundant API calls within TTL.
  • graceful handling when GitHub token is revoked or API returns 401.

Difficulty

advanced — requires external API integration, token management, pattern matching, and caching layer.

Metadata

Metadata

Assignees

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions