We will try to understand the use of each file present on CAP (Cloud Application Programming) app and which also check the flow of execution.
CAP App structure
Use the below command to create a CAP Application -
1. app folder
The app folder contains frontend applications, typically SAP Fiori Elements apps, SAPUI5 applications file and It is not mandatory, but used when you want UI inside the same project.
2. db folder
It contains your CDS (Core Data Service) entities and database artifacts.
it creates tables in HANA / SQLite, defines relationships, etc.
3. srv folder
This folder contains your services(.cds file) and business logic(.js file).
It exposes OData or REST APIs.
4. .cdsrc.json
This is the CAP configuration file.
It contains settings like database type, external services, authentication, etc.
It also contains CAP runtime configuration.
5. mta.yaml
Multi-Target App descriptor for Cloud Foundry deployment.
It defines your modules (srv, db, approuter) and resources (HDI container, XSUAA).
Used when you build/deploy to BTP.
6. package.json
This is the main Node.js project file.
It contains-
- Dependencies (like @sap/cds)
- Scripts (start, build, etc.)
- Project configuration
Means, It contains project dependencies and settings.
7. package-lock.json
This file locks the exact versions of dependencies.
It ensures everyone installs the same versions.
So this file is known for version control for dependencies.
8. xs-security.json
This file is used for authentication and authorization (XSUAA).
It defines roles, scopes, and security settings.
What happens when you run the app locally
Build time:
Deploy time:
Runtime:
And it is done, You can deploy your app and use it. !!!