-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathbackend_design.txt
76 lines (57 loc) · 2.05 KB
/
backend_design.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Python Flask server with the following components:
1. Database:
- Use SQLite for simplicity
- Tables:
- Orders: id, customer_id, status, created_at, updated_at
- DeliveryEvents: id, order_id, event_type, timestamp, driver_id, region
- Drivers: id, name, contact_info
- Regions: id, name
2. API Endpoints:
- GET /api/orders
- Query parameters: customer_id, status, date_range
- Returns list of orders with basic info
- GET /api/orders/<order_id>
- Returns detailed order info including delivery events
- GET /api/delivery_events
- Query parameters: order_id, driver_id, region, date_range
- Returns list of delivery events
- POST /api/delivery_events
- Create new delivery event
- PUT /api/orders/<order_id>
- Update order status
3. Search functionality:
- Implement full-text search on orders and delivery events
- Use SQLite FTS5 extension for efficient searching
4. Authentication:
- Simple username/password authentication for customer support team
- Use Flask-Login for session management
5. Logging:
- Implement logging for all API requests and database operations
Pseudocode for main app structure:
```python
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
app = Flask(__name__)
db = SQLAlchemy(app)
login_manager = LoginManager(app)
# Define database models (Orders, DeliveryEvents, Drivers, Regions)
@app.route('/api/orders', methods=['GET'])
def get_orders():
# Implement order search and filtering
pass
@app.route('/api/orders/<order_id>', methods=['GET'])
def get_order_details(order_id):
# Retrieve and return order details with delivery events
pass
@app.route('/api/delivery_events', methods=['GET', 'POST'])
def handle_delivery_events():
# Implement delivery event search and creation
pass
@app.route('/api/orders/<order_id>', methods=['PUT'])
def update_order_status(order_id):
# Update order status
pass
if __name__ == '__main__':
app.run(debug=True)
```