Skip to main content
The frontend uses a service-oriented architecture for API integration, authentication, and utility functions.

Services

portalService

File: services/portalService.ts Portal dashboard API integration:

Functions

fetchUpdates() Fetches portal updates from the API.
async function fetchUpdates(): Promise<PortalUpdate[]>
fetchGoals() Fetches project goals.
async function fetchGoals(): Promise<PortalGoal[]>
fetchToolLinks() Fetches quick-access tool links.
async function fetchToolLinks(): Promise<ToolLinkResponse>
searchPortal() Searches portal content.
async function searchPortal(query: string): Promise<SearchResult[]>
fetchStatus() Fetches portal status.
async function fetchStatus(): Promise<StatusResponse>
fetchLinearTasks() Fetches Linear tasks.
async function fetchLinearTasks(): Promise<LinearTask[]>
fetchNotionPages() Fetches Notion pages.
async function fetchNotionPages(): Promise<NotionPage[]>
fetchOrgMatrix() Fetches organization matrix.
async function fetchOrgMatrix(): Promise<OrgMatrixRow[]>
startSso() Initiates SSO authentication.
async function startSso(provider: string): Promise<void>

Mock Data

The service includes fallback mock data when the API is unreachable (e.g., local development).

authService

File: services/authService.ts Authentication service:
  • Login handling: Session management
  • Token storage: Secure token storage
  • GitHub OAuth: OAuth flow integration
  • Steganographic auth: Image-based authentication

pdfGenerator

File: services/pdfGenerator.ts PDF generation service:
  • Document generation: Create PDFs from data
  • Formatting: Structured PDF layout
  • Export: Download functionality
Uses jsPDF library for PDF generation.

API Integration

Base URL

Portal API base URL configuration:
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 
  'https://portal-api.metacogna.ai';

Error Handling

Services include error handling with fallbacks:
try {
  const response = await fetch(`${API_BASE_URL}/api/portal/updates`);
  if (!response.ok) throw new Error('Failed to fetch');
  return await response.json();
} catch (error) {
  console.error('API error:', error);
  // Return mock data as fallback
  return MOCK_UPDATES;
}

Type Definitions

Services use TypeScript types defined in types.ts:
  • PortalUpdate - Update entries
  • PortalGoal - Goal entries
  • UserRole - User role types
  • SearchResult - Search results
  • StatusResponse - Status information