- Laravel 12.x (Latest)
- PHP 8.4 FPM
- PostgreSQL 16 (Primary Database)
- Redis 7 (Cache, Session, Queue)
- Elasticsearch 8.11.3 (Search Engine)
- React 19.x
- Vite 7.x (Build Tool)
- Tailwind CSS 3.x (Styling)
- React Router DOM 7.x (Routing)
- Axios (HTTP Client)
- TanStack Query (React Query - Data Fetching)
- Docker & Docker Compose
- Nginx (Web Server)
- Kibana 8.11.3 (Elasticsearch UI)
- pgAdmin 4 (PostgreSQL UI)
| Container | Image | Purpose | Ports |
|---|---|---|---|
sms_nginx |
nginx:alpine | Web server for API & frontend | 8888:80, 8443:443 |
sms_php |
php:8.4-fpm-alpine | Laravel application | 9000 (internal) |
sms_postgres |
postgres:16-alpine | Primary database | 5432:5432 |
sms_redis |
redis:7-alpine | Cache, sessions, queues | 6379:6379 |
sms_elasticsearch |
elasticsearch:8.11.3 | Search engine | 9200:9200, 9300:9300 |
sms_kibana |
kibana:8.11.3 | Elasticsearch management UI | 5601:5601 |
sms_node |
node:20-alpine | React development server | 5173:5173 |
sms_pgadmin |
pgadmin4:latest | PostgreSQL management UI | 5050:80 |
- Docker Engine 20.x or higher
- Docker Compose 2.x or higher
- At least 4GB RAM (2GB for Elasticsearch)
- Git
git clone <repository-url>
cd SmartStockThe setup script will automatically:
- Create Laravel backend project
- Create React frontend project (optional)
- Install all dependencies
- Configure database connections
- Build Docker images
- Start all containers
- Run database migrations
- Install Laravel Sanctum for API authentication
chmod +x setup.sh
./setup.shInstallation Options:
When you run the setup script, you'll be prompted to choose:
-
Full-stack Mode (Default) - Complete application with Laravel backend + React frontend
- β Laravel backend with views and API support
- β React frontend with Vite dev server
- β All database and caching services
- β Perfect for building complete web applications
-
API-only Mode - Optimized for REST API development
- β Laravel backend optimized for API endpoints
- β Unnecessary view files removed
- β Laravel Sanctum pre-installed
- β All database and caching services
- β Perfect for mobile apps, microservices, or separate frontend projects
After setup completes, you can access:
- Frontend (Development): http://localhost:5173
- Backend API: http://localhost:8888/api
- Kibana (Elasticsearch UI): http://localhost:5601
- pgAdmin (Database UI): http://localhost:5050
- Host: localhost
- Port: 5432
- Database: laravel
- Username: laravel
- Password: secret
- Email: admin@admin.com
- Password: admin
- URL: http://localhost:9200
- Authentication: Disabled (development only)
SmartStock/
βββ backend/ # Laravel application
β βββ app/
β βββ config/
β βββ database/
β βββ routes/
β βββ ...
βββ frontend/ # React application
β βββ src/
β βββ public/
β βββ index.html
β βββ vite.config.js
βββ docker/ # Docker configuration
β βββ nginx/
β β βββ default.conf
β βββ php/
β βββ Dockerfile
β βββ php.ini
βββ docker-compose.yml # Docker services configuration
βββ setup.sh # Automated setup script
βββ README.md # This file
βββ ELASTICSEARCH.md # Elasticsearch integration guide
- RESTful API architecture
- PostgreSQL with full ACID compliance
- Redis-based caching and session management
- Elasticsearch integration for advanced search
- Queue system for background jobs
- Laravel Scout for model searching
- Modern React with hooks
- Tailwind CSS for responsive design
- React Router for SPA navigation
- TanStack Query for efficient data fetching
- Axios for API communication
- Vite for fast HMR and builds
- Fully containerized with Docker
- One-command setup
- Persistent data volumes
- Development and production ready
- Horizontal scalability support
# Start all services
docker-compose up -d
# Stop all services
docker-compose down
# View logs
docker-compose logs -f
# View specific service logs
docker-compose logs -f php
docker-compose logs -f nginx
docker-compose logs -f elasticsearch
# Restart a service
docker-compose restart php# Enter PHP container
docker-compose exec php sh
# Run migrations
docker-compose exec php php artisan migrate
# Create migration
docker-compose exec php php artisan make:migration create_products_table
# Create model
docker-compose exec php php artisan make:model Product
# Create controller
docker-compose exec php php artisan make:controller ProductController
# Clear cache
docker-compose exec php php artisan cache:clear
docker-compose exec php php artisan config:clear
docker-compose exec php php artisan route:clear
# Run tests
docker-compose exec php php artisan test# Enter Node container
docker-compose exec node sh
# Install new package
docker-compose exec node npm install <package-name>
# Build for production
docker-compose exec node npm run build
# Run linter
docker-compose exec node npm run lint# Access PostgreSQL CLI
docker-compose exec postgres psql -U laravel -d laravel
# Backup database
docker-compose exec postgres pg_dump -U laravel laravel > backup.sql
# Restore database
docker-compose exec -T postgres psql -U laravel laravel < backup.sql# Check Elasticsearch health
curl http://localhost:9200/_cluster/health?pretty
# List all indices
curl http://localhost:9200/_cat/indices?v
# Import models to Elasticsearch
docker-compose exec php php artisan scout:import "App\Models\Product"
# Flush Elasticsearch index
docker-compose exec php php artisan scout:flush "App\Models\Product"For detailed Elasticsearch setup and usage, see ELASTICSEARCH.md.
Quick setup:
# Install Laravel Scout and Elasticsearch driver
docker-compose exec php composer require laravel/scout
docker-compose exec php composer require matchish/laravel-scout-elasticsearch
# Publish Scout configuration
docker-compose exec php php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"APP_NAME="Smart Stock Management"
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secret
REDIS_HOST=redis
REDIS_PORT=6379
ELASTICSEARCH_HOST=elasticsearch
ELASTICSEARCH_PORT=9200
SCOUT_DRIVER=elasticsearchVITE_API_URL=http://localhost:8888/api-
Backend:
# Create migration docker-compose exec php php artisan make:migration create_feature_table # Create model with controller docker-compose exec php php artisan make:model Feature -mc # Run migration docker-compose exec php php artisan migrate
-
Frontend:
# Create component files in frontend/src/components/ # Add routes in frontend/src/App.jsx
-
Testing:
# Test backend docker-compose exec php php artisan test # Test frontend (after adding tests) docker-compose exec node npm run test
# Build frontend
docker-compose exec node npm run build
# Optimize Laravel
docker-compose exec php php artisan config:cache
docker-compose exec php php artisan route:cache
docker-compose exec php php artisan view:cache- Enable Elasticsearch security (xpack.security.enabled=true)
- Use strong passwords for all services
- Configure HTTPS with SSL certificates
- Use environment-specific .env files
- Enable Laravel's security features (CSRF, rate limiting)
- CPU: 2 cores
- RAM: 4GB
- Disk: 10GB
- CPU: 4 cores
- RAM: 8GB
- Disk: 20GB SSD
# Check what's using the port
lsof -i :8888
lsof -i :5173
# Change ports in docker-compose.yml if needed# Fix backend permissions
chmod -R 755 backend
chmod -R 777 backend/storage backend/bootstrap/cache
# Fix frontend permissions (if files are owned by root)
sudo chown -R $USER:$USER frontend# Increase vm.max_map_count on Linux
sudo sysctl -w vm.max_map_count=262144
# Make it permanent
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf# Wait for PostgreSQL to fully start
docker-compose logs postgres
# Restart PHP container
docker-compose restart php[Your License Here]
[Contributing Guidelines]
For issues and questions:
- Create an issue in the repository
- Check ELASTICSEARCH.md for search-related questions
- Laravel Framework
- React Team
- Docker Community
- Elasticsearch Team