Skip to main content

Frontend Overview

Modern React/Next.js frontend with TypeScript, Zustand state management, and real-time capabilities.

Tech Stack

TechnologyVersionPurpose
Next.js16.xReact framework with App Router
React19.xUI library
TypeScript5.9.xType safety
Zustand5.xClient state management
TanStack Query5.xServer state & caching
Tailwind CSS3.xStyling
Radix UI-Headless components
Socket.io4.xReal-time communication

Directory Structure

frontend/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── (auth)/ # Auth routes (login, register, etc.)
│ │ ├── (dashboard)/ # Protected dashboard routes
│ │ ├── layout.tsx # Root layout with providers
│ │ └── page.tsx # Landing page
│ ├── components/
│ │ ├── chat/ # Chat feature components
│ │ ├── layout/ # Layout components (sidebar, header)
│ │ ├── analytics/ # Analytics dashboard
│ │ ├── marketing/ # Public marketing components (pricing, etc.)
│ │ ├── providers/ # Context providers
│ │ ├── common/ # Shared components
│ │ └── ui/ # Radix UI components
│ ├── lib/
│ │ ├── api/ # API layer (Axios)
│ │ ├── stores/ # Zustand stores
│ │ ├── hooks/ # Custom React hooks
│ │ └── utils/ # Utility functions
│ ├── types/ # TypeScript definitions
│ └── tests/ # Unit tests
├── public/ # Static assets
└── package.json

Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│ Frontend Architecture │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Presentation Layer │ │
│ │ • React Components │ │
│ │ • Radix UI primitives │ │
│ │ • Tailwind styling │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ State Management │ │
│ │ • Zustand (auth, workspace, UI) │ │
│ │ • React Query (server state) │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Data Layer │ │
│ │ • API client (Axios) │ │
│ │ • WebSocket (Socket.io) │ │
│ │ • SSE (streaming) │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘

Route Structure

Public Routes

RouteFileDescription
/app/page.tsxLanding page (hero, features, how-it-works, pricing, CTA)
/pricingapp/pricing/page.tsxStandalone pricing page with plan comparison and FAQ
/contactapp/contact/page.tsxEnterprise sales contact page

Auth Routes (auth)/

RouteDescription
/loginUser login
/registerUser registration
/forgot-passwordPassword reset request
/reset-passwordPassword reset form
/verify-emailEmail verification

Dashboard Routes (dashboard)/

RouteDescriptionPermission
/assessmentsDORA third-party ICT risk assessmentsAll members
/questionnairesVendor security questionnaires + Export RoIAll members
/copilotDORA compliance AI copilot (Q&A)All members
/sourcesData sources hub (files, Confluence, URLs)Owner/Member
/conversationsConversation historyAll members
/analyticsUsage analyticsOwner/Member
/membersMember managementOwner only
/workspacesWorkspace managementAll members
/notificationsNotificationsAll members
/settingsUser settingsAll members
/chatRedirects to /copilot (backwards compat)

Provider Hierarchy

<ThemeProvider>           // Dark/light theme
<QueryProvider> // React Query client
<AuthProvider> // Session initialization
<SocketProvider> // WebSocket events
{children}
</SocketProvider>
</AuthProvider>
</QueryProvider>
</ThemeProvider>

Key Features

Real-Time Updates

  • WebSocket connection for live notifications
  • Conversation updates across sessions

Streaming Responses

  • Server-Sent Events for progressive AI responses
  • Timeout handling with graceful degradation
  • Source citations displayed with responses

Multi-Workspace Support

  • Workspace switcher in sidebar
  • Role-based navigation per workspace
  • Persistent workspace selection

Security

  • HTTP-only cookies for authentication
  • Content sanitization with DOMPurify
  • Permission guards on routes and components
  • Token refresh with exponential backoff

Configuration

Environment Variables

NEXT_PUBLIC_API_URL=http://localhost:3007/api/v1
NEXT_PUBLIC_SOCKET_URL=http://localhost:3007

API Client Configuration

// lib/api/client.ts
const apiClient = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_URL,
timeout: 30000,
withCredentials: true, // HTTP-only cookies
});

React Query Configuration

const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 60 * 1000, // 1 minute
retry: 1,
refetchOnWindowFocus: false,
},
},
});

Development

# Install dependencies
npm install

# Development server
npm run dev

# Type checking
npm run type-check

# Linting
npm run lint

# Unit tests
npm run test

Build

# Production build
npm run build

# Start production server
npm start