12 KiB
EDR Admin Portal (Backoffice)
Comprehensive admin portal for the Ethio-Djibouti Railway passenger management system. Built with Next.js 14, TypeScript, and Tailwind CSS with full dark mode support and EDR branding.
🚀 Enhanced Features
Complete Admin Module Coverage
- Overview - Dashboard with KPIs, revenue trends, and real-time metrics
- Operations - Bookings, Passengers, Tickets, Live Tracking, Agent Operations
- Master Data - Stations, Routes, Fleet Management, Schedules, Seat Classes
- Financial - Pricing & Fares, Payments, Wallet Management, Promotions
- Customer Services - Loyalty Program, Support Center, Notifications, Food & Dining
- Security & Compliance - Fraud Detection, Verifayda Integration, Audit Logs
- Analytics & Reports - Comprehensive reporting and operational analytics
- System - Settings and configuration management
UI/UX Enhancements
- EDR Branding - Official blue, orange, and red color scheme
- Dark Mode - Full dark mode support with theme persistence
- Collapsible Sidebar - Space-efficient navigation with categorized sections
- Responsive Design - Mobile-first approach with adaptive layouts
- Loading States - Skeleton loaders and async action feedback
- Interactive Components - Sortable tables, action buttons, modals
Technical Features
- Real API Integration - Connected to all EDR passenger API endpoints
- Functional CRUD Operations - Add, edit, delete with optimistic updates
- Advanced Data Tables - Sorting, filtering, pagination, bulk actions
- Form Validation - Client-side validation with error handling
- State Management - Zustand for auth and theme state
- Query Management - React Query for server state and caching
- Type Safety - Full TypeScript coverage with EDR domain types
📋 Prerequisites
- Node.js >= 20.x
- pnpm >= 9.x
- EDR Passenger API running on http://localhost:4000
🛠️ Installation
1. Install Dependencies
From the monorepo root:
pnpm install
Or from the backoffice directory:
cd apps/edr-passenger-web/backoffice
pnpm install
2. Environment Configuration
Copy the environment template:
cp .env.example .env.local
Edit .env.local:
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:4000
# IAM Configuration (Corporate Authentication)
NEXT_PUBLIC_IAM_ENABLED=false
NEXT_PUBLIC_IAM_API_URL=https://iam.tria-plc.com/api
3. Start Development Server
From the backoffice directory:
pnpm dev
Or from the monorepo root:
pnpm --filter @edr/passenger-backoffice run dev
The admin portal will be available at: http://localhost:3001
🔑 Login Credentials
Use these demo credentials to access the admin portal:
| Password | Role | |
|---|---|---|
| admin@edr-platform.com | admin123 | Admin |
Note: This is a stub authentication flow. TODO: Integrate with real backend auth endpoint.
📁 Enhanced Project Structure
backoffice/
├── src/
│ ├── app/ # Next.js App Router pages
│ │ ├── dashboard/ # Dashboard with KPIs
│ │ ├── bookings/ # Booking management
│ │ ├── passengers/ # Passenger management
│ │ ├── stations/ # Station master data
│ │ ├── routes/ # Route management
│ │ ├── fleet/ # Train & coach management
│ │ ├── schedules/ # Trip schedules
│ │ ├── seat-classes/ # Seat class configuration
│ │ ├── pricing/ # Fare rules & pricing
│ │ ├── payments/ # Payment management
│ │ ├── tickets/ # Ticket operations
│ │ ├── agents/ # Agent operations
│ │ ├── loyalty/ # Loyalty program
│ │ ├── wallet/ # Wallet management
│ │ ├── promotions/ # Promotion management
│ │ ├── support/ # Customer support
│ │ ├── notifications/ # Notification center
│ │ ├── fraud/ # Fraud detection
│ │ ├── verifayda/ # ID verification
│ │ ├── audit/ # Audit logs
│ │ ├── live/ # Live tracking
│ │ ├── food/ # Food & dining
│ │ ├── reports/ # Analytics & reports
│ │ ├── operational-reports/ # Operational reports
│ │ ├── settings/ # System settings
│ │ └── login/ # Authentication
│ ├── components/
│ │ ├── layout/ # Layout components
│ │ │ ├── Sidebar.tsx # Collapsible navigation
│ │ │ └── Header.tsx # Top header
│ │ ├── dashboard/ # Dashboard components
│ │ │ └── StatCard.tsx # KPI cards
│ │ └── ui/ # Enhanced UI components
│ │ ├── DataTable.tsx # Advanced data table
│ │ ├── ActionButton.tsx # Loading button
│ │ ├── Badge.tsx # Status badges
│ │ ├── Modal.tsx # Modal dialogs
│ │ └── Pagination.tsx # Pagination
│ ├── lib/
│ │ ├── api/ # Comprehensive API layer
│ │ │ ├── index.ts # All EDR API services
│ │ │ ├── bookings.ts # Booking operations
│ │ │ ├── passengers.ts # Passenger operations
│ │ │ ├── routes.ts # Route operations
│ │ │ └── dashboard.ts # Dashboard data
│ │ ├── api-client.ts # Axios client
│ │ ├── auth-store.ts # Authentication state
│ │ ├── theme-store.ts # Dark mode state
│ │ └── utils.ts # Utility functions
│ ├── types/
│ │ ├── index.ts # Main types
│ │ └── edr.ts # EDR domain types
│ └── styles/
│ └── globals.css # Enhanced styles with dark mode
├── .env.example # Environment template
├── .env.local # Local environment
├── next.config.js # Next.js configuration
├── tailwind.config.js # Enhanced Tailwind config
├── tsconfig.json # TypeScript configuration
└── package.json # Dependencies
🎨 EDR Design System
Color Palette
- Primary Blue: #2563eb (EDR Blue)
- Secondary Orange: #f97316 (EDR Orange)
- Accent Red: #ef4444 (EDR Red)
- Success: #10b981
- Warning: #f59e0b
- Danger: #ef4444
Components
Enhanced DataTable
<DataTable
data={items}
columns={[
{ key: 'name', label: 'Name', sortable: true },
{ key: 'status', label: 'Status', render: (item) => <Badge variant="status" status={item.status}>{item.status}</Badge> },
]}
actions={[
{ label: 'Edit', onClick: handleEdit, variant: 'secondary', icon: Edit },
{ label: 'Delete', onClick: handleDelete, variant: 'danger', icon: Trash2 },
]}
loading={isLoading}
/>
ActionButton with Loading
<ActionButton
onClick={handleSubmit}
variant="primary"
icon={Plus}
loading={mutation.isPending}
>
Create Item
</ActionButton>
🔌 Complete API Integration
Available Services
stationsApi- Station CRUD operationsfleetApi- Train and coach managementschedulesApi- Trip schedule operationsseatsApi- Seat management and blockingbookingsApi- Booking lifecycle managementpassengersApi- Passenger operationspaymentsApi- Payment processingticketsApi- Ticket operationsagentsApi- Agent managementloyaltyApi- Loyalty programwalletApi- Wallet operationspromotionsApi- Promotion managementsupportApi- Customer supportnotificationsApi- Notification systemfraudApi- Fraud detectionverifaydaApi- ID verificationauditApi- Audit loggingliveApi- Live trackingseatClassesApi- Seat class managementfoodApi- Food & dining
Real Data Integration
All components use real API endpoints:
const { data, isLoading } = useQuery({
queryKey: ['stations', filters],
queryFn: () => stationsApi.getAll(filters),
});
const createMutation = useMutation({
mutationFn: stationsApi.create,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['stations'] });
setShowModal(false);
},
});
🌙 Dark Mode Support
Full dark mode implementation with:
- System preference detection
- Manual toggle in sidebar
- Persistent theme storage
- Semantic color variables
- Smooth transitions
📱 Responsive Design
- Mobile-first approach
- Collapsible sidebar on mobile
- Adaptive table layouts
- Touch-friendly interactions
- Responsive grid systems
🔐 Enhanced Security
- JWT token management
- Automatic token refresh
- Role-based access control
- Audit trail logging
- Fraud detection integration
🚀 Performance Optimizations
- React Query caching
- Optimistic updates
- Lazy loading
- Code splitting
- Image optimization
📊 Advanced Features
Functional CRUD Operations
- Create, Read, Update, Delete for all entities
- Form validation and error handling
- Optimistic UI updates
- Bulk operations support
Data Management
- Advanced filtering and search
- Sortable columns
- Pagination with page size options
- Export functionality
- Real-time updates
User Experience
- Loading states and skeletons
- Toast notifications
- Confirmation dialogs
- Keyboard shortcuts
- Accessibility compliance
🎯 Available Scripts
# Development
pnpm dev # Start dev server on port 3001
# Build
pnpm build # Build for production
# Production
pnpm start # Start production server
# Linting
pnpm lint # Run ESLint
# Type Checking
pnpm type-check # Run TypeScript compiler
🚀 Deployment
Build for Production
pnpm build
Start Production Server
pnpm start
Environment Variables for Production
Ensure these are set in production:
NEXT_PUBLIC_API_URL- Backend API URLNEXT_PUBLIC_IAM_ENABLED- Enable IAM authenticationNEXT_PUBLIC_IAM_API_URL- Corporate IAM API URL
📝 Development Notes
Adding New Pages
- Create directory in
src/app/ - Add
page.tsxandlayout.tsx - Update sidebar navigation
- Create API service if needed
- Add types to
src/types/edr.ts
API Integration
- Add service to
src/lib/api/index.ts - Create types in
src/types/edr.ts - Use React Query hooks in components
- Handle loading and error states
🔧 Customization
Theme Customization
Update tailwind.config.js for custom colors:
theme: {
extend: {
colors: {
edr: {
blue: { /* custom blue shades */ },
orange: { /* custom orange shades */ },
red: { /* custom red shades */ },
},
},
},
}
Component Styling
Use semantic color classes:
<div className="bg-card text-card-foreground border-border">
<h1 className="text-foreground">Title</h1>
<p className="text-muted-foreground">Description</p>
</div>
📝 TODO
- Integrate with real backend authentication endpoint
- Implement IAM authentication for back-office users
- Add real-time WebSocket connections for live updates
- Implement advanced reporting with chart exports
- Add bulk operations for data management
- Implement advanced search with filters
- Add keyboard shortcuts for power users
- Implement role-based UI permissions
- Add comprehensive error boundary handling
- Implement offline support with service workers
🤝 Contributing
- Create a feature branch
- Follow the established patterns
- Add proper TypeScript types
- Test thoroughly
- Submit a pull request
📧 Support
For technical support or questions:
- Email: support@edr-platform.com
- Backend API Docs: http://localhost:4000/api-docs
Built with ❤️ for Ethio-Djibouti Railway