Synkronus Portal Reference
Complete technical reference for the Synkronus Portal web interface.
Overview
Synkronus Portal is a web-based administrative interface for managing Synkronus server operations. It provides a user-friendly interface for app bundle management, user administration, observation viewing, and data export. The portal is built with React, TypeScript, and Vite.
Architecture
Technology Stack
- Framework: React 19.2.0
- Language: TypeScript
- Build Tool: Vite 7.2.4
- State Management: React Context API
- HTTP Client: Fetch API with custom wrapper
- Styling: CSS (with ODE design tokens)
Project Structure
synkronus-portal/
├── src/
│ ├── main.tsx # Application entry point
│ ├── App.tsx # Root component
│ ├── types/
│ │ └── auth.ts # TypeScript interfaces
│ ├── services/
│ │ └── api.ts # HTTP client
│ ├── contexts/
│ │ └── AuthContext.tsx # Authentication state
│ ├── components/
│ │ ├── Login.tsx # Login component
│ │ └── ProtectedRoute.tsx # Route protection
│ └── pages/
│ └── Dashboard.tsx # Main dashboard
├── index.html # HTML entry point
└─ ─ vite.config.ts # Vite configuration
Core Features
Authentication
- JWT-based Auth: Secure token authentication
- Token Refresh: Automatic token refresh
- Session Management: Persistent login sessions
- Protected Routes: Route-level access control
App Bundle Management
- View Versions: List all app bundle versions
- Upload Bundles: Upload new app bundles
- Switch Versions: Activate specific bundle versions
- Download Bundles: Download bundle files
- Version History: View version history
User Management
- List Users: View all users
- Create Users: Add new users
- Edit Users: Update user information
- Delete Users: Remove users
- Role Management: Assign user roles
Observation Management
- View Observations: Browse collected observations
- Filter Observations: Filter by form type, date, etc.
- Search: Search observations
- Export: Export observations in various formats
Data Export
- Parquet Export: Export as Parquet ZIP
- JSON Export: Export as JSON
- CSV Export: Export as CSV
- Filtered Export: Export filtered data
User Interface
Dashboard
The main dashboard provides:
- Overview Statistics: Total observations, users, bundles
- Recent Activity: Latest observations and changes
- Quick Actions: Common administrative tasks
- System Status: Server health and status
Navigation
- Sidebar Navigation: Access to all sections
- Breadcrumbs: Current location indicator
- User Menu: User profile and logout
- Notifications: System notifications
API Integration
API Service
The portal uses a centralized API service:
import { api } from './services/api'
// Login
await api.login(username, password)
// Get data
const users = await api.get('/users')
// Post data
await api.post('/users/create', userData)
Authentication Flow
- User enters credentials
- Portal sends login request to
/auth/login - Server returns JWT token
- Token stored in localStorage
- Token included in all subsequent requests
Error Handling
The API service handles errors:
- Network Errors: Connection failures
- 401 Unauthorized: Invalid credentials
- 500+ Errors: Server errors
- API Errors: Structured error responses
Configuration
Development Mode
Vite Dev Server:
- Port: 5174
- Hot Module Replacement: Enabled
- Proxy:
/api/*→http://localhost:8080/*
Start Development:
npm run dev
Production Mode
Nginx Serving:
- Port: 80 (exposed as 5173)
- Static files from
/usr/share/nginx/html - API proxy:
/api/*→http://synkronus:8080/*
Build for Production:
npm run build
Environment Variables
VITE_API_URL: Override API base URL (optional)DOCKER_ENV: Set totruein Docker (optional)
Deployment
Docker Deployment
The portal can be deployed with Docker:
docker compose up -d
Docker Compose Services:
synkronus-portal: Frontend portalsynkronus: Backend APIpostgres: Database
Standalone Deployment
Build and serve with any static file server:
npm run build
# Serve dist/ directory
Development
Local Development Setup
-
Install Dependencies:
npm install -
Start Backend:
# In synkronus directory go run cmd/synkronus/main.go -
Start Portal:
npm run dev -
Access Portal:
Adding New Features
Add API Endpoint
-
Add TypeScript Types:
// src/types/feature.ts export interface FeatureRequest { field: string } -
Add API Method:
// src/services/api.ts async getFeature(id: string): Promise<FeatureResponse> { return this.get<FeatureResponse>(`/feature/${id}`) } -
Use in Component:
const data = await api.getFeature('123')
Add New Page
-
Create Component:
// src/pages/NewPage.tsx export function NewPage() { return <div>New Page</div> } -
Add to App.tsx:
<ProtectedRoute> <NewPage /> </ProtectedRoute>
Authentication Context
AuthContext Usage
import { useAuth } from './contexts/AuthContext'
function MyComponent() {
const { user, isAuthenticated, login, logout } = useAuth()
if (!isAuthenticated) {
return <Login />
}
return <div>Welcome, {user?.username}</div>
}
AuthContext Methods
login(credentials): Authenticate userlogout(): Clear authenticationrefreshAuth(): Refresh expired tokens
Styling
Design Tokens
The portal uses ODE design tokens:
- Primary Color: Green (#4F7F4E)
- Secondary Color: Gold (#E9B85B)
- Typography: Noto Sans
- Spacing: Consistent spacing scale
CSS Structure
- Global Styles:
src/index.css - Component Styles: Component-specific CSS files
- No Framework: Plain CSS (can extend with CSS modules)
Best Practices
Code Organization
- Types First: Define TypeScript types
- API Service: Centralize API calls
- Context for State: Use Context for global state
- Component Separation: Separate components and pages
Error Handling
- Try-Catch Blocks: Wrap API calls
- User-Friendly Messages: Show clear error messages
- Error Logging: Log errors for debugging
- Graceful Degradation: Handle errors gracefully
Performance
- Code Splitting: Lazy load components
- Memoization: Memoize expensive computations
- Optimistic Updates: Update UI before server response
- Debouncing: Debounce search and filter inputs
Troubleshooting
Common Issues
Portal Won't Load:
- Check backend is running
- Verify API URL configuration
- Check browser console for errors
Authentication Fails:
- Verify credentials
- Check JWT_SECRET on server
- Clear localStorage and retry
API Calls Fail:
- Check network connectivity
- Verify CORS configuration
- Check server logs
Related Documentation
- Synkronus Server Reference - Backend API
- Deployment Guide - Production deployment
- Configuration Guide - Configuration options
- API Reference - Complete API documentation