|
| 1 | +# API Design |
| 2 | + |
| 3 | +**Document Version**: 1.0.0 |
| 4 | +**Status**: Published |
| 5 | +**Last Updated**: December 3, 2025 |
| 6 | +**Audience**: Architects, Developers |
| 7 | +**Maintained By**: IoT Bay Documentation Team |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +IoT Bay uses a RESTful API design pattern for client-server communication, primarily serving the frontend JSP pages via AJAX and providing potential external integration points. |
| 14 | + |
| 15 | +## Design Principles |
| 16 | + |
| 17 | +1. **Resource-Oriented**: URLs represent resources (e.g., `/api/products`, `/api/users`). |
| 18 | +2. **Stateless**: Each request contains all necessary information (via session cookies). |
| 19 | +3. **Standard Methods**: Uses HTTP methods explicitly (GET, POST, PUT, DELETE). |
| 20 | +4. **JSON Format**: Data exchange in JSON format. |
| 21 | + |
| 22 | +## API Structure |
| 23 | + |
| 24 | +### Base URL |
| 25 | +- Development: `http://localhost:8080/IoTBay/api` |
| 26 | +- Production: `https://iotbay.com/api` |
| 27 | + |
| 28 | +### Standard Response Format |
| 29 | + |
| 30 | +```json |
| 31 | +{ |
| 32 | + "success": true, |
| 33 | + "data": { ... }, |
| 34 | + "message": "Operation successful", |
| 35 | + "timestamp": "2025-12-03T12:00:00Z" |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +### Error Format |
| 40 | + |
| 41 | +```json |
| 42 | +{ |
| 43 | + "success": false, |
| 44 | + "error": "RESOURCE_NOT_FOUND", |
| 45 | + "message": "The requested product ID 123 does not exist", |
| 46 | + "statusCode": 404 |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +## Core Resources |
| 51 | + |
| 52 | +| Resource | Description | Endpoint | |
| 53 | +|---|---|---| |
| 54 | +| **Auth** | Login, register, logout | `/auth/*` | |
| 55 | +| **Products** | Catalog management | `/products/*` | |
| 56 | +| **Orders** | Order processing | `/orders/*` | |
| 57 | +| **Users** | Profile management | `/users/*` | |
| 58 | + |
| 59 | +## Detailed Documentation |
| 60 | + |
| 61 | +For the complete list of endpoints, parameters, and examples, please refer to the **[API Reference](../3_requirements/API_REFERENCE.md)**. |
| 62 | + |
| 63 | +## Related Documentation |
| 64 | + |
| 65 | +- [API Reference](../3_requirements/API_REFERENCE.md) |
| 66 | +- [Backend Guide](../4_development/BACKEND_GUIDE.md) |
0 commit comments