Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
261 changes: 192 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,125 +1,248 @@
<p align="center">
<p align="center">
<img src="https://camo.githubusercontent.com/870812d4ebe999bd1434db7ffcb27c2f347f1c2c6af1842e59ae8b28855b4b42/68747470733a2f2f666c622d6173736574732e73332e61702d736f757468656173742d312e616d617a6f6e6177732e636f6d2f7374617469632f73746f726566726f6e742d6c6f676f2e737667" width="380" height="100" />
</p>
<p align="center">
Open-source Headless Commerce & Marketplace Extension for Fleetbase
</p>
<img src="https://flb-assets.s3.ap-southeast-1.amazonaws.com/static/storefront-logo.svg" alt="Fleetbase Storefront" width="380">
</p>

<p align="center">
Logistics-first headless commerce and marketplace infrastructure for Fleetbase.
</p>

<p align="center">
<a href="https://www.fleetbase.io/docs/storefront">Documentation</a>
|
<a href="https://github.com/fleetbase/storefront">GitHub</a>
|
<a href="https://www.fleetbase.io/platform/storefront">Platform Overview</a>
|
<a href="https://www.fleetbase.io">Fleetbase</a>
</p>

<p align="center">
<img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-blue" alt="License: AGPL-3.0-or-later">
<img src="https://img.shields.io/badge/php-%5E8.0-777bb4" alt="PHP ^8.0">
<img src="https://img.shields.io/badge/node-%3E%3D18-339933" alt="Node >=18">
<img src="https://img.shields.io/badge/ember-engine-e04e39" alt="Ember Engine">
</p>

---

<p align="center">
<img src="https://www.fleetbase.io/images/screenshots/storefront/storefront-dashboard.webp" alt="Fleetbase Storefront dashboard" width="860">
</p>

## Overview

This monorepo contains both the frontend and backend components of the Storefront extension for Fleetbase. The frontend is built using Ember.js and the backend is implemented in PHP.
Storefront is the commerce extension for Fleetbase. It combines a Laravel API package with an Ember engine for the Fleetbase Console, giving operators the tools to manage stores, products, carts, checkout, customers, marketplace networks, and fulfillment workflows from one logistics-native system.

### Requirements
Unlike a generic e-commerce plugin, Storefront is built around the handoff from purchase to delivery. A checkout can create Fleet-Ops orders, attach storefront order metadata, expose customer and commerce details in the Fleetbase Console, and keep operators close to the real delivery lifecycle.

* PHP 7.3.0 or above
* Ember.js v4.8 or above
* Ember CLI v4.8 or above
* Node.js v18 or above
Read the official guide at [fleetbase.io/docs/storefront](https://www.fleetbase.io/docs/storefront).

## Structure
## Features

```
├── addon
├── app
├── assets
├── translations
├── config
├── node_modules
├── server
│ ├── config
│ ├── data
│ ├── migrations
│ ├── resources
│ ├── src
│ ├── tests
│ └── vendor
├── tests
├── testem.js
├── index.js
├── package.json
├── phpstan.neon.dist
├── phpunit.xml.dist
├── pnpm-lock.yaml
├── ember-cli-build.js
├── composer.json
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
```
- **Store and marketplace management**: run a single store or organize many stores into Storefront networks.
- **Product catalog**: manage products, categories, variants, variant options, addons, addon categories, images, pricing, tags, and availability hours.
- **Locations and mobile commerce**: configure store locations, service areas, food trucks, Fleet-Ops vehicle links, and catalogs assigned to mobile stores.
- **Carts and checkout**: support persistent carts, line items, variants, addons, scheduled items, service quotes, checkout initialization, and order capture.
- **Payments**: configure Stripe, QPay, and cash-on-delivery flows through Storefront gateways.
- **Customers**: support customer registration, login, SMS verification, social login hooks, saved customer metadata, device registration, order history, and account closure flows.
- **Orders and fulfillment**: manage Storefront orders in the console, advance order activity, assign/unassign drivers, mark preparation states, complete pickups, and inspect commerce details alongside route and tracking data.
- **Reviews and votes**: expose API resources for customer reviews and voting.
- **Promotions and notifications**: manage notification channels and send broadcast or transactional push notifications through APNs, FCM, and related Storefront notification classes.
- **Dashboard analytics**: ship Storefront widgets for revenue, order volume, average order value, active orders, completed orders, customers, cart conversion, cancellation rate, revenue trends, top products, customer insights, order status mix, recent orders, and recent customers.
- **Fleet-Ops integration**: register Storefront summaries inside Fleet-Ops order details and add product-as-entity tooling to Fleet-Ops order creation.
- **Internationalization**: include translations for multiple locales through the extension translation files.

## Architecture

This repository contains both sides of the Storefront extension:

| Area | Path | Purpose |
| --- | --- | --- |
| Ember engine | `addon/`, `app/`, `config/`, `translations/` | Fleetbase Console UI, routes, models, components, services, widgets, and translations. |
| Laravel API | `server/src/`, `server/config/`, `server/migrations/` | Storefront API controllers, models, resources, middleware, providers, observers, notifications, jobs, and database migrations. |
| Tests | `tests/`, `server/tests/` | Ember integration tests and backend test scaffolding. |

The Ember package is published as `@fleetbase/storefront-engine`. The Laravel package is published as `fleetbase/storefront-api`.

## Installation
## Console Modules

### Backend
Storefront registers a Console entry under the `storefront` route and exposes these primary work areas:

Install the PHP packages using Composer:
- **Dashboard**: Storefront-specific operational and analytics widgets.
- **Products**: product catalog, categories, variants, addons, import processing, and product entity creation.
- **Orders**: incoming Storefront orders, activity actions, customer details, commerce summary, documents, route/tracking context, and comments.
- **Customers**: customer records and order history.
- **Networks**: multi-store marketplace networks, store assignment, categories, invitations, and network-level views for stores, customers, and orders.
- **Catalogs**: product bundles and catalog categories, including food truck catalog assignment.
- **Food Trucks**: Fleet-Ops vehicle-linked mobile stores with service area and zone support.
- **Promotions**: push notification campaigns and notification channel workflows.
- **Settings**: store profile, API keys, locations, gateways, and notifications.

## API Surface

Storefront exposes two API families.

### Public Storefront API

The public customer-facing API is mounted under `storefront/v1` and protected by Storefront API middleware. It includes:

- Store lookup, store/network information, locations, gateways, search, tags, and network stores.
- Categories, products, food trucks, reviews, and customer-facing catalog browsing.
- Persistent carts with add, update, remove, empty, and delete operations.
- Service quotes from carts.
- Checkout initialization, status, capture, Stripe setup intents, Stripe payment intent updates, and QPay capture callbacks.
- Customer registration, login, SMS code verification, social login endpoints, device registration, saved places, customer orders, phone verification, Stripe customer helpers, and account closure flows.
- Order pickup completion and receipt generation.

### Internal Console API

The protected internal API is mounted under `storefront/int/v1`. It powers the Fleetbase Console and includes:

- CRUD resources for orders, customers, stores, store hours, store locations, products, product hours, variants, variant options, addons, addon categories, gateways, notification channels, reviews, votes, food trucks, catalogs, catalog categories, and catalog hours.
- Order actions for accept, preparing, ready, completed, cancel, and unassign driver.
- Network actions for adding stores, removing stores, categories, invitations, and network lookup.
- Analytics endpoints for overview, revenue trends, order status mix, top products, and customer insights.
- Metrics and operational action endpoints.

## Getting Started

Storefront is designed to run inside a Fleetbase installation with `fleetbase/core-api` and `fleetbase/fleetops-api` available.

### Requirements

- PHP `^8.0`
- Node.js `>=18`
- pnpm
- Composer
- Fleetbase Core API
- Fleetbase FleetOps API

### Install Dependencies

```bash
pnpm install
composer install
```

### Backend Package

```bash
composer require fleetbase/core-api
composer require fleetbase/fleetops-api
composer require fleetbase/storefront-api
```
### Frontend

Install the Ember.js Engine/Addon:
### Frontend Package

```bash
pnpm install @fleetbase/storefront-engine
```

## Usage
## Development

For the full local Fleetbase workflow, see the [Fleetbase Development Setup guide](https://www.fleetbase.io/docs/platform/quickstart/development-setup). That guide covers cloning the main repository with submodules, mounting live package source, linking extensions, running the Console dev server, and reloading the API after backend changes.

### Backend
### Use Local Storefront Source in Fleetbase

When developing Storefront inside the Fleetbase monorepo, run the package linker from the repository root so the local `packages/storefront` source replaces the published Storefront packages used by Console and API:

🧹 Keep a modern codebase with **PHP CS Fixer**:
```bash
composer lint
flb-package-linker enable storefront
flb-package-linker install storefront
```

⚗️ Run static analysis using **PHPStan**:
The linker updates the local Console and API manifests for development. To inspect the current link state:

```bash
composer test:types
flb-package-linker status
flb-package-linker doctor
```

✅ Run unit tests using **PEST**
If the linker is not installed yet, install it once from the Fleetbase repository root:

```bash
composer test:unit
npm link
```

🚀 Run the entire test suite:
After linking backend package changes, reload the running API worker so Laravel Octane picks up PHP changes:

```bash
composer test
docker compose exec application php artisan octane:reload
```

### Frontend
For frontend changes, run the Fleetbase Console dev server as described in the development setup guide; linked Ember packages are watched and live-reloaded by the dev server.

### Package Commands

Run the Ember engine locally:

🧹 Keep a modern codebase with **ESLint**:
```bash
pnpm lint
pnpm start
```

✅ Run unit tests using **Ember/QUnit**
Build the Ember engine:

```bash
pnpm test
pnpm test:ember
pnpm test:ember-compatibility
pnpm build
```

🚀 Start the Ember Addon/Engine
Run frontend lint and tests:

```bash
pnpm start
pnpm lint
pnpm test
pnpm test:ember
```

🔨 Build the Ember Addon/Engine
Run backend checks:

```bash
pnpm build
composer test:lint
composer test:types
composer test:unit
composer test
```

## Configuration

Storefront configuration is provided through the Laravel package config files and environment variables:

- `server/config/storefront.php`: API routing, Storefront app verification settings, database connection, and request throttling.
- `server/config/api.php`: Storefront API configuration.
- `server/config/database.connections.php`: Storefront database connection defaults.

Important environment variables include:

| Variable | Purpose |
| --- | --- |
| `STOREFRONT_DB_CONNECTION` | Database connection name for Storefront models. |
| `STOREFRONT_BYPASS_VERIFICATION_CODE` | Development bypass code for Storefront app verification flows. |
| `STOREFRONT_THROTTLE_REQUESTS_PER_MINUTE` | Public Storefront API request limit. |
| `STOREFRONT_THROTTLE_DECAY_MINUTES` | Public Storefront API throttle decay window. |

For customer app configuration, see the [Storefront App configuration docs](https://www.fleetbase.io/docs/storefront/app/configuration).

## Documentation

- [Storefront documentation](https://www.fleetbase.io/docs/storefront)
- [Products and catalog](https://docs.fleetbase.io/guides/storefront/products/)
- [Orders and checkout](https://www.fleetbase.io/docs/storefront/orders/overview)
- [Checkout flow](https://www.fleetbase.io/docs/storefront/orders/checkout)
- [Store locations](https://www.fleetbase.io/docs/storefront/stores/store-locations)
- [Storefront App configuration](https://www.fleetbase.io/docs/storefront/app/configuration)

## Contributing
See the Contributing Guide for details on how to contribute to this project.

Storefront follows the same review expectations as the rest of Fleetbase:

- Keep changes small and reviewable.
- Preserve existing architecture and naming conventions.
- Add or update tests when practical.
- Run the relevant frontend or backend validation commands before opening a pull request.
- For API behavior changes, check whether the API specification and public documentation also need updates.

See [CONTRIBUTING.md](CONTRIBUTING.md) for general contribution guidance.

## License
This project is licensed under the MIT License.

Fleetbase Storefront is open-source software licensed under the [AGPL-3.0-or-later](LICENSE.md).
58 changes: 3 additions & 55 deletions addon/components/customer-panel/orders.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,7 @@
</td>
<td>
<div>
{{#if order.isFresh}}
<Button
@size="xs"
@type="success"
@iconPrefix="fas"
@icon="check"
@text={{concat (t "storefront.component.widget.orders.accept-order") "!"}}
@onClick={{fn this.acceptOrder order}}
/>
{{/if}}
{{#if (eq order.status "accepted")}}
<Button
@size="xs"
@type="success"
@icon="bell-concierge"
@text={{t "storefront.component.widget.orders.mark-as-ready"}}
@onClick={{fn this.markAsReady order}}
/>
{{/if}}
{{#if order.isPickupReady}}
<Button
@size="xs"
@type="success"
@icon="check"
@text={{t "storefront.component.widget.orders.mark-as-completed"}}
@onClick={{fn this.markAsCompleted order}}
/>
{{/if}}
</div>
<div>
<Button @size="xs" @type="danger" @icon="ban" @text="Cancel" @onClick={{fn this.cancelOrder order}} />
<Storefront::Order::Actions @order={{order}} @onChange={{this.handleOrderChange}} @showText={{true}} />
</div>
</td>
</tr>
Expand All @@ -85,29 +55,7 @@
</div>
<div class="flex flex-row space-x-2 flex-wrap">
<Button @size="xs" @type="primary" @icon="eye" @text={{t "storefront.common.view"}} @onClick={{fn this.viewOrder order}} />
<Button
@size="xs"
@type="default"
@icon="id-card"
@text={{if order.has_driver_assigned (t "storefront.component.widget.order.change-driver") (t "storefront.component.widget.order.assign-driver")}}
@onClick={{fn this.assignDriver order}}
/>
{{#if order.isFresh}}
<Button
@size="xs"
@type="success"
@iconPrefix="fas"
@icon="check"
@text={{concat (t "storefront.component.widget.orders.accept-order") "!"}}
@onClick={{fn this.acceptOrder order}}
/>
{{/if}}
{{#if (eq order.status "accepted")}}
<Button @size="xs" @type="success" @icon="bell-concierge" @text={{t "storefront.component.widget.orders.mark-as-mark"}} @onClick={{fn this.markAsReady order}} />
{{/if}}
{{#if order.isPickupReady}}
<Button @size="xs" @type="success" @icon="check" @text={{t "storefront.component.widget.orders.mark-as-completed"}} @onClick={{fn this.markAsCompleted order}} />
{{/if}}
<Storefront::Order::Actions @order={{order}} @onChange={{this.handleOrderChange}} @showText={{true}} />
</div>
<ContentPanel @title={{t "storefront.component.widget.orders.title"}} class="mt-2">
<div class="flex flex-col py-2 border-t dark:border-gray-800">
Expand Down Expand Up @@ -146,4 +94,4 @@
</div>
{{/each}}
</div>
</Layout::Section::Body>
</Layout::Section::Body>
Loading
Loading