A modern bug bounty platform interface built with React, TypeScript, and Tailwind CSS.
# Navigate to frontend
cd bugkhoji-frontend
# Install dependencies
npm install
# Start development server
npm run devApplication runs on http://localhost:8080 (or next available port)
- Node.js 16+
- npm or yarn
- BugKhoji Backend running on port 4001
npm installCreate .env file:
VITE_API_BASE_URL=http://localhost:4001
VITE_APP_NAME=BugKhoji
VITE_APP_VERSION=1.0.0npm run devThe app will open at http://localhost:8080 or show the port in terminal.
- User registration (Researcher/Organizer)
- Secure login with JWT
- Password reset
- Session management
- Auto token refresh
- View all bug bounty programs
- Submit vulnerability reports
- Track report status
- View rewards and earnings
- Real-time notifications
- Personal leaderboard ranking
- Create and manage programs
- Review submitted reports
- Award bounties
- Manage program participants
- View analytics
- Process rewards
- User management
- System analytics
- Program oversight
- Report moderation
- User ban/unban
- Platform statistics
- Global researcher rankings
- Program-specific leaderboards
- Time-based filters (all-time, monthly, weekly)
- Personal rank tracking
- View earning history
- Track pending rewards
- Payment status
- Transaction details
- Real-time updates
- Report status changes
- Reward notifications
- System announcements
- Mark as read
- Unread count badge
/ β Landing page
/login β Login page
/register β Registration page
/forgot-password β Password reset
/dashboard β Researcher dashboard
/programs β Browse programs
/programs/:id β Program details
/reports β My reports
/reports/new β Submit report
/rewards β My rewards
/leaderboard β Rankings
/profile β Profile settings
/notifications β Notifications
/organizer/dashboard β Organizer dashboard
/organizer/programs β Manage programs
/organizer/reports β Review reports
/organizer/rewards β Manage rewards
/organizer/analytics β Program analytics
/admin/dashboard β Admin dashboard
/admin/users β User management
/admin/programs β Program oversight
/admin/reports β Report moderation
/admin/analytics β System analytics
// Login
const response = await fetch('http://localhost:4001/v1/login/researcher', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
const { token, refreshToken } = await response.json();
localStorage.setItem('token', token);// Fetch with auth token
const response = await fetch('http://localhost:4001/api/v1/programs', {
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
});// services/api.ts
const API_BASE = import.meta.env.VITE_API_BASE_URL;
export const api = {
// Auth
login: (credentials) => post('/v1/login/researcher', credentials),
register: (data) => post('/v1/register/researcher', data),
// Programs
getPrograms: () => get('/api/v1/programs'),
getProgram: (id) => get(`/api/v1/programs/${id}`),
// Reports
submitReport: (data) => post('/api/v1/reports', data),
getMyReports: () => get('/api/v1/researcher/reports'),
// Leaderboard
getLeaderboard: () => get('/user/leaderboard'),
getMyRank: () => get('/user/leaderboard/my-rank'),
// Rewards
getRewards: () => get('/api/v1/researcher/rewards'),
// Notifications
getNotifications: () => get('/notifications'),
markAsRead: (id) => patch(`/notifications/${id}/read`),
};src/
βββ components/
β βββ common/
β β βββ Button.tsx
β β βββ Input.tsx
β β βββ Modal.tsx
β β βββ Card.tsx
β β βββ Badge.tsx
β βββ layout/
β β βββ Header.tsx
β β βββ Sidebar.tsx
β β βββ Footer.tsx
β β βββ Layout.tsx
β βββ auth/
β β βββ LoginForm.tsx
β β βββ RegisterForm.tsx
β β βββ ProtectedRoute.tsx
β βββ dashboard/
β β βββ StatsCard.tsx
β β βββ RecentReports.tsx
β β βββ ProgramList.tsx
β βββ programs/
β β βββ ProgramCard.tsx
β β βββ ProgramDetails.tsx
β β βββ ProgramForm.tsx
β βββ reports/
β β βββ ReportCard.tsx
β β βββ ReportForm.tsx
β β βββ ReportDetails.tsx
β βββ leaderboard/
β β βββ LeaderboardTable.tsx
β β βββ RankBadge.tsx
β β βββ UserStats.tsx
β βββ notifications/
β βββ NotificationBell.tsx
β βββ NotificationList.tsx
β βββ NotificationItem.tsx
βββ pages/
β βββ HomePage.tsx
β βββ LoginPage.tsx
β βββ DashboardPage.tsx
β βββ ProgramsPage.tsx
β βββ ReportsPage.tsx
β βββ LeaderboardPage.tsx
β βββ AdminPage.tsx
βββ services/
β βββ api.ts
β βββ auth.ts
β βββ storage.ts
βββ hooks/
β βββ useAuth.ts
β βββ usePrograms.ts
β βββ useReports.ts
β βββ useNotifications.ts
βββ contexts/
β βββ AuthContext.tsx
β βββ ThemeContext.tsx
βββ utils/
β βββ formatters.ts
β βββ validators.ts
β βββ constants.ts
βββ types/
β βββ user.ts
β βββ program.ts
β βββ report.ts
βββ App.tsx
βββ main.tsx
// tailwind.config.js
module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#10B981',
danger: '#EF4444',
warning: '#F59E0B',
}
}
}
}/* src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
.btn-primary {
@apply bg-primary text-white px-4 py-2 rounded hover:bg-primary-dark;
}
.card {
@apply bg-white shadow-md rounded-lg p-6;
}
}// contexts/AuthContext.tsx
interface AuthContextType {
user: User | null;
token: string | null;
login: (email: string, password: string) => Promise<void>;
logout: () => void;
isAuthenticated: boolean;
isLoading: boolean;
}
// Usage in components
const { user, isAuthenticated, login, logout } = useAuth();- AuthContext - User authentication
- ThemeContext - Dark/light mode
- NotificationContext - Real-time notifications
// store/index.ts
export const useStore = create((set) => ({
programs: [],
reports: [],
setPrograms: (programs) => set({ programs }),
addReport: (report) => set((state) => ({
reports: [...state.reports, report]
})),
}));# Unit tests
npm test
# E2E tests
npm run test:e2e
# Coverage
npm run test:coverageimport { render, screen } from '@testing-library/react';
import { LoginForm } from './LoginForm';
test('renders login form', () => {
render(<LoginForm />);
expect(screen.getByText('Login')).toBeInTheDocument();
});npm run devnpm run buildnpm run previewvercelnetlify deploy --prodProblem: Cannot connect to backend
# Check backend is running
curl http://localhost:4001/api/health
# Verify CORS settings in backend
# Check .env VITE_API_BASE_URLSolution: Ensure backend is running on port 4001
Problem: TypeScript errors
# Clear node_modules
rm -rf node_modules
npm install
# Clear cache
rm -rf dist
npm run build# Restart dev server
npm run dev
# Clear browser cache
# Ctrl + Shift + R (hard refresh)# Kill process on port 8080
lsof -i :8080
kill -9 <PID>
# Or use different port
npm run dev -- --port 3000{
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.20.0",
"axios": "^1.6.0",
"tailwindcss": "^3.3.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.2.0",
"typescript": "^5.3.0",
"vite": "^5.0.0"
}
}// Lazy load routes
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Programs = lazy(() => import('./pages/Programs'));// Use WebP format
<img src="image.webp" alt="..." loading="lazy" />// Cache API responses
const cachedPrograms = localStorage.getItem('programs');
if (cachedPrograms && !isStale) {
return JSON.parse(cachedPrograms);
}sm: 640px β Mobile
md: 768px β Tablet
lg: 1024px β Desktop
xl: 1280px β Large Desktop
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{/* Responsive grid */}
</div>- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
- β User authentication
- β Program browsing
- β Report submission
- β Leaderboard
- β Rewards tracking
- β Notifications
- β Admin panel
- β Responsive design
- β Dark mode ready
- β Error handling
- Token Storage: Store JWT in httpOnly cookies (recommended) or localStorage
- CSRF Protection: Use CSRF tokens for state-changing operations
- XSS Prevention: Sanitize user inputs, use React's built-in escaping
- HTTPS: Always use HTTPS in production
- Content Security Policy: Configure CSP headers
For issues:
- Check backend is running
- Verify API endpoints
- Check browser console
- Review network tab
- Clear cache and try again
npm run dev # Start dev server
npm run build # Build for production
npm run preview # Preview production build
npm test # Run tests
npm run lint # Lint code
npm run format # Format code with Prettier
npm run type-check # TypeScript type checkingColors, typography, and component patterns are documented in src/styles/design-system.md
MIT License - See LICENSE file
Built with β€οΈ for BugKhoji Platform
Need help? Check the backend README for API documentation.