Home Projects Portfolio Dashboard Export PDF Log in

Mapping the Cloud: Documenting a Serverless AWS Architecture for 'Justifai'

For the justifai project, clarity in our increasingly complex serverless architecture is paramount. As microservices proliferate and responsibilities become more distributed, keeping a holistic view of the system's structure and data flows is a significant challenge.

The Challenge of Distributed Systems Documentation

Serverless applications, while offering immense flexibility and scalability, introduce a unique set of documentation challenges. With components like AWS Lambda functions, API Gateway, and various data stores interacting asynchronously, understanding the complete request lifecycle or the dependencies between services can be difficult without a clear visual aid. This complexity can hinder onboarding for new team members, slow down debugging efforts, and make architectural discussions less efficient.

Visualizing the 'Justifai' Architecture with Draw.io

To address this, we've introduced a comprehensive and editable architectural diagram for the justifai project. This draw.io file serves as a single source of truth, visually mapping out our core AWS serverless infrastructure and the crucial data flows within it. The diagram encompasses key components vital to our application's operation:

  • AWS Cognito: Manages user authentication and authorization.
  • API Gateway: Acts as the single entry point for all client requests, routing them to appropriate backend services.
  • AWS Lambda Functions: Our serverless compute layer, executing business logic in response to various events.
  • Amazon S3: Utilized for scalable object storage, often for input/output files or static assets.
  • Amazon Textract: An AI service for extracting text and data from documents, crucial for processing tasks.
  • Amazon DynamoDB: Our high-performance NoSQL database for storing application data.
  • Amazon SQS (Simple Queue Service) & DLQ (Dead-Letter Queue): Facilitate asynchronous messaging between services, ensuring reliable processing and error handling.
  • Amazon SNS (Simple Notification Service): Used for publishing messages to subscribers or triggering other services.
  • Amazon CloudWatch: For monitoring and logging all AWS resources and application activity.

By illustrating these components and their connections, the diagram provides an invaluable tool for understanding how justifai's various microservices interact and how data flows through our system. Crucially, keeping it in an editable format (like draw.io) ensures it can evolve alongside our architecture.

An Illustrative Lambda Example

Consider a simple C# Lambda function, one of many deployed within our justifai architecture, designed to process and store configuration data into DynamoDB. This exemplifies a common interaction depicted in our architectural diagram:

using Amazon.Lambda.Core;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
using System.Collections.Generic;
using System.Threading.Tasks;

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

public class ConfigProcessorFunction
{
    private readonly AmazonDynamoDBClient _dynamoDbClient = new AmazonDynamoDBClient();
    private const string TableName = "AppConfigurationTable"; // Generic table name

    public async Task<string> FunctionHandler(string configData, ILambdaContext context)
    {
        context.Logger.LogInformation($"Processing configuration data: {configData}");

        var item = new Dictionary<string, AttributeValue>
        {
            {"ConfigId", new AttributeValue { S = System.Guid.NewGuid().ToString() }},
            {"ConfigValue", new AttributeValue { S = configData }}
        };

        var request = new PutItemRequest
        {
            TableName = TableName,
            Item = item
        };

        await _dynamoDbClient.PutItemAsync(request);
        context.Logger.LogInformation("Configuration item stored in DynamoDB.");

        return $"Configuration '{configData}' successfully processed and stored.";
    }
}

This C# code snippet demonstrates a Lambda function receiving input, logging it, constructing an item, and asynchronously storing it in a DynamoDB table. This is a foundational pattern for many serverless operations shown in our architecture diagram.

Actionable Takeaway

Invest in living, editable architectural diagrams for your serverless applications. They are indispensable tools for team alignment, rapid onboarding, and efficient troubleshooting, helping you maintain control over complex distributed systems as they grow.


Generated with Gitvlg.com

Mapping the Cloud: Documenting a Serverless AWS Architecture for 'Justifai'
Seydina Limamou Laye Yade

Seydina Limamou Laye Yade

Author

Share: