Account Service

The Account Service is an asynchronous messaging service that manages user accounts in the system. It uses MQTT protocol for real-time communication and publishes events related to user account activities.

Overview

  • Version: 1.0.0
  • Protocol: MQTT
  • License: Apache 2.0

Description

This service manages user accounts in the system and publishes events when significant account-related activities occur, such as user registrations.

Server Information

Production Server

  • URL: mqtt://test.mosquitto.org
  • Protocol: MQTT
  • Description: Test MQTT broker

Events

User Signed Up Event

The service publishes a UserSignedUp event when a new user registers in the system.

Channel: user/signedup

Message Format:

{
  "firstName": "string",
  "lastName": "string", 
  "email": "string (email format)",
  "createdAt": "string (date-time format)"
}

Properties:

  • firstName: User's first name
  • lastName: User's last name
  • email: User's email address (must be valid email format)
  • createdAt: Timestamp when the user account was created (ISO 8601 format)

Usage

Subscribing to Events

To receive user sign-up notifications, subscribe to the user/signedup channel:

// Example using MQTT.js
const mqtt = require('mqtt');
const client = mqtt.connect('mqtt://test.mosquitto.org');

client.on('connect', () => {
  client.subscribe('user/signedup');
  console.log('Subscribed to user sign-up events');
});

client.on('message', (topic, message) => {
  if (topic === 'user/signedup') {
    const userSignedUpEvent = JSON.parse(message.toString());
    console.log('New user signed up:', userSignedUpEvent);
    
    // Process the user sign-up event
    handleUserSignUp(userSignedUpEvent);
  }
});

Event Processing

When you receive a UserSignedUp event, you can process it to:

  • Send welcome emails to new users
  • Initialize user profiles
  • Trigger onboarding workflows
  • Update analytics and metrics
  • Sync with external systems

AsyncAPI Specification

The complete AsyncAPI specification for this service is available in spec.yaml. This specification defines:

  • Message schemas and formats
  • Channel definitions
  • Server configurations
  • Component definitions

Integration

This service integrates with the broader system architecture by:

  1. Publishing Events: Emits user sign-up events when new accounts are created
  2. MQTT Messaging: Uses MQTT for reliable, real-time event delivery
  3. JSON Payloads: Sends structured JSON messages with user information

Development

Prerequisites

  • MQTT client library for your programming language
  • Access to the MQTT broker (mqtt://test.mosquitto.org)

Testing

You can test the service by:

  1. Connecting to the MQTT broker
  2. Subscribing to the user/signedup channel
  3. Monitoring for incoming user sign-up events

License

This project is licensed under the Apache License 2.0 - see the Apache 2.0 License for details.