Skip to main content

Getting Started with LEGO SaaS SDK

What is LEGO?

LEGO (Lightweight, Extensible, Granular, and Orchestrated) is a stateful library framework that encapsulates common capabilities needed in >80% of SaaS solutions. It significantly reduces development time and costs by providing reusable, standardized building blocks.

Quick Start Guide

1. Prerequisites

Before you begin, ensure you have:

  • Java 11 or higher
  • Maven 3.6+
  • Spring Boot 2.7+ or 3.0+
  • Access to Bosch internal Maven repositories

2. Basic Setup

Add the LEGO parent dependency to your pom.xml:

<properties>
<lego.version>1.0.7</lego.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.bosch.bd.lego</groupId>
<artifactId>lego-bom</artifactId>
<version>${lego.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

3. Core Configuration

Start with the essential LEGOs for any SaaS application:

Tenant Configuration

<dependency>
<groupId>com.bosch.bd.lego</groupId>
<artifactId>lego-config-core</artifactId>
</dependency>
<dependency>
<groupId>com.bosch.bd.lego</groupId>
<artifactId>lego-config-rest</artifactId>
</dependency>

SSO (Single Sign-On)

<dependency>
<groupId>com.bosch.bd.lego</groupId>
<artifactId>lego-sso-spring-security</artifactId>
</dependency>
<dependency>
<groupId>com.bosch.bd.lego</groupId>
<artifactId>lego-sso-keycloak</artifactId>
</dependency>

4. Application Configuration

Add the following to your application.yml:

spring:
security:
resourceserver:
jwt:
issuers:
- https://p61.authz.bosch.com/auth/realms/myrealm

lego:
api:
urlBase: /api/1
config:
azure:
blobconnection: ${AZURE_BLOB_CONNECTION_STRING}
blobContainerId: ${AZURE_CONTAINER_ID}

Working with the LEGO API

The LEGO framework provides a comprehensive REST API for managing tenants, users, workflows, and documents. Here are practical examples using the actual API endpoints:

Tenant Management

Create a New Tenant

curl -X PUT "https://your-app.com/api/1/legos/tenants" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "tenant-001",
"name": {
"en": "Acme Corporation"
},
"description": {
"en": "Acme Corporation tenant configuration"
},
"owningEntity": "PS/EBT",
"legos": [
{
"id": "lego-sso",
"enabled": true,
"config": {
"allowedOrigins": ["https://acme.com"]
}
}
]
}'

List All Tenants

curl -X GET "https://your-app.com/api/1/legos/tenants" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"

User and Identity Management

Get Current User Profile

curl -X GET "https://your-app.com/api/1/legos/sso/identities/users/me" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"

List All Users in Tenant

curl -X GET "https://your-app.com/api/1/legos/sso/identities/users" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"

Create User Invitation

curl -X PUT "https://your-app.com/api/1/legos/sso/invitations" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"roles": ["APPLICATION_USER"],
"message": "Welcome to our platform!"
}'

Document Management

Upload Documents

curl -X POST "https://your-app.com/api/1/legos/docmanager/documents" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-F "files=@document.pdf"

Search Documents

curl -X PUT "https://your-app.com/api/1/legos/docmanager/documents" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "invoice",
"filters": {
"documentType": "invoice",
"dateRange": {
"from": "2024-01-01",
"to": "2024-12-31"
}
},
"pageIndex": 0,
"pageSize": 20
}'

Download Document

curl -X GET "https://your-app.com/api/1/legos/docmanager/documents/download?uri=document-uri" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
--output downloaded-document.pdf

Workflow Management

Create New Workflow

curl -X POST "https://your-app.com/api/1/legos/workflows" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"legoId": "lego-workflow",
"customFields": {
"requestType": "approval",
"priority": "high",
"description": "Budget approval request"
}
}'

Search Todo Workflows

curl -X GET "https://your-app.com/api/1/legos/workflows/search/todo?pageIndex=0&pageSize=10" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"

Application Information

Update Application Info

curl -X PUT "https://your-app.com/api/1/legos/appinfo" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"warnings": [
{
"id": "maintenance-notice",
"title": {
"en": "Scheduled Maintenance"
},
"message": {
"en": "System will be unavailable on Sunday from 2-4 AM"
},
"severity": "WARNING",
"active": true
}
],
"generalInfo": [
{
"id": "new-feature",
"title": {
"en": "New Feature Available"
},
"message": {
"en": "Document search functionality is now available!"
},
"active": true
}
]
}'

Java Integration Examples

Tenant Service Integration

import com.bosch.bd.lego.api.tenant.TenantService;
import com.bosch.bd.lego.api.tenant.TenantInfo;
import com.bosch.bd.lego.api.common.I18NText;

@Service
public class TenantManagementService {

@Autowired
private TenantService tenantService;

public void createTenant(String tenantId, String name, String description) {
TenantInfo tenant = TenantInfo.builder()
.id(tenantId)
.name(I18NText.builder().en(name).build())
.description(I18NText.builder().en(description).build())
.owningEntity("PS/EBT")
.build();

tenantService.createOrUpdate(tenant);
}

public List<TenantInfo> getAllTenants() {
return tenantService.getAllTenants();
}
}

Document Management Integration

import com.bosch.bd.lego.api.docmanager.DocumentService;
import com.bosch.bd.lego.api.docmanager.SearchQuery;

@Service
public class DocumentService {

@Autowired
private DocumentService documentService;

public void uploadDocument(MultipartFile file) {
documentService.uploadDocuments(Arrays.asList(file));
}

public DocumentPage searchDocuments(String query, int pageIndex, int pageSize) {
SearchQuery searchQuery = SearchQuery.builder()
.query(query)
.pageIndex(pageIndex)
.pageSize(pageSize)
.build();

return documentService.searchDocuments(searchQuery);
}
}

Error Handling

The LEGO API returns standardized error responses:

{
"error": "INVALID_REQUEST",
"message": "Invalid tenant configuration",
"details": "Tenant ID cannot be empty"
}

Common HTTP status codes:

  • 200 - Success
  • 400 - Bad Request (invalid input)
  • 401 - Unauthorized (missing or invalid token)
  • 403 - Forbidden (insufficient permissions)
  • 404 - Not Found
  • 413 - Payload Too Large

Security and Authentication

All LEGO API endpoints require authentication using JWT tokens from Bosch CIAM. Include the token in the Authorization header:

Authorization: Bearer YOUR_JWT_TOKEN

For tenant-specific operations, also include the tenant header:

X-Tenant-ID: your-tenant-id

Next Steps

  1. Explore Available LEGOs: Check the LEGO Marketplace for available building blocks
  2. Read Detailed Guides: Visit the User Guides for comprehensive documentation
  3. Review API Reference: Explore the complete API Reference for all available endpoints
  4. Join the Community: Contact the Lego Support Team for questions and support

Business Impact

With the continuous growth of reusable LEGO building blocks in the marketplace, assembly time and costs for building software solutions are significantly reduced while maintaining high quality. It creates a "flywheel" effect where LEGOs become more intelligent and broadly capable through real customer project usage and feedback.

Get Support

For questions, issues, or contributions: