A comprehensive web application for rating and reviewing local stores with role-based user management.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ FRONTEND │ │ BACKEND │ │ DATABASE │
│ (React.js) │ │ (Node.js) │ │ (PostgreSQL) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
├─ Landing Page ├─ Auth Routes ├─ Users Table
├─ Registration ├─ Store Routes ├─ Stores Table
├─ Authentication ├─ Rating Routes ├─ Ratings Table
├─ User Dashboard ├─ JWT Middleware └─ Relationships
├─ Store Management ├─ Validation Layer │
└─ Rating System └─ Error Handling │
│
┌─────────────────────────────────────────────────────────────┘
│
└─── USER ROLES & PERMISSIONS
├─ Regular User: Browse stores, submit ratings, view reviews
└─ Store Owner: Manage owned stores, view detailed analytics
- User Authentication: Secure registration and login system
- Role-Based Access Control: Different permissions for regular users and store owners
- Store Management: Add, edit, and manage store information
- Rating System: 5-star rating system with detailed reviews
- Search & Filter: Find stores by location, category, or rating
- JWT Authentication: Secure token-based authentication
- Input Validation: Both client-side and server-side validation using Zod
- Password Security: Bcrypt hashing for secure password storage
- Responsive Design: Mobile-first responsive design using Tailwind CSS
- Error Handling: Comprehensive error handling and user feedback
- React.js - UI library with hooks
- React Router - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Context API - State management for authentication
- Node.js - JavaScript runtime
- Express.js - Web application framework
- PostgreSQL - Relational database
- JWT - JSON Web Tokens for authentication
- Bcrypt - Password hashing
- Zod - Schema validation
- ESLint - Code linting
- Git - Version control
- Environment Variables - Configuration management
-- Users Table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
address TEXT,
role VARCHAR(20) DEFAULT 'normal',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Stores Table
CREATE TABLE stores (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
address TEXT NOT NULL,
category VARCHAR(50),
owner_id INTEGER REFERENCES users(id),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Ratings Table
CREATE TABLE ratings (
id SERIAL PRIMARY KEY,
store_id INTEGER REFERENCES stores(id),
user_id INTEGER REFERENCES users(id),
rating INTEGER CHECK (rating >= 1 AND rating <= 5),
review TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);POST /api/auth/register- User registrationPOST /api/auth/login- User loginPUT /api/auth/update-password- Update password
GET /api/stores- Get all storesPOST /api/stores- Create new store (store owners only)GET /api/stores/:id- Get store detailsPUT /api/stores/:id- Update store (owner only)
POST /api/ratings- Submit rating/reviewGET /api/ratings/store/:id- Get store ratingsGET /api/ratings/user/:id- Get user's ratings
- Node.js (v14 or higher)
- PostgreSQL (v12 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/yourusername/storerate.git cd storerate -
Install dependencies
# Backend dependencies cd backend npm install # Frontend dependencies cd ../frontend npm install
-
Environment Setup Create
.envfile in backend directory:DATABASE_URL=postgresql://username:password@localhost:5432/storerate JWT_SECRET=your-super-secret-jwt-key PORT=5000 NODE_ENV=development
-
Database Setup
# Create database and run migrations npm run db:setup -
Run the application
# Start backend server cd backend && npm start # Start frontend development server cd frontend && npm start
# Run backend tests
cd backend && npm test
# Run frontend tests
cd frontend && npm test# Build frontend for production
cd frontend && npm run build
# Start production server
cd backend && npm run start:prod- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.