A full-stack application simulating company buy/sell operations with role-based access control, multi-cart support, and order lifecycle management. Built with SAP Cloud Application Programming Model (CAP) on the backend and SAPUI5 on the frontend, deployed to SAP BTP Cloud Foundry.
- SAP CAP backend (Node.js, OData V4) with a 6-entity domain model and
@restrict-based RBAC - SAPUI5 frontend (
sap_horizon_darktheme) with a service-layer architecture and reusable fragments - Transactional cart finalization — atomic stock decrement (
UPDATE ... WHERE stock >= qty) prevents overselling under concurrency - Background jobs via
node-cron— cart abandonment detection and automatic order status progression - Excel integration — bulk product upload via generated
.xlsxtemplate (exceljsserver-side,XLSXclient-side) - Tested: 49 backend Jest tests (
@cap-js/cds-test) + 121 frontend QUnit tests (Karma, headless Chrome), both in CI - Cloud-ready: MTA deployment to SAP BTP Cloud Foundry with HANA Cloud, XSUAA and the HTML5 Application Repository
- Node.js >= 18 (LTS recommended)
- npm >= 9
- SAP CDS CLI - installed globally:
npm install -g @sap/cds-dkVerify the installation with
cds --version.
git clone https://github.com/Setforex7/shop-cart.git
cd shop-cartnpm installThis installs both backend (SAP CAP, Express, node-cron, exceljs) and frontend dependencies. The app uses SQLite as an in-memory database for local development - no database setup required.
npm run watch-cap_tryThis runs cds watch with auto-reload and opens the SAPUI5 app in your default browser. The app will be available at:
- UI5 App: http://localhost:4004/cap_try/webapp/index.html
- OData Service: http://localhost:4004/shop
- CDS Index Page: http://localhost:4004
The database is seeded automatically with sample companies, products, and currencies from the CSV files in
db/data/.
In local development, authentication is mocked. When prompted for credentials, use one of the following users:
| Username | Password | Role | Permissions |
|---|---|---|---|
alice |
(empty) | Admin | Full CRUD on Products, Orders, Companies, Carts |
bob |
(empty) | User | Browse products, manage own carts, place orders |
Leave the password field empty for both users.
In production the same roles are enforced by XSUAA (xs-security.json defines the ShopCart_Admin and ShopCart_User role collections).
- Log in as
bob(leave password empty). - You land on the Shop page showing all available products.
- Products display stock status with color indicators:
- Green - stock is above the minimum threshold.
- Yellow/Red - stock is low or critical.
- Click on a product to add it to your cart.
- Use the Cart panel to view items you've added.
- Adjust quantities or remove items as needed.
- You can create multiple carts for different companies.
- Once your cart is ready, click Finalize Cart.
- The system will:
- Validate that all products have enough stock.
- Create an order with all cart items.
- Deduct product stock accordingly.
- Update the company's capital.
- Mark the cart as "Ordered".
- Your order will progress automatically through statuses:
- Initiated -> Shipping (after ~2 minutes) -> Delivered (after ~5 minutes)
- Navigate to Reports to view your order history and analytics.
- Uses a Flexible Column Layout (FCL) for master-detail navigation.
- Export order data to Excel.
Admins have access to everything a regular user can do, plus:
- Navigate to Settings (visible only to admins).
- Manage Companies - Create, edit, or delete companies.
- View All Carts - Monitor all user carts across the system.
- Go to the Shop page.
- Use the Add Product button to create new products.
- Click on any product to Edit or Delete it.
- Products referenced by existing orders cannot be deleted (the backend rejects with 409) so order history is never orphaned.
- Use the Excel template feature to bulk-upload products: download the generated template, fill it in, and upload it back.
- Go to Settings > Companies.
- Add new companies with name, description, capital, and currency.
- Edit or remove existing companies.
shop-cart/
app/
cap_try/
webapp/ # SAPUI5 frontend
controller/ # View controllers (BaseController, Shop, Reports, Settings)
view/ # XML views and fragments
formatters/ # UI formatters (stock status, etc.)
i18n/ # Internationalization
model/ # UI5 models
service/ # Frontend service layer
test/unit/ # QUnit tests (121 tests, run via Karma)
ui5-deploy.yaml # Production build config (HTML5 repo zip)
router/ # Standalone approuter (entry point / XSUAA login)
db/
schema.cds # Domain model (Orders, Products, Cart, Company, etc.)
data/ # CSV seed data
srv/
shop_cart-service.cds # Service definition with RBAC annotations
shop_cart-service.js # Service handler entry point
handlers/ # Business logic handlers
cart.js # Cart operations and finalization
products.js # Product validation and cleanup
jobs.js # Background cron jobs (cart abandonment, order progression)
excel.js # Excel template generation
test/ # Backend Jest tests (49 tests, @cap-js/cds-test)
mta.yaml # Multi-target application descriptor (BTP deployment)
xs-security.json # XSUAA scopes, roles and role collections
| Command | Where | Description |
|---|---|---|
npm run watch-cap_try |
root | Start dev server with auto-reload and open the UI5 app |
npm start |
root | Start the production server |
npm test |
root | Run the backend Jest suite (49 tests) |
npm run lint |
root | Lint the codebase (ESLint, SAP CAP rules) |
npm test |
app/cap_try |
Run the frontend QUnit suite via Karma (121 tests, headless Chrome) |
npm run build |
app/cap_try |
Production UI5 build (zipped for the HTML5 Application Repository) |
- SQLite In-Memory Database - No external database needed locally. Data is seeded on every restart from CSV files in
db/data/. - OData V4 - The frontend communicates with the backend via OData V4 with
$autobatch grouping. - Role-Based Access Control - Enforced on the backend (
@restrictannotations, user-owned data filtered bycreatedBy = $user.id) and mirrored on the frontend (conditional UI visibility). - Background Jobs -
node-cronhandles cart abandonment detection (idle carts become Abandoned) and order status progression (Initiated → Shipping → Delivered).
- Backend:
npm test— 49 Jest tests over the live service using@cap-js/cds-test(cart lifecycle, stock/capital math, RBAC, Excel template, validations). - Frontend:
npm testinapp/cap_try— 121 QUnit tests run by Karma in headless Chrome (controllers, services, dialog handling). - CI: GitHub Actions runs lint + both test suites on every push/PR to
main(.github/workflows/ci.yml).
The app is deployed as a multi-target application (MTA): CAP backend bound to SAP HANA Cloud and XSUAA, a standalone approuter as the authenticated entry point, and the UI5 app served from the HTML5 Application Repository.
See DEPLOYMENT.md for the full step-by-step guide (entitlements, HANA Cloud setup, mbt build, cf deploy, role assignment and troubleshooting).
For local development none of this is required — everything runs on SQLite with mocked authentication.





