A modern React-based admin dashboard for managing Ownima platform users and beta testers.
- π Authentication - Secure login with JWT token management
- π₯ User Management - View and manage platform users with search and filtering
- π Dashboard Analytics - Overview of key metrics and statistics
- π¨ Modern UI - Built with Tailwind CSS and Headless UI components
- π± Responsive Design - Works seamlessly on desktop and mobile devices
- Frontend: React 18 with TypeScript
- Build Tool: Vite for fast development and optimized builds
- Styling: Tailwind CSS with Headless UI components
- State Management: TanStack Query for server state management
- Routing: React Router v6 for client-side routing
- HTTP Client: Axios with automatic token handling
- Form Handling: React Hook Form with Zod validation
- Icons: Heroicons for consistent iconography
- Node.js 18+ and npm
- Clone the repository:
git clone <repository-url>
cd ownima-admin- Install dependencies:
npm install-
Configure environment:
cp .env.example .env.local
- Edit
.env.localto set your environment (development, staging, beta, production) - The API base URL is automatically determined based on the environment
- See
.env.examplefor all available configuration options
- Edit
-
Start the development server:
npm run dev- Open http://localhost:5173 in your browser
npm run buildThe build artifacts will be stored in the dist/ directory.
src/
βββ components/ # Reusable UI components
β βββ layout/ # Layout components (Header, Sidebar, etc.)
β βββ ui/ # Base UI components (Button, LoadingSpinner, etc.)
βββ contexts/ # React contexts (AuthContext)
βββ hooks/ # Custom React hooks
βββ pages/ # Page components
βββ services/ # API service layer
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
- JWT-based authentication with automatic token refresh
- Protected routes that redirect to login when unauthenticated
- Persistent login state using localStorage
- Paginated user listings with search functionality
- Filter by user status (active/inactive)
- User profile display with role-based badges
- Key metrics overview cards
- Real-time data updates
The admin dashboard integrates with the Ownima backend API:
- Authentication: OAuth2 password flow
- Users: CRUD operations and user management
- Analytics: Statistics and metrics endpoints
The project has comprehensive test coverage using Vitest and React Testing Library.
# Run tests in watch mode
npm test
# Run tests once
npm run test:run
# Run tests with coverage
npm run test:coverage
# Run tests with UI
npm run test:uiCurrent test coverage:
- 564 tests across 24 test files
- 58.15% statement coverage
- 83.51% branch coverage
- 64.88% function coverage
Fully tested components:
- β Authentication (LoginPage, AuthContext, ProtectedRoute)
- β Dashboard (DashboardPage with metrics)
- β User Management (UsersPage)
- β UI Components (Button, Modal, Toast, MetricCard, LoadingSpinner, SkeletonLoader, EmptyState, ConfirmDialog)
- β Services (API client, auth, users, admin)
- β Hooks (useAuth, useToast)
- β App routing and providers
src/
βββ App.test.tsx
βββ components/
β βββ layout/
β β βββ Header.test.tsx
β β βββ Layout.test.tsx
β β βββ Sidebar.test.tsx
β βββ ui/
β β βββ Button.test.tsx
β β βββ ConfirmDialog.test.tsx
β β βββ EmptyState.test.tsx
β β βββ MetricCard.test.tsx
β β βββ Modal.test.tsx
β β βββ SkeletonLoader.test.tsx
β β βββ Toast.test.tsx
β βββ ProtectedRoute.test.tsx
βββ contexts/
β βββ AuthContext.test.tsx
βββ hooks/
β βββ useAuth.test.ts
β βββ useToast.test.ts
βββ pages/
β βββ DashboardPage.test.tsx
β βββ LandingPage.test.tsx
β βββ LoginPage.test.tsx
β βββ UsersPage.test.tsx
βββ services/
βββ admin.test.ts
βββ api.test.ts
βββ auth.test.ts
βββ users.test.ts
Follow these patterns when adding tests:
- Component Tests: Test user interactions and rendering
- Service Tests: Mock API calls and test data transformations
- Integration Tests: Test complete user flows
- Accessibility: Include accessibility checks in component tests
Example:
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { MyComponent } from './MyComponent'
describe('MyComponent', () => {
it('renders correctly', () => {
render(<MyComponent />)
expect(screen.getByText('Hello')).toBeInTheDocument()
})
it('handles user interaction', async () => {
const user = userEvent.setup()
render(<MyComponent />)
await user.click(screen.getByRole('button'))
expect(screen.getByText('Clicked')).toBeInTheDocument()
})
})The application supports multiple environments with automatic API endpoint detection:
- Development:
http://localhost:8000/api/v1(local backend) - Staging:
https://stage.ownima.com/api/v1 - Beta:
https://beta.ownima.com/api/v1(default) - Production:
https://api.ownima.com/api/v1
-
Copy the example environment file:
cp .env.example .env.local
-
Set your desired environment:
VITE_ENVIRONMENT=development # or staging, beta, production -
The API base URL is automatically determined based on:
- The
VITE_ENVIRONMENTvariable (if set) - The hostname (auto-detected in browser)
- Defaults to
betaif not specified
- The
Build for specific environments:
npm run build:development
npm run build:staging
npm run build:beta
npm run build:production- Follow the existing code style and patterns
- Use TypeScript for all new code
- Implement proper error handling and loading states
- Add appropriate type definitions
- Write tests for new features - aim for 80% coverage
- No console.log statements - use proper error handling with toasts
- Run linter and tests before committing:
npm run lint npm run test:run
This project is proprietary software for Ownima platform administration.