TalentSync

AI resume builder and ATS optimizer for job seekers. Tailored resumes, outreach, and interview prep from one profile.

Frontend architecture

The frontend architecture of the Next.js application.

Repository layout#

The frontend follows Next.js app router conventions with a strict file-system-based routing and a layered provider pattern. The root layout composes a global stylesheet, fonts, and a Providers wrapper that exposes session and query client contexts. Pages under app define the top-level routes, while reusable UI components live under components. Services encapsulate API communication, and utilities centralize shared logic.

Building blocks#

  • Root layout: Defines metadata, fonts, PWA manifest, and wraps children with Providers and LayoutContent.
  • Providers: FastAPI SessionProvider plus React Query with caching and retry policies.
  • Layout content: Renders Navbar, main content area with dynamic sidebar padding, and global Toaster.
  • Global styles: Tailwind base/components/utilities plus CSS variables for theme tokens and responsive utilities.
  • Navigation: Typed navigation items and icons for desktop and mobile layouts.
  • UI primitives: Radix UI-based components (e.g., Button) with Tailwind variants and class variance authority.

How it fits together#

The application uses a layered provider pattern:

  • Authentication: session-provider.tsx talks to /api/v1/auth/me. Server uses getSession().
  • Data fetching: React Query manages server state, caching, retries, and background refetch policies.
  • UI: Tailwind CSS and Radix UI components form a cohesive design system with theme tokens and animations.
  • Routing: App router pages and nested groups organize feature areas and API routes.

Provider pattern: authentication and data fetching#

The Providers component initializes:

  • SessionProvider for FastAPI cookies, enabling client-side session reads and /me refresh.
  • QueryClient with a defaultOptions configuration:
  • Stale time of 1 minute.
  • Retry attempts set to 2.
  • Disables refetch on window focus to reduce unnecessary network activity.

Authentication: FastAPI cookies and getSession#

NextAuth is gone. Sign-in is Google on FastAPI.

  • getSession() in lib/session.ts verifies ts_access_token and loads Prisma User.
  • SessionProvider GETs /api/v1/auth/me and POSTs /api/v1/auth/refresh.
  • signIn("google") navigates to /api/v1/auth/oauth/google.
  • Role lives on User.role. First OAuth login may set roleSelectionRequired.

Data fetching: React query defaults and devtools#

React Query is configured :

  • StaleTime: 1 minute to balance freshness and performance.
  • Retry: Up to two attempts on failure.
  • RefetchOnWindowFocus: Disabled to avoid excessive background refetches.
  • Devtools: Conditionally enabled in development.

API client: request abstraction and error handling#

The apiClient module is a typed HTTP client:

  • Methods: get, post, put, patch, delete.
  • Automatic query string building and JSON serialization for non-FormData bodies.
  • Unified error handling:
  • Parses error messages from response data (message, detail, error).
  • Throws ApiError with status and parsed message.
  • Wraps network errors into ApiError with status 500.

UI framework: tailwind CSS and radix UI#

  • Tailwind configuration:
  • Dark mode via class strategy.
  • Theme extension with semantic color tokens, brand colors, and animations.
  • Font families bound to CSS variables from next/font/google.
  • Radix UI primitives:
  • Button component uses class-variance-authority for variants and sizes.
  • Consistent design tokens and motion through Tailwind classes.
  • Navigation items and icons are centralized for desktop and mobile views.
  • LayoutContent manages sidebar collapse state and adjusts main content padding responsively.
  • Global styles define theme tokens and responsive utilities for safe areas and mobile navigation spacing.

Shared utilities and services#

  • Prisma client initialization with global singleton pattern for development isolation.
  • Toast manager with reducer-based state, timeouts, and dismissal logic for user feedback.

Dependencies#

Key external dependencies and integrations:

  • next-pwa: Enables PWA features with service worker registration and skipWaiting.
  • next.config.js: Image optimization settings, webpack fixes for PostHog, and rewrites for analytics.
  • next-font-google: Font variables injected into CSS variables for Tailwind usage.
  • jose + session.ts: verify FastAPI access JWT. No next-auth package.
  • @tanstack/react-query: Centralized caching and retry logic for API data.
  • Tailwind CSS: Utility-first CSS with theme tokens and animations.
  • Radix UI: Accessible UI primitives integrated with Tailwind variants.

Performance#

  • React Query defaults:
  • StaleTime reduces redundant network calls.
  • Retry improves resilience without manual intervention.
  • Disabling refetchOnWindowFocus minimizes background traffic.
  • PWA:
  • Service worker registration and skipWaiting improve offline readiness and update behavior.
  • Image optimization:
  • Remote patterns for trusted avatars; unoptimized images to avoid extra processing overhead.
  • Webpack fixes:
  • Aliases and replacements prevent PostHog Node APIs from bundling in the browser.
  • Tailwind:
  • CSS variables and theme tokens enable efficient runtime switching and minimal CSS output.
  • Build configuration:
  • Bundler module resolution and incremental compilation optimize rebuild times.

[No sources needed since this section provides general guidance]

Troubleshooting#

  • Authentication:
  • Set BACKEND_JWT_SECRET to the backend JWT_SECRET.
  • Set Google client id/secret and redirect URI.
  • Confirm User row exists for the JWT sub.
  • API client:
  • Inspect ApiError thrown on non-OK responses; review message/detail/error fields.
  • Confirm request body serialization and Content-Type handling for FormData vs JSON.
  • React Query:
  • Adjust staleTime/retry based on data volatility.
  • Use ReactQueryDevtools to inspect cache state and refetch triggers.
  • Navigation and layout:
  • Validate navigation items and icons; ensure responsive padding adapts to sidebar collapse.
  • Styling:
  • Confirm Tailwind content globs include all component paths.
  • Verify CSS variables for theme tokens are present in :root and .dark.