graph TB
Client[Client Applications]
API[Food Hub API]
Auth[Authentication Service]
DB[(Database)]
Stripe[Stripe Payment]
Storage[File Storage]
Client -->|HTTP/HTTPS| API
API -->|Authenticate| Auth
API -->|CRUD Operations| DB
API -->|Payment Processing| Stripe
API -->|File Operations| Storage
subgraph Backend Services
API
Auth
DB
Storage
end
sequenceDiagram
participant C as Customer
participant A as API
participant R as Restaurant
participant S as Stripe
C->>A: Create Order
A->>S: Initialize Payment
S-->>A: Payment Intent
A-->>C: Payment Details
C->>S: Process Payment
S-->>A: Payment Confirmation
A->>R: New Order Notification
R->>A: Accept Order
A-->>C: Order Confirmed
flowchart LR
A[Start] --> B{Has Token?}
B -->|Yes| C[Validate Token]
B -->|No| D[Login Required]
C -->|Valid| E[Access Granted]
C -->|Invalid| D
D --> F[Login]
F --> G[Generate Token]
G --> E
flowchart TD
A[Restaurant Owner] -->|Login| B[Dashboard]
B -->|Manage Menu| C[Products Management]
B -->|View Orders| D[Order Management]
B -->|Update Details| E[Restaurant Profile]
C -->|Add Product| C1[New Product Form]
C -->|Edit Product| C2[Edit Product Form]
C -->|Delete Product| C3[Confirm Delete]
D -->|New Orders| D1[Process Orders]
D -->|Active Orders| D2[Update Status]
D -->|Completed Orders| D3[View History]
erDiagram
User ||--o{ Order : places
User ||--o{ Restaurant : owns
User ||--|| DeliveryPerson : has
Restaurant ||--o{ Product : has
Restaurant ||--o{ Order : receives
Order ||--|{ OrderItem : contains
Product ||--o{ OrderItem : includes
DeliveryPerson ||--o{ Order : delivers
User {
int id
string name
string email
string role
}
Restaurant {
int id
string name
string address
int owner_id
}
Product {
int id
string name
float price
int restaurant_id
}
Order {
int id
int user_id
int restaurant_id
int delivery_person_id
string status
float total
}
DeliveryPerson {
int id
int user_id
string status
}
Full system access
Restaurant management access
Basic ordering access
Order delivery access
sequenceDiagram
participant C as Client
participant M as Middleware
participant A as API Controller
participant D as Database
C->>M: HTTP Request
M->>M: Validate Token
M->>M: Check Permissions
alt Invalid Auth
M-->>C: 401/403 Error
else Valid Auth
M->>A: Forward Request
A->>D: Query Data
D-->>A: Return Data
A-->>C: JSON Response
end
Note over C,D: All responses follow standard format
Login with email and password
Register new user account
Logout current user
Get all users with optional role filter (admin only)
Query Parameters:
Example Request:
GET /api/users?role=delivery
Create new user (admin only)
Update user details (admin only)
Get orders based on role:
Get specific order details (role-based access)
Create new order (customers only)
Confirm order payment
Update order status and assign delivery person
Request body:
{
"status": "ready",
"delivery_person_id": 1 // Optional, admin only
}
List all restaurants (public)
Get restaurant details (public)
Create new restaurant (admin only)
Update restaurant (admin or owner)
List all products (public)
Create new product (restaurant owner or admin)
Update product (restaurant owner or admin)
Get all delivery persons (admin only)
Get available delivery persons (admin only)
Update delivery person status (delivery person or admin)
Get assigned orders (delivery person only)
Get Stripe publishable key (public)
{
"success": true,
"data": {
// Response data
},
"message": "Optional message"
}