AnthoLume Frontend
A React + TypeScript frontend for AnthoLume, replacing the server-side rendering (SSR) templates.
Tech Stack
- React 19 - UI framework
- TypeScript - Type safety
- React Query (TanStack Query) - Server state management
- Orval - API client generation from OpenAPI spec
- React Router - Navigation
- Tailwind CSS - Styling
- Vite - Build tool
- Axios - HTTP client with auth interceptors
Authentication
The frontend includes a complete authentication system:
Auth Context
AuthProvider- Manages authentication state globallyuseAuth()- Hook to access auth state and methods- Token stored in
localStorage - Axios interceptors automatically attach Bearer token to API requests
Protected Routes
- All main routes are wrapped in
ProtectedRoute - Unauthenticated users are redirected to
/login - Layout redirects to login if not authenticated
Login Flow
- User enters credentials on
/login - POST to
/api/v1/auth/login - Token stored in localStorage
- Redirect to home page
- Axios interceptor includes token in subsequent requests
Logout Flow
- User clicks "Logout" in dropdown menu
- POST to
/api/v1/auth/logout - Token cleared from localStorage
- Redirect to
/login
401 Handling
- Axios response interceptor clears token on 401 errors
- Prevents stale auth state
Architecture
The frontend mirrors the existing SSR templates structure:
Pages
HomePage- Landing page with recent documentsDocumentsPage- Document listing with search and paginationDocumentPage- Single document view with detailsProgressPage- Reading progress tableActivityPage- User activity logSearchPage- Search interfaceSettingsPage- User settingsLoginPage- Authentication
Components
Layout- Main layout with navigation sidebar and header- Generated API hooks from
api/v1/openapi.yaml
API Integration
The frontend uses Orval to generate TypeScript types and React Query hooks from the OpenAPI spec:
npm run generate:api
This generates:
- Type definitions for all API schemas
- React Query hooks (
useGetDocuments,useGetDocument, etc.) - Mutation hooks (
useLogin,useLogout)
Development
# Install dependencies
npm install
# Generate API types (if OpenAPI spec changes)
npm run generate:api
# Start development server
npm run dev
# Build for production
npm run build
Deployment
The built output is in dist/ and can be served by the Go backend or deployed separately.
Migration from SSR
The frontend replicates the functionality of the following SSR templates:
templates/pages/home.tmpl→HomePage.tsxtemplates/pages/documents.tmpl→DocumentsPage.tsxtemplates/pages/document.tmpl→DocumentPage.tsxtemplates/pages/progress.tmpl→ProgressPage.tsxtemplates/pages/activity.tmpl→ActivityPage.tsxtemplates/pages/search.tmpl→SearchPage.tsxtemplates/pages/settings.tmpl→SettingsPage.tsxtemplates/pages/login.tmpl→LoginPage.tsx
The styling follows the same Tailwind CSS classes as the original templates for consistency.