Skip to main content

Technology Stack

The frontend is built with modern React and Next.js:
  • Next.js 15 (App Router)
  • React 19 (with React Server Components)
  • TypeScript (strict mode)
  • TailwindCSS 4 (with custom design system)
  • TanStack Query (React Query v5) for data fetching
  • Axios for HTTP client
  • React Hot Toast for notifications

Project Structure

Routing (App Router)

Next.js 15 uses the App Router with file-system based routing:
  • / - Landing page (marketing, login button)
All routes under app/(dashboard)/ require authentication:
  • /dashboard - Overview metrics + top contributors sparklines
  • /reviews - PR review history table
  • /reviews/[id] - Individual review detail
  • /analytics - Team metrics, timeline, insights
  • /repos - Connect/disconnect repositories
  • /team - Team member management
  • /settings - Account settings
  • /api-keys - API key management

Authentication Flow

1. GitHub OAuth (Server-Side)

Flow:
  1. User clicks “Login with GitHub”
  2. Frontend redirects to GET /auth/github (backend)
  3. Backend redirects to github.com/login/oauth/authorize
  4. User authorizes app
  5. GitHub redirects to GET /auth/github/callback (backend)
  6. Backend exchanges code for token, creates user, sets JWT cookie
  7. Backend redirects to ${FRONTEND_URL}/dashboard
withCredentials: true is critical. Without it, the browser won’t send the httpOnly JWT cookie to the backend.

3. Protected Route Guard

All dashboard routes use this guard via the (dashboard)/layout.tsx wrapper.

Data Fetching with TanStack Query

All API calls use React Query for caching, background refetching, and optimistic updates.

Example: Fetch Repositories

Example: Use in Component

  • Stale time: 30 seconds (data is considered fresh)
  • Cache time: 5 minutes (inactive queries remain in cache)
  • Refetch on window focus: Enabled (keeps data fresh)
  • Retry: 1 attempt on failure

Layout Components

AppLayout

Design System

Nectr uses a custom design system built on TailwindCSS 4:
  • Font: Geist Sans (default), Geist Mono (code)
  • Headings: font-bold, text-content-primary
  • Body: text-sm, text-content-secondary
  • Labels: text-xs, uppercase, tracking-wide
All UI components follow shadcn/ui patterns:
  • Button: default, secondary, outline, ghost, danger
  • Badge: default, success, warning, danger
  • Card: Elevated background with border

State Management

Nectr uses React Context for global state and TanStack Query for server state.

AuthContext

Error Handling

API Error Interceptor

Toast Notifications

Performance Optimizations

  • All images use Next.js <Image> component
  • Automatic WebP conversion
  • Lazy loading with loading="lazy"
  • Priority loading for above-the-fold images
  • Dynamic imports for heavy components
  • Route-based code splitting (automatic)
  • 'use client' only where necessary (most components are Server Components)
  • Background refetching keeps data fresh
  • Prefetching on hover for navigation links
  • Optimistic updates for mutations

Next Steps

Data Flow

See how data flows from user action to UI update

Backend Architecture

Learn about the FastAPI backend