Skip to content

Commit

Permalink
Merge pull request #42 from event-catalog/fix-custom-registry-eventbr…
Browse files Browse the repository at this point in the history
…idge

fix(plugin): fixed issue using channels and custom registries
  • Loading branch information
boyney123 authored Feb 6, 2025
2 parents 56c9492 + fa18d2d commit 0d7c686
Show file tree
Hide file tree
Showing 16 changed files with 322 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-eyes-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/generator-eventbridge": patch
---

fix(plugin): fixed issue using channels and custom registries
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ All plugins require a license key. You can get a license key from [EventCatalog
**EventBridge Integrations**

- [Import EventBridge schemas into EventCatalog using schema discovery](./examples/generator-eventbridge/basic/)
- [Import EventBridge schemas into EventCatalog using a custom schema registry](./examples/generator-eventbridge/custom-registry/)

**Backstage Integrations**

Expand Down
41 changes: 41 additions & 0 deletions examples/generator-eventbridge/custom-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# EventCatalog EventBridge Example - Custom Registry

This example shows you how to ingest events from EventBridge into EventCatalog using a custom registry.

EventBridge Schema Registry lets you define your own registry and upload schemas into it.

This example shows you how to connect to that schema registry and import the schemas into EventCatalog.

## Prerequisites

- AWS Account

## Setup

1. Clone this project
1. Run `npm install`
1. Get a EventCatalog license key from [EventCatalog](https://eventcatalog.cloud) (14 day free trial)
1. Run the init.sh script to create a custom schema registry in EventBridge
1. Run the upload-schemas.sh script to upload the schemas to the custom schema registry
1. Run the `npm run generate` command to generate EventCatalog from EventBridge (events mapped to schemas in eventcatalog.config.js)
1. Run the catalog `npm run dev`
1. View your catalog at http://localhost:3000

### Features of the EventBridge Generator

- Add semantic meaning to your schemas
- Import schemas, and add markdown to them. Between builds the markdown will be persisted.
- This allows you to add documentation to your schemas and give them business meaning
- Document your event bus as a channel
- View all messages going through your event bus
- Map events from EventBridge to domains, services and messages
- Downloads schemas directly into EventCatalog
- Use filters to only parse certain events you want.
- Auto versioning of domains, services and messages
- And much more...

To dive into how this plugin can help you, you can read the [EventBridge Plugin Docs](https://www.eventcatalog.dev/integrations/eventbridge)




Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import path from "path";
import url from "url";

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

/** @type {import('@eventcatalog/core/bin/eventcatalog.config').Config} */
export default {
cId: "10b46030-5736-4600-8254-421c3ed56e47",
title: "EventCatalog",
tagline: "Discover, Explore and Document your Event Driven Architectures",
organizationName: "Your Company",
homepageLink: "https://eventcatalog.dev/",
editUrl: "https://github.com/boyney123/eventcatalog-demo/edit/master",
// By default set to false, add true to get urls ending in /
trailingSlash: false,
// Change to make the base url of the site different, by default https://{website}.com/docs,
// changing to /company would be https://{website}.com/company/docs,
base: "/",
// Customize the logo, add your logo to public/ folder
logo: {
alt: "EventCatalog Logo",
src: "/logo.png",
text: "EventCatalog",
},
docs: {
sidebar: {
// Should the sub heading be rendered in the docs sidebar?
showPageHeadings: true,
},
},
generators: [
[
'@eventcatalog/generator-eventbridge',
{
region: 'us-east-1',
// Name of the registry in EventBridge, if you are using EventBridge Schema discovery this should be discovered-schemas
registryName: 'my-custom-registry',
services: [
{ id: 'Orders Service', version: '1.0.0', sends: [{ source: ['OrderPlaced']}] },
{ id: 'Inventory Service', version: '1.0.0', sends: [{ source: ['InventoryChanged']}], receives: [{ source: ['OrderPlaced']}] },
],
// This service is mapped into the orders domain
domain: { id: 'orders', name: 'Orders', version: '0.0.1' },
},
],
[
'@eventcatalog/generator-eventbridge',
{
region: 'us-east-1',
// Name of the registry in EventBridge, if you are using EventBridge Schema discovery this should be discovered-schemas
registryName: 'my-custom-registry',
services: [
{ id: 'Payments Service', version: '1.0.0', sends: [{ source: ['PaymentProcessed']}], receives: [{ source: ['OrderPlaced']}] },
],
// This service is mapped into the orders domain
domain: { id: 'payments', name: 'Payments', version: '0.0.1' },
},
]
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Custom styling support coming soon. */
17 changes: 17 additions & 0 deletions examples/generator-eventbridge/custom-registry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "openapi-basic-example",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "eventcatalog dev",
"build": "eventcatalog build",
"start": "eventcatalog start",
"preview": "eventcatalog preview",
"generate": "eventcatalog generate",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@eventcatalog/core": "latest",
"@eventcatalog/generator-eventbridge": "latest"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Create a custom schema registry
aws schemas create-registry --registry-name my-custom-registry --description "Custom registry for demo" --region us-east-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# Set AWS region
AWS_REGION="us-east-1" # Change this to your desired region

# Sample schemas
declare -a schemas=(
"UserCreated"
"OrderPlaced"
"PaymentProcessed"
"ProductUpdated"
"InventoryChanged"
"InventoryUpdated"
"OrderShipped"
"OrderCreated"
"OrderCancelled"
"OrderPaid"
"OrderShipped"
"OrderDelivered"
"OrderReturned"
)

# Create custom schema registry if it doesn't exist
aws schemas create-registry \
--registry-name "my-custom-registry" \
--description "Custom registry for sample schemas" \
--region $AWS_REGION > /dev/null 2>&1

# Schema content for each event type
for schema in "${schemas[@]}"
do
echo "Creating schema: $schema"

# Create schema content
SCHEMA_CONTENT=$(cat <<EOF
{
"\$schema": "http://json-schema.org/draft-07/schema#",
"title": "${schema}Event",
"type": "object",
"properties": {
"eventType": {
"type": "string",
"description": "The type of the event",
"enum": ["${schema}"]
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "The time when the event occurred"
},
"data": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Unique identifier"
},
"name": {
"type": "string",
"description": "Name associated with the event"
}
}
}
},
"required": ["eventType", "timestamp", "data"]
}
EOF
)

# Create schema in the registry
aws schemas create-schema \
--registry-name "my-custom-registry" \
--schema-name "${schema}" \
--content "$SCHEMA_CONTENT" \
--type "JSONSchemaDraft4" \
--region $AWS_REGION > /dev/null 2>&1

echo "Schema ${schema} created successfully"
done

echo "All schemas have been uploaded to the registry"
26 changes: 26 additions & 0 deletions examples/generator-eventbridge/custom-registry/teams/full-stack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
id: full-stack
name: Full stackers
summmary: Full stack developers based in London, UK
members:
- dboyne
- asmith
- msmith
email: test@test.com
slackDirectMessageUrl: https://yourteam.slack.com/channels/boyney123
---

## Overview

The Full Stack Team is responsible for developing and maintaining both the front-end and back-end components of our applications. This team ensures that the user interfaces are intuitive and responsive, and that the server-side logic and database interactions are efficient and secure. The Full Stack Team handles the entire lifecycle of web applications, from initial development to deployment and ongoing maintenance.

## Responsibilities

### Key Responsibilities
- **Front-End Development**: Design and implement user interfaces using modern web technologies (e.g., HTML, CSS, JavaScript, React).
- **Back-End Development**: Develop and maintain server-side logic, APIs, and database interactions (e.g., Node.js, Express, SQL/NoSQL databases).
- **Integration**: Ensure seamless communication between the front-end and back-end components.
- **Performance Optimization**: Optimize the performance and scalability of web applications.
- **Testing and Debugging**: Write and maintain unit, integration, and end-to-end tests to ensure the quality and reliability of the applications.
- **Deployment**: Manage the deployment of applications to production environments using CI/CD pipelines.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
id: mobile-devs
name: The mobile devs
members:
- dboyne
---

The Mobile Devs team is responsible for the development and maintenance of the mobile applications for our company. This includes the iOS and Android apps that customers use to interact with our services, make purchases, and manage their accounts. The team ensures that the mobile apps are user-friendly, secure, and performant.

## Responsibilities

### 1. Mobile Application Development
- **Platform Support**: Developing and maintaining apps for iOS and Android platforms.
- **Feature Implementation**: Implementing new features based on product requirements and user feedback.
- **User Interface Design**: Ensuring a consistent and intuitive user interface across all mobile platforms.
- **Performance Optimization**: Optimizing the performance of mobile apps to ensure fast and smooth user experiences.

### 2. Integration with Backend Services
- **API Integration**: Integrating mobile apps with backend services using RESTful APIs and other communication protocols.
- **Real-time Updates**: Implementing real-time data updates and synchronization with backend services.
27 changes: 27 additions & 0 deletions examples/generator-eventbridge/custom-registry/users/aSmith.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
id: asmith
name: Amy Smith
avatarUrl: https://randomuser.me/api/portraits/women/48.jpg
role: Product owner
---

Hello! I'm Amy Smith, the Product Owner of the innovative Full Stackers team. With a strong focus on delivering exceptional value, I specialize in connecting business objectives with technical solutions to create products that users love.

### About Me

With a comprehensive background in product management and a solid understanding of software development, I bring a unique perspective to the table. My career has been driven by a passion for understanding user needs, defining clear product visions, and leading teams to successful product deliveries.

### What I Do

As the Product Owner for Full Stackers, my role involves a wide range of responsibilities aimed at ensuring our products are both high-quality and user-centric. Key aspects of my role include:

- **Product Vision & Strategy**: Defining and communicating the long-term vision and strategy for our products, ensuring alignment with the company's objectives and market demands.
- **Roadmap Planning**: Developing and maintaining a product roadmap that highlights key features and milestones, prioritizing tasks based on their business value and user feedback.
- **Stakeholder Management**: Engaging with stakeholders across the organization to gather requirements, provide updates, and ensure everyone is aligned on the product's direction.
- **User-Centric Design**: Championing the end-users by conducting user research, analyzing feedback, and ensuring our products effectively solve their problems.
- **Agile Leadership**: Leading the development process using Agile methodologies, facilitating sprint planning, and ensuring the team has clear priorities and objectives.

My mission is to deliver products that not only meet but exceed customer expectations. I thrive on the challenge of translating complex requirements into simple, intuitive solutions.

If you’re interested in product management, user experience, or discussing the latest trends in technology, feel free to reach out!

32 changes: 32 additions & 0 deletions examples/generator-eventbridge/custom-registry/users/dboyne.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
id: dboyne
name: David Boyne
avatarUrl: "https://pbs.twimg.com/profile_images/1262283153563140096/DYRDqKg6_400x400.png"
role: Lead developer
email: test@test.com
slackDirectMessageUrl: https://yourteam.slack.com/channels/boyney123
---

Hello! I'm David Boyne, the Tech Lead of an amazing team called Full Stackers. With a passion for building robust and scalable systems, I specialize in designing and implementing event-driven architectures that power modern, responsive applications.

### About Me

With over a decade of experience in the tech industry, I have honed my skills in full-stack development, cloud computing, and distributed systems. My journey has taken me through various roles, from software engineer to architect, and now as a tech lead, I am committed to driving innovation and excellence within my team.

### What I Do

At Full Stackers, we focus on creating seamless and efficient event-driven architectures that enhance the performance and scalability of our applications. My role involves:

- **Architecture Design**: Crafting scalable and resilient system architectures using event-driven paradigms.
- **Team Leadership**: Guiding a talented team of developers, fostering a collaborative and innovative environment.
- **Code Reviews & Mentorship**: Ensuring code quality and sharing knowledge to help the team grow.
- **Stakeholder Collaboration**: Working closely with other teams and stakeholders to align our technical solutions with business goals.
- **Continuous Improvement**: Advocating for best practices in software development, deployment, and monitoring.

I am passionate about leveraging the power of events to build systems that are not only highly responsive but also easier to maintain and extend. In an ever-evolving tech landscape, I strive to stay ahead of the curve, continuously learning and adapting to new technologies and methodologies.

Feel free to connect with me to discuss all things tech, event-driven architectures, or to exchange ideas on building better software systems!

---
*David Boyne*
*Tech Lead, Full Stackers*
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: msmith
name: Martin Smith
avatarUrl: "https://randomuser.me/api/portraits/men/51.jpg"
role: Senior software engineer
---

As a Senior Mobile Developer on The Mobile Devs team, I play a key role in designing, developing, and maintaining our company’s mobile applications. My focus is on creating a seamless and intuitive user experience for our customers on both iOS and Android platforms. I work closely with cross-functional teams, including backend developers, UX/UI designers, and product managers, to deliver high-quality mobile solutions that meet business objectives and exceed user expectations.
2 changes: 1 addition & 1 deletion packages/generator-eventbridge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const processEvents = async (events: Event[], options: GeneratorProps) => {
schemaPath,
markdown: messageMarkdown,
badges: getBadgesForMessage(event, options.eventBusName),
channels: eventChannel,
...(eventChannel.length > 0 && { channels: eventChannel }),
});

console.log(chalk.cyan(` - Event (${event.id} v${event.version}) created`));
Expand Down
3 changes: 0 additions & 3 deletions packages/generator-eventbridge/src/test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ describe('EventBridge EventCatalog Plugin', () => {
expect(event).toEqual({
id: 'UserSignedUp',
name: 'UserSignedUp',
channels: [],
version: '1',
markdown: expect.any(String),
schemaPath: 'myapp.users@UserSignedUp-jsondraft.json',
Expand All @@ -313,7 +312,6 @@ describe('EventBridge EventCatalog Plugin', () => {
expect(event).toEqual({
id: 'UserSignedUp',
name: 'UserSignedUp',
channels: [],
version: '1',
markdown: expect.any(String),
schemaPath: 'myapp.users@UserSignedUp-jsondraft.json',
Expand Down Expand Up @@ -532,7 +530,6 @@ describe('EventBridge EventCatalog Plugin', () => {
expect(event).toEqual({
id: 'UserSignedUp',
name: 'UserSignedUp',
channels: [],
version: '1',
markdown: expect.any(String),
schemaPath: 'myapp.users@UserSignedUp-jsondraft.json',
Expand Down

0 comments on commit 0d7c686

Please sign in to comment.