A Laravel-based REST API for a cosmetics e-commerce platform with admin dashboard and public store functionality.
- Laravel 12 with Sanctum authentication
- MySQL/SQLite database support
- CORS configuration for Next.js applications
- Admin and public API endpoints
- Role-based access control (admin/manager)
- PHP 8.2 or higher
- Composer
- MySQL (optional, SQLite is configured by default)
- Install dependencies:
composer install- Copy environment file:
cp .env.example .env- Generate application key:
php artisan key:generate- Run migrations:
php artisan migrate- Seed the database with initial admin user:
php artisan db:seed- Start the development server:
php artisan serve --port=8000The project is configured to use MySQL database hosted on srv1469.hstgr.io. The database connection is already configured in the .env file.
For local development, you can switch to SQLite by updating the .env file:
DB_CONNECTION=sqlite
# Comment out MySQL configuration- Email:
admin@cosmetics.com - Password:
password - Role:
admin
POST /api/login- Admin loginPOST /api/logout- Admin logout (requires authentication)GET /api/user- Get authenticated user (requires authentication)
GET /api/public/products- List productsGET /api/public/products/{id}- Get product detailsPOST /api/public/clients- Register clientPOST /api/public/orders- Create order
GET /api/admin/users- List admin usersGET /api/admin/products- List all productsGET /api/admin/orders- List all ordersGET /api/admin/clients- List all clientsGET /api/admin/inventory- List inventory levels
The API is configured to accept requests from:
http://localhost:3000(Admin Dashboard)http://localhost:3001(Public Store)http://127.0.0.1:3000http://127.0.0.1:3001
curl -X POST http://127.0.0.1:8000/api/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@cosmetics.com", "password": "password"}'curl -X GET http://127.0.0.1:8000/api/user \
-H "Authorization: Bearer YOUR_TOKEN_HERE"This is the foundation setup. The following tasks will implement:
- Database models and migrations
- Complete API endpoints
- Business logic and validation
- File upload handling
- Next.js applications (Admin Dashboard and Public Store)
cosmetics-api/
├── app/
│ ├── Http/
│ │ └── Controllers/
│ │ └── Api/
│ │ ├── Admin/ # Admin-specific controllers
│ │ ├── Public/ # Public API controllers
│ │ ├── AuthController.php
│ │ └── BaseApiController.php
│ └── Models/
├── config/
│ ├── cors.php # CORS configuration
│ └── sanctum.php # Sanctum configuration
├── database/
│ ├── migrations/
│ └── seeders/
└── routes/
└── api.php # API routes