A REST API for restaurant management, handling products, tables, table sessions, and orders. Built with Node.js, Express, and TypeScript.
Note: This project is based on a challenge from the Rocketseat Fullstack curriculum. I revisited and implemented this solution independently to consolidate backend fundamentals, including database modeling, API design, and error handling patterns.
- Node.js 20
- Express
- TypeScript
- Knex.js (Query Builder)
- SQLite
- Zod (Validation)
- Swagger/OpenAPI 3.0
erDiagram
PRODUCTS {
int id PK
text name
decimal price
timestamp created_at
timestamp updated_at
}
TABLES {
int id PK
int table_number
timestamp created_at
timestamp updated_at
}
TABLES_SESSIONS {
int id PK
int table_id FK
timestamp opened_at
timestamp closed_at
}
ORDERS {
int id PK
int table_session_id FK
int product_id FK
int quantity
decimal price
timestamp created_at
timestamp updated_at
}
TABLES ||--o{ TABLES_SESSIONS : has
TABLES_SESSIONS ||--o{ ORDERS : contains
PRODUCTS ||--o{ ORDERS : "referenced_by"
- Node.js 20+
npm installRun migrations:
npm run knex -- migrate:latestSeed the database (optional):
npm run knex -- seed:runnpm run devServer runs at http://localhost:3333.
Interactive API documentation is available via Swagger UI:
http://localhost:3333/api-docs
| Resource | Method | Endpoint | Description |
|---|---|---|---|
| Products | GET | /products |
List all products |
| Products | POST | /products |
Create a product |
| Products | PUT | /products/:id |
Update a product |
| Products | DELETE | /products/:id |
Delete a product |
| Tables | GET | /tables |
List all tables |
| Tables | POST | /tables |
Create a table |
| Tables | DELETE | /tables/:id |
Delete a table |
| Table Sessions | GET | /tables-sessions |
List all sessions |
| Table Sessions | POST | /tables-sessions |
Open a session |
| Table Sessions | PATCH | /tables-sessions/:id |
Close a session |
| Orders | POST | /orders |
Create an order |
| Orders | GET | /orders/:id |
List orders by session |
| Orders | GET | /orders/:id/total |
Get session total |
In active development. Core functionality is implemented and functional.