- PHP 8.1+
- Composer
- MySQL
- Clone repo
- cp .env.example .env and set DB credentials and APP_URL
- composer install
- php artisan key:generate
- php artisan jwt:secret
- php artisan migrate
- php artisan db:seed
- php artisan serve
- Register: POST /api/auth/register payload: {name, email, password, password_confirmation}
- Login: POST /api/auth/login payload: {email, password} returns token: store in Authorization: Bearer
- All other endpoints require Authorization header.
- Products: GET/POST/PUT/DELETE /api/products
- Cart: GET /api/cart, POST /api/cart {product_id, quantity}, DELETE /api/cart/{id}
- Orders: POST /api/orders {address, phone} -> returns order_number, total, items
erDiagram
users ||--o{ cart_items : has
users ||--o{ orders : places
products ||--o{ cart_items : referenced_in
products ||--o{ order_items : referenced_in
orders ||--o{ order_items : contains
users {
bigint id PK
string name
string email
string password
}
products {
bigint id PK
string name
text description
decimal price
int stock
}
cart_items {
bigint id PK
bigint user_id FK
bigint product_id FK
int quantity
}
orders {
bigint id PK
bigint user_id FK
string order_number
decimal total
string address
string phone
}
order_items {
bigint id PK
bigint order_id FK
bigint product_id FK
int quantity
decimal unit_price
decimal total_price
}