This doc underlines the architectural implementational details of reference Beckn Provider Platform (BPP) implementation for the Courses and Training track complaint to DSEP spec v1.0.0.
The reference BPP implemented in this repository is onboarded on the Beckn Gateway and Beckn Gateway Registry under the Courses and Trainings category.
- BPP Deployed URL
- BAP Deployed URL
- BPP Network Participant Id: bpp.dsep.samagra.io
- Network Participant Information on Beckn Registry
Programming Language: TypeScript Framework: NestJS Database: Postgres exposed via Hasura Runtime: Node v16.19.0
This reference implementation contains all three network participants, i.e. Beckn Provider Platform, Beckn Gateway, Beckn Provider Platform, organised as a NestJS Monorepo.
.
├── apps
│ ├── bap
│ ├── bg
│ └── bpp
├── docs
│ └── examples
├── tsconfig.build.json
├── tsconfig.json
├── types
│ └── schema.ts
├── utils
│ ├── generators.ts
│ ├── types.ts
│ └── utils.ts
├── nest-cli.json
├── package.json
├── README.md
└── yarn.lockThe apps directory contains the actual apps for each network participant
apps/bap and apps/bg contains the code for a sample Beckn Application Platform and Beckn Gateway respectively for testing the Beckn Provider Platform.
More details about each network participant and their implementation can be found their following directories here as:
The reference app is a Course Discovery Platform that talks in Decentralised Skilling and Education Protocol and curates courses from various providers like, Swayam Portal, MIT OCW, Udemy, etc., right now only swayam is onboarded as a provider, other platforms can be easily onboarded onto the BPP.
The /search request is forwarded to the Beckn Gateway with the domain of dsep:courses so that reaches our reference BPP. The BPP then forwards the search request to the Swayam Provider Wrapper which translates the Beckn compliant search request into a search query compatible to be forwarded to the Swayam Portal and fetches the result from there. The fetched results are then again converted in Beckn /on_search compliant response and forwarded to the BPP, which then calls the /on_back endpoint on the bap_uri present in the search requests's context. The sample BAP implementation for the demonstration of end to end flow right now, forwards the request to the client proxy which determines which client the request belongs to based on the message_id and transaction_id in the context of the on_search request and forwards the response to the concerned client.
The client and client proxy are connected together via a websocket connection using redis and socket.io to create a publish-subscribe model to support the asynchronous nature of Beckn APIs. (To learn more about the Beckn APIs and their structure refer the official Beckn Protocol Website)
/search: This method/endpoint allows for searching of courses and training via a direct DSEP complaint request to the BPP using the context.domain as dsep:courses
/select: This method/endpoint is allows for selecting some courses or trainings to be enrolled in/purchased by the user. The context domain for this method should be dsep:courses. In the reference course discovery platform implementation this endpoint is called when expanding a particular course to view its details.
/init: This method/endpoint is allows for initiating purchasing a course or training by getting a quote from the provider and entering personal details required for enrollment. The context domain for this method should be dsep:courses.
/confirm: This method/endpoint indicated the confirmation of an order after successful payment/enrollment. In the reference course discovery platform implementation this endpoint is called when visiting the course on the external website.
Follow the following steps to setup the monorepo locally on your system.
-
Clone the repository
git clone https://github.com/Samagra-Development/dsep
-
Navigate into the directory where you have cloned the repository
cd /path/to/cloned/repository-
Install the required dependencies using the package manager of your choice (yarn preferred).
yarn install
-
Create a
.envfile similar to the.env,samplefile and populate it with required credentials -
Install Docker, Install Docker Compose, and run
docker compose up
-
Navigate to your hasura UI which will be started after running the command in
Step 5and create a table nameddsep_courses. -
Run the services for the required network participant using the following commands
yarn start <bap | bg | bpp> # replace <bap | bg | bpp> with a single name # for example: yarn start bpp will start the BPP
Or start all of them together using
bash yarn start:all # this will start all the services
-
Install Docker, Install Docker Compose, and run
docker compose up
-
PM2 Based Deployment
yarn build pm2 start dist/apps/bpp/main.js --name beckn-bpp pm2 start dist/apps/bap/main.js --name beckn-bap pm2 start dist/apps/bg/main.js --name beckn-bg
- Mock Provider (Swayam)
- BAP Client Proxy - Acts as a service connecting Client and Proxy
- BAP Client - A course search page
Follow this guide to onboard yourself on the Beckn Registry.
- Author: Yash Mittal
- Mentor on the project: Chakshu Gautam
