A modern, full-stack e-commerce application built with React.js frontend, Laravel backend API, and real-time capabilities powered by Socket.io.
- User Authentication & Authorization: Secure login/registration with role-based access control (Client, Admin, Super Admin)
- Product Management: Complete CRUD operations with image uploads, pricing, descriptions, and inventory management
- Shopping Cart: Real-time cart management with persistent storage
- Order Processing: Full order lifecycle management with order tracking
- Admin Dashboard: Comprehensive admin panel for managing products, categories, users, orders, and analytics
- Real-time Notifications: Live updates using Socket.io for order status, notifications, and events
- Blog System: Manage blog posts and categories with full CRUD operations
- User Reviews & Ratings: Product review system with ratings
- Coupon Management: Create and apply discount coupons to orders
- Search & Filtering: Advanced product search and category-based filtering
- Media Management: Upload and manage product images and assets
- Audit Logging: Track user actions and system events for security and compliance
This project follows a microservices-inspired architecture:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React) β
β afront/ (Vite + TypeScript) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β HTTP/REST API
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend API (Laravel 9) β
β backend/ (RESTful API) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββ΄βββββββββββ
βΌ βΌ
ββββββββββ ββββββββββββ
β MySQL β β Socket.ioβ
β (Data) β β(Real-time)
ββββββββββ ββββββββββββ
- React 18 - UI library
- TypeScript - Type safety
- Vite - Fast build tool
- Redux Toolkit - State management
- React Router v7 - Client-side routing
- Axios - HTTP client
- Socket.io Client - Real-time communication
- Tailwind CSS - Styling
- Recharts - Data visualization
- Laravel 9 - PHP framework
- Laravel Sanctum - API authentication
- Spatie Laravel Permission - Role & permission management
- MySQL - Database
- Redis - Caching (optional)
- Node.js - Runtime
- Express - HTTP server
- Socket.io - WebSocket communication
- Axios - Backend communication
- PHP 8.0+ (for Laravel backend)
- Node.js 18+ (for React frontend and Socket server)
- MySQL 8.0+ (or compatible database)
- Composer (PHP package manager)
- npm or yarn (Node package manager)
git clone https://github.com/bravonokoth/store.git
cd storecd backend
# Install PHP dependencies
composer install
# Copy environment file
cp .env.example .env
# Generate application key
php artisan key:generate
# Configure database in .env file
# DB_DATABASE=store
# DB_USERNAME=root
# DB_PASSWORD=
# Run migrations
php artisan migrate
# Seed database (optional)
php artisan db:seed
# Start Laravel development server
php artisan serve
# Backend runs at: http://localhost:8000cd afront
# Install dependencies
npm install
# Start development server
npm run dev
# Frontend runs at: http://localhost:5173cd socket_server
# Install dependencies
npm install
# Start socket server
npm start
# Socket server runs at: http://localhost:3000The backend API follows RESTful conventions. Key endpoints include:
POST /api/register- User registrationPOST /api/login- User loginPOST /api/logout- User logoutGET /api/user- Get current user
GET /api/products- List all productsGET /api/products/{id}- Get product detailsPOST /api/products- Create product (Admin only)PUT /api/products/{id}- Update product (Admin only)DELETE /api/products/{id}- Delete product (Admin only)
GET /api/orders- List user ordersPOST /api/orders- Create orderGET /api/orders/{id}- Get order details
GET /api/users- List users (Super Admin only)GET /api/analytics- Get analytics data (Admin only)GET /api/audit-logs- View audit logs (Super Admin only)
See backend/routes/api.php for the complete API route list.
The application uses Laravel Sanctum for API token-based authentication and Spatie Laravel Permission for role-based access control.
- Client - Regular users who can browse products and place orders
- Admin - Can manage products, orders, and view analytics
- Super Admin - Full system access, can manage users and roles
Example authenticated request:
const response = await axios.get('/api/orders', {
headers: {
'Authorization': `Bearer ${authToken}`
}
});Key models and relationships:
- User - Application users with roles
- Product - E-commerce products
- Category - Product categories
- Cart - Shopping cart items
- Order - Customer orders
- OrderItem - Individual items in orders
- Review - Product reviews and ratings
- Coupon - Discount coupons
- Blog - Blog posts and articles
- Role - User roles (Client, Admin, Super Admin)
- Permission - Access permissions
Run tests for the backend:
cd backend
# Run all tests
php artisan test
# Run specific test file
php artisan test --filter AuthTest
# Run with coverage
php artisan test --coveragecd afront
npm run build
# Upload contents of `dist/` folder to your hostingcd backend
composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan migrate --force
# Upload to server and configure web root to `public/`sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cacheEnsure rate limiter is defined in bootstrap/app.php or routes/api.php:
RateLimiter::for('api', function ($request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});# Test database connection
php artisan tinker
>>> DB::connection()->getPDO();store/
βββ afront/ # React Frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ store/ # Redux state management
β β βββ services/ # API client & utilities
β β βββ App.tsx # Root component
β βββ package.json
βββ backend/ # Laravel Backend API
β βββ app/
β β βββ Http/
β β β βββ Controllers/Api/ # API endpoints
β β β βββ Middleware/ # Custom middleware
β β βββ Models/ # Eloquent models
β β βββ Exceptions/
β βββ database/
β β βββ migrations/ # Database migrations
β β βββ seeders/ # Database seeders
β βββ routes/
β β βββ api.php # API routes
β βββ composer.json
βββ socket_server/ # Node.js Real-time Server
β βββ server.js
β βββ package.json
βββ README.md
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs using GitHub Issues
- Discussions: Join GitHub Discussions
- Documentation: Check the wiki for detailed guides
Bravon Okoth
- GitHub: @bravonokoth
- Email: bravonoorwa@gmail.com
Happy coding! π
- Clone the repository:
git clone https://github.com/bravonokoth/store.git cd store - Backend Setup (
backfolder):- Navigate to the backend directory:
cd back - Install Composer dependencies:
composer install - Set up your
.envfile and database connection. - Run database migrations:
php artisan migrate - Start the Laravel development server:
php artisan serve
- Navigate to the backend directory:
- Frontend Setup (
frontfolder):- Navigate to the frontend directory:
cd ../front - Install Node.js dependencies:
npm install - Start the React development server:
npm start
- Navigate to the frontend directory: