A comprehensive full-stack web application for store rating management with role-based access control.
- Dashboard with comprehensive statistics
- User management (create, view, filter, sort)
- Store management (create, view, filter, sort)
- Role-based access control
- Password management
- User registration and authentication
- Browse and search stores
- Submit and modify store ratings (1-5 stars)
- View personal ratings and store statistics
- Password management
- Dedicated dashboard
- View store's average rating
- See all users who rated their store
- Track rating history
- Password management
- Framework: Express.js
- Database: MySQL
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcryptjs
- Validation: express-validator
- CORS: cors middleware
- Framework: React 18 with TypeScript
- Styling: Tailwind CSS
- Routing: React Router DOM
- Forms: React Hook Form with Yup validation
- HTTP Client: Axios
- Icons: Lucide React
- Notifications: React Hot Toast
- β Name: 20-60 characters
- β Address: Max 400 characters
- β Password: 8-16 characters, uppercase + special character
- β Email: Standard email validation
- β Proper schema design with relationships
- β Sorting support for all key fields
- β Search and filter functionality
- β Data integrity with foreign keys
- β JWT-based authentication
- β Role-based authorization
- β Password hashing
- β Input validation and sanitization
- Node.js (v16 or higher)
- MySQL (v8.0 or higher)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd roxiler-store-rating
-
Install dependencies
npm install
-
Database Setup
- Create a MySQL database named
roxiler_store_rating - Update database credentials in
.envfile
- Create a MySQL database named
-
Environment Configuration
# Copy and configure environment variables cp .env.example .envUpdate
.envwith your configuration:DB_HOST=localhost DB_USER=root DB_PASSWORD=your_password DB_NAME=roxiler_store_rating JWT_SECRET=your-super-secret-jwt-key JWT_EXPIRES_IN=7d PORT=5000
You can configure the frontend to use a specific backend API base URL by setting the Vite environment variable
VITE_API_BASE_URLin your.envfile at the project root. Example:# For local backend VITE_API_BASE_URL=http://localhost:5000/api # Or point to your deployed Render backend VITE_API_BASE_URL=https://roxiler-store-rating-raiq.onrender.com/api
After changing
.env, restart the frontend dev server so Vite picks up the new variable. -
Start the application
# Start backend server npm run server # Start frontend (in another terminal) npm run dev
- Email: admin@roxiler.com
- Password: Admin@123
- Register with required details
- Login to access store listings
- Search and filter stores
- Submit ratings (1-5 stars)
- Modify existing ratings
- Update password
- Login with provided credentials
- View store dashboard
- Monitor average rating
- See customer feedback
- Update password
- Login with admin credentials
- Access comprehensive dashboard
- Manage users and stores
- View system statistics
- Apply filters and sorting
server/
βββ config/
β βββ database.js # Database configuration
βββ controllers/
β βββ authController.js # Authentication logic
β βββ adminController.js # Admin operations
β βββ storeController.js # Store operations
βββ middleware/
β βββ auth.js # Authentication middleware
βββ routes/
β βββ auth.js # Auth routes
β βββ admin.js # Admin routes
β βββ stores.js # Store routes
βββ index.js # Server entry point
src/
βββ components/ # Reusable components
βββ context/ # React context providers
βββ pages/ # Page components
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
βββ App.tsx # Main application component
users (id, name, email, password, address, role, timestamps)
stores (id, name, email, address, owner_id, timestamps)
ratings (id, user_id, store_id, rating, timestamps)- JWT-based authentication
- Role-based access control
- Password hashing with bcrypt
- Input validation and sanitization
- CORS protection
- SQL injection prevention
- Total users count
- Total stores count
- Total ratings submitted
- Real-time statistics
- Search by name, email, address
- Filter by user roles
- Sort by multiple fields
- Ascending/descending order
- 1-5 star rating scale
- Real-time average calculation
- User-specific rating tracking
- Rating modification support
- Responsive design for all devices
- Modern, clean interface
- Interactive star rating system
- Real-time form validation
- Toast notifications
- Loading states and error handling
The application includes comprehensive validation and error handling:
- Form validation with real-time feedback
- API error handling
- Authentication state management
- Role-based route protection
- Efficient database queries with proper indexing
- Connection pooling for database
- Optimized React components
- Lazy loading and code splitting ready
- Responsive image handling
npm run dev- Start frontend development servernpm run server- Start backend servernpm run server:prod- Start backend in production modenpm run build- Build frontend for production
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPUT /api/auth/update-password- Update password
GET /api/admin/dashboard- Dashboard statisticsPOST /api/admin/users- Create userGET /api/admin/users- List usersPOST /api/admin/stores- Create storeGET /api/admin/stores- List stores
GET /api/stores- List stores for usersPOST /api/stores/rating- Submit/update ratingGET /api/stores/owner/dashboard- Store owner dashboard
The application is ready for deployment on various platforms:
- Frontend: Vercel, Netlify, or any static hosting
- Backend: Heroku, Railway, or any Node.js hosting
- Database: MySQL on cloud providers
This project is created for the Roxiler coding challenge.
Built with β€οΈ for Roxiler Systems
If you're on Windows and using PowerShell, the easiest way to test the deployed backend is with Invoke-RestMethod or the included script.
- Run the provided script (uses the deployed Render URL):
.
\scripts\test-login.ps1- Or run manually:
$body = @{ email='admin@roxiler.com'; password='Admin@123' } | ConvertTo-Json
Invoke-RestMethod -Uri 'https://roxiler-store-rating-raiq.onrender.com/api/auth/login' -Method Post -Body $body -ContentType 'application/json'Notes:
- If you use
curl.exefrom PowerShell, prefer using a here-string or write the JSON to a file and use--data-binary @fileto avoid quoting issues. - If the server returns 500, check Render Live Tail logs and verify
JWT_SECRETand DB env vars are set in the Render dashboard.