How npjigak/twitch-follower-checker works
Project type and purpose
• This is a client-centric, multi-language, static/SSR web application built with Next.js and MDX for localized content.
• Its core feature is a browser-based interface that authenticates a streamer via OAuth, polls the Twitch API for follower changes, and displays new followers and unfollowers in real time.
File structure
• pages/ – Next.js routing for static and dynamic content, organized by locale (e.g., pages/en, pages/ja), plus MDX files for documentation pages.
• components/ – React UI pieces (AppContainer, AuthenticateWithTwitch, RefreshListsButton, etc.).
• lib/ – Utility modules:
• accessTwitch.ts – wrapper for Twitch HTTP API calls
• countdownWorker.ts – a Web Worker for countdown timers
• gtm.ts – Google Tag Manager integration
• debugLogger.ts, constants.ts, navigateToUserLocalePage.tsx
• next.config.mjs, postcss.config.js, tailwind.config.ts – build and styling configuration.
• .github/workflows/ – CI/CD pipelines: Next.js build/deploy, IndexNow sitemap updates.
• public/ – static assets (if any) served by Next.js.
README for additional insights
• It confirms the user-facing purpose (tracking followers/unfollowers) and points to multi-locale documentation.
• No backend microservice; all dynamic logic runs in the browser or at build time (SSG/ISR).
Main architectural components (to represent
A. End User (Browser)
• Interacts with the Next.js React SPA/SSR pages.
• Hosts the Web Worker for countdowns.
B. Next.js Framework / Hosting
• SSR/SSG server (Vercel, Netlify or similar CDN).
• Serves static HTML, JS bundles, generated MDX content.
• Runs getStaticProps / getServerSideProps at build or request time (if used).
C. CI/CD Pipeline
• GitHub Actions workflows triggered on push.
• Runs linting, builds the Next.js app, generates sitemap, and deploys to hosting.
D. External Services
• Twitch API (OAuth2 token acquisition + follower data endpoints).
• Google Tag Manager (for analytics).
• IndexNow (for sitemap submission).
Relationships and data flows
1. User navigates to the site (DNS → CDN → Next.js app).
2. AppContainer loads, picks correct locale, and renders MDX pages + React UI.
3. User clicks “Authenticate with Twitch” → OAuth popup → Twitch Authorization Server → redirect with token.
4. accessTwitch module uses the token to call Twitch’s follower endpoints periodically (polling or via countdownWorker).
5. Data is displayed in the UI; debugLogger writes to console if enabled.
6. gtm module fires analytics events.
Architectural patterns & principles
• Client-centric rendering with optional SSR/SSG for SEO and multi-locale docs.
• Separation of concerns:
• UI components in components/
• API integration in lib/
• Configuration in root config files.
• CD pipeline for automated builds, tests, sitemap updates, and deployment.