cds init — Your First CAP Project

Use cds init to create a new CAP project, add a sample service, and explore the generated folder structure.

cds init — Your First CAP Project

CAP (Cloud Application Programming Model) lets you build OData services with very little boilerplate.

Make sure the CDS CLI is installed

cds --version
# @sap/cds-dk: 8.x.x

If not installed:

npm install -g @sap/cds-dk

Create a new project

cds init bookshop
cd bookshop

What gets generated

bookshop/
├── app/          ← SAPUI5 / Fiori frontends go here
├── db/           ← CDS data model files (.cds)
├── srv/          ← Service definitions (.cds) and handlers (.js)
├── .cdsrc.json   ← CDS configuration
└── package.json

Add a sample data model

Create db/schema.cds:

namespace bookshop;

entity Books {
  key ID     : Integer;
  title      : String(100);
  author     : String(50);
  stock      : Integer;
  price      : Decimal(10, 2);
}

Add a service

Create srv/cat-service.cds:

using bookshop from '../db/schema';

service CatalogService {
  entity Books as projection on bookshop.Books;
}

Add sample data

Create db/data/bookshop-Books.csv:

ID,title,author,stock,price
1,The Hobbit,J.R.R. Tolkien,100,14.99
2,Dune,Frank Herbert,75,12.50
3,Foundation,Isaac Asimov,50,11.99

Run the server

cds watch

Visit http://localhost:4004 — you'll see your OData service metadata and the Books entity.

Key facts about cds init

Sign in for progress tracking & Q&A →