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:Public Routes
Public Routes
/- Landing page (marketing, login button)
Protected Routes (Dashboard Group)
Protected Routes (Dashboard Group)
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)
- User clicks “Login with GitHub”
- Frontend redirects to
GET /auth/github(backend) - Backend redirects to
github.com/login/oauth/authorize - User authorizes app
- GitHub redirects to
GET /auth/github/callback(backend) - Backend exchanges code for token, creates user, sets JWT cookie
- Backend redirects to
${FRONTEND_URL}/dashboard
2. JWT Cookie Authentication
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
Query Caching Strategy
Query Caching Strategy
- 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
Sidebar
Design System
Nectr uses a custom design system built on TailwindCSS 4:Color Palette
Color Palette
Typography
Typography
- 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
Component Variants
Component Variants
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
Image Optimization
Image Optimization
- All images use Next.js
<Image>component - Automatic WebP conversion
- Lazy loading with
loading="lazy" - Priority loading for above-the-fold images
Code Splitting
Code Splitting
- Dynamic imports for heavy components
- Route-based code splitting (automatic)
'use client'only where necessary (most components are Server Components)
Query Optimizations
Query Optimizations
- 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