The sample is based on a simple API written for a social-media site (like twitter) which has users, associated posts and followers. Following is the high level component diagram.
Following is the entity relationship diagram.
Following is the service description.
type SocialMedia service object {
*http:Service;
// users resource
resource function get users() returns User[]|error;
resource function get users/[int id]() returns User|UserNotFound|error;
resource function post users(@http:Payload NewUser newUser) returns http:Created|error;
resource function delete users/[int id]() returns http:NoContent|error;
// posts resource
resource function get users/[int id]/posts() returns PostMeta[]|UserNotFound|error;
resource function post users/[int id]/posts(@http:Payload NewPost newPost) returns http:Created|UserNotFound|PostForbidden|error;
};
Following are the features covered by the scenario.
- Writing REST APIs with verbs, URLs, data binding and status codes
- Accessing databases
- Configurability
- Data transformation with the data mapper
- HTTP client
- Resiliency - Retry
- Writing tests
- Using connectors - Twilio
- OpenAPI specification, client stubs and central
- Adding validations
- Security - OAuth2
- Error handlers
- Ballerina concurrency
- Integrating a message broker
- Observability - Tracing
- Docker image generation
You can use the below docker compose commands.
- docker compose up
- To send request open
social-media-request.http
file using VS Code withREST Client
extension - Jaeger URL - http://localhost:16686/search