Team: OpenDash
This project requires:
Python 3.12+
Clone the repository:
git clone https://github.com/RealUltra/OpenEats
cd OpenEatsCreate a virtual environment:
python3 -m venv backend/.venv
source backend/.venv/bin/activatepython -m venv backend\.venv
backend\.venv\Scripts\Activate.ps1Install the required dependencies:
pip install -r backend/requirements.txtCreate a local environment file for development and tests:
Copy-Item .env.example .envGenerate a secret with python -c "import secrets; print(secrets.token_urlsafe(48))" and put it in .env as JWT_SECRET_KEY. The key must be at least 32 bytes. Keep .env private; it is ignored by Git.
To use the sample data, rename backend/sample-data to backend/data.
mv backend/sample-data backend/dataRename-Item backend/sample-data backend/dataThe sample data has two accounts, both with the password password123:
| Role | |
|---|---|
customer@openeats.com |
customer |
owner@openeats.com |
owner |
New registrations are always customers.
Start the application with:
fastapi dev --entrypoint backend.app.main:mainThe application will be available at:
http://127.0.0.1:8000
Install Node.js and npm.
From the repository root, go into the frontend directory:
cd frontendInstall the packages:
npm installStart the Web UI:
npm run devOpen the URL printed by Vite (normally http://localhost:5173/).
Install Docker with Docker Compose.
To start with the sample restaurants, move backend/sample-data to data in the repository root before starting the application.
mv backend/sample-data ./dataMove-Item backend/sample-data dataCreate the Docker environment file and generate a different secret from the local .env key:
Copy-Item .env.docker.example .env.dockerSet JWT_SECRET_KEY in .env.docker to its own generated value. Compose passes this file into the container; it is ignored by Git and must be provided on the production host.
From the repository root, run:
docker compose up --build -dIf there have been no changes since you last built the image, you may run:
docker compose up -dhttp://127.0.0.1:8000/
docker compose downOn the startup screen, choose Customer to browse restaurants or Restaurant to select an existing restaurant or create a new one. The restaurant view has tabs for general details and menu items.
The API provides the following endpoints:
Customer login returns a bearer token. Include it in the Authorization header when calling the /customers/me, /cart, and /orders/me endpoints.
| Method | Path | Description |
|---|---|---|
| GET | /api/v1/health |
Checks if the API is running. |
| GET | /api/v1/restaurants |
Lists all the restaurants. |
| GET | /api/v1/restaurants?{query} |
Lists all the restaurants that match searching query: name=...&hasMenu=...&sort_by=...&sort_desc=... |
| GET | /api/v1/restaurants/{restaurant_id} |
Retrieves a specific restaurant by its ID. |
| POST | /api/v1/restaurants |
Creates a restaurant. Returns 201, 409 if the same name and address already exist, 422 for invalid input. |
| PATCH | /api/v1/restaurants/{restaurant_id} |
Updates only the fields sent. Returns 200, 404 for an unknown ID, 409 for a duplicate, 422 for invalid input. |
| POST | /api/v1/restaurants/{restaurant_id}/menu-items |
Creates a new menu item. Returns 201, 404 if the restaurant is not found, 422 for invalid input. |
| PATCH | /api/v1/restaurants/{restaurant_id}/menu-items/{menu_item_id} |
Updates a menu item's fields. Returns 200, 404 if the item or restaurant is not found, 422 for invalid input. |
| DELETE | /api/v1/restaurants/{restaurant_id}/menu-items/{menu_item_id} |
Deletes a specific menu item. Returns 204 on success, 404 if not found. |
| POST | /api/v1/customers |
Registers a customer. Returns 201 (without the password), 409 if the email is already registered, 422 for invalid input. |
| POST | /api/v1/login |
Authenticates a customer and returns a bearer access token. Returns 200, 401 for invalid credentials or a deactivated account, 422 for invalid input. |
| POST | /api/v1/logout |
Logs out a customer and invalidates their token |
| GET | /api/v1/customers/me |
Returns the signed-in customer's info. Returns 401 if not signed in. |
| GET | /api/v1/customers/{customer_id}/orders |
Returns all orders for the specified customer id. No authentication required. |
| PATCH | /api/v1/customers/me |
Updates the signed-in customer's name, email, telephone or delivery address. Returns 200, 401, 409 if the email is taken, 422 for invalid input. |
| DELETE | /api/v1/customers/me |
Deactivates the signed-in customer's account (kept but marked inactive). Returns 204, 401 if not signed in. |
| GET | /api/v1/cart |
Returns the signed-in customer's active cart (creates an empty one the first time) with current prices, subtotal and total. Returns 200, 401 if not signed in. |
| POST | /api/v1/cart/items |
Adds a menu item (or increases its quantity). Returns 200, 401, 404 for an unknown item, 409 if it's out of stock, from another restaurant or would go over 99, 422 for an invalid quantity. |
| PATCH | /api/v1/cart/items/{menu_item_id} |
Sets an item's quantity (1-99). Returns 200, 401, 404 if the item isn't in the cart or was removed from the menu, 409 if raising the quantity of an out of stock item, 422 for an invalid quantity. |
| DELETE | /api/v1/cart/items/{menu_item_id} |
Removes an item from the cart. Returns 200 with the updated cart, 401, 404 if the item isn't in the cart. |
| DELETE | /api/v1/cart |
Clears the cart. Returns 200 with the empty cart, 401 if not signed in. |
| GET | /api/v1/orders/{order_id} |
Returns the order with the specified id. No authentication required; returns 404 if not found. |
| GET | /api/v1/orders/me |
Returns all orders belonging to the signed-in customer. Returns 401 if not signed in. |
| POST | /api/v1/checkout |
Checks out the signed-in customer's cart: checks availability and prices again, saves the order, then closes the cart. Returns 201 with the order, 401, 403 for owner or deactivated accounts, 409 if the cart is empty, has an unavailable item or there's no delivery address. |
API documentation is available at:
http://127.0.0.1:8000/api/v1/docs
Run the test suite from the appropriate project directory:
python -m pytest backend/tests -q -s --tb=shortOpenEats/
├── backend/
│ ├── app/
│ │ ├── api/ # API route definitions
│ │ ├── core/ # Functionality code
│ │ ├── repositories/ # Data-access logic
│ │ ├── schemas/ # Pydantic models/schemas
│ │ ├── services/ # Business logic
│ │ └── main.py # Application entry point
│ ├── data/ # Application data
│ ├── sample-data/ # Sample application data
│ ├── scrum/ # Project documents
│ ├── tests/ # Automated tests
│ │ └── test-data/ # Test data
│ └── requirements.txt # Python dependencies
├── docs/
│ └── PROVENANCE.md # AI Usage information
├── scrum/
├── frontend/ # React and Vite Web UI
│ ├── src/
│ │ ├── api/ # Backend request functions
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Application screens
│ │ ├── schemas/ # Frontend data types
│ │ ├── main.tsx # App entry point and routes
│ │ └── index.css # Shared styles
│ ├── index.html # HTML entry point
│ ├── package.json # Dependencies and npm scripts
│ └── vite.config.ts # Vite configuration
├── README.md
└── .gitignore