πŸ–₯️ Chapter 5 – System Design (Software Development)

1) General Architecture

The system architecture shows how major components communicate: a mobile client connects to the backend over the Internet; the server handles business logic and integrates with Firebase (real-time features, messaging), APNS (iOS push), and a relational database (e.g., PostgreSQL/MySQL) for structured data.

2) Sequence Diagrams

For each key use case, a sequence diagram clarifies component interactions over time. Example below for Place an Order:

  1. App sends checkout request to API.
  2. Server validates cart & user, reserves stock, calls payment gateway.
  3. Server persists order, publishes realtime event (optional Firebase), returns confirmation.
  4. APNS pushes status notification to the user’s device (if enabled).

3) Database Analysis & ER Diagram

The ER diagram defines entities and relationships. Tables should document primary keys, foreign keys, uniqueness, and column types.

Users

ColumnTypePKFKUniqueNotes
user_idINTβœ”β€“βœ”Auto-increment
emailVARCHAR(255)β€“β€“βœ”Login identifier
password_hashVARCHAR(255)–––BCrypt/Argon2
roleENUM('customer','admin')–––Access level
created_atTIMESTAMP–––Default now()

Orders

ColumnTypePKFKUniqueNotes
order_idINTβœ”β€“βœ”Auto-increment
user_idINTβ€“βœ” β†’ Users.user_id–Owner
total_priceDECIMAL(10,2)–––Sum of items
statusENUM('pending','paid','shipped','cancelled')–––Lifecycle
created_atTIMESTAMP–––Default now()

Add more tables as needed (Products, OrderItems, Payments, etc.).

4) API Analysis

For each endpoint, specify method, URL, headers, body, response, and error cases.

Endpoint: POST /api/orders

Headers Authorization: Bearer <token>
Content-Type: application/json
Body
{
  "user_id": 101,
  "items": [
    { "product_id": 20, "quantity": 2 },
    { "product_id": 55, "quantity": 1 }
  ]
}
Response (200)
{
  "order_id": 999,
  "status": "pending",
  "created_at": "2025-08-16T09:00:00Z"
}
Errors
  • 400 Bad Request – invalid or missing fields
  • 401 Unauthorized – invalid/expired token
  • 409 Conflict – stock issue
  • 500 Internal Server Error – unexpected failure

Repeat for all endpoints (auth, products, cart, payment, profile…).

5) Wireframes (UI/UX)

Provide low-fidelity layouts for key screens (Login, Dashboard, Order Details, Settings). Keep them simple and structural.