DIEGO JULIÃO

SHOWCASING WORLD-CLASS SOFTWARE ENGINEERING

HArd Skills

Python

NestJS

Amazon Web Services

Typescript

Javascript

Nodejs

ReactJS

Angular

Full TIme Software Engineer

Part-TIme THRILL SEEKER

Underwater Hockey πŸ’

Underwater Rugby πŸ‰

Underwater Contact Team Sports

Certified scuba and freediverΒ 

  • Ownership

  • Transparency

  • Excellence

My Core Values

Market Enabler

AG FINANCE

World-Class Projects

Contract Generator for a Marketplace

CMA

Framework migration

VALID8 MIGRATION

Ag Finance

Market Enabler

  • πŸ‡§πŸ‡· Operates in Brazil
  • πŸ€‘ Allow Farmers to access money
  • 🌾 Acts as gateway to sell company's biological products

Ag Finance

Loans and everything to support them

  • Background checks
  • Gathering documents
  • Validating the grower's financial situation
  • Contract generation
  • Assing funds

Ag Finance

Who is involved?

  • Credit AnalystsΒ (internal & 3rd party)
  • Collateral Analysts
  • Field Referencing Analysts (3rd party)
  • Sales Representatives
  • Grower/Borrower
  • Grower/Borrower Spouse
  • Guarantor
  • etc...

Ag Finance

🧩 Extensive workflow πŸ”

Ag Finance

Why world-class?

  • πŸ€‘ Top revenue project
  • πŸ›‘οΈ Highly stable
  • ⚑ High efficient team
  • πŸ’¬ Customer-centric focus
  • πŸ“ˆ Growth x 8

What would I change?

  • Leans more towards composition instead of inheratance

Ag Finance

Indigo's Architecture

AgFinance Architecture

Ag Finance

1. Initial Improvements

🚼

We received a small project

πŸ“… πŸ”„

Two weeks adaptation period

Ag Finance

1. Initial Improvements

  • Migrate Squalize to TypeORM
  • Improve Dx
    • Dependency Injection (DI)
    • ​Decorators

Ag Finance

1. Initial Improvements

Migrate Squalize to TypeORM

  • TypeScript Support
  • Decorator-based Configuration
  • Migration Generation
@Entity('AgFinancingMatricula')
export class AgFinancingMatriculaModel extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @ManyToOne((type) => Phase2Model, (phase2) => phase2.matriculas, { nullable: true })
  phase2?: AgFinancingMatriculaModel;

  @OneToOne((type) => AgFinancingFileModel, (file) => file.id, { nullable: true })
  @JoinColumn()
  matricula?: AgFinancingFileModel;

  @OneToOne((type) => AgFinancingFileModel, (file) => file.id, { nullable: true })
  @JoinColumn()
  kml?: AgFinancingFileModel;

  @OneToMany((type) => AgFinancingMatriculaDetailModel, (detail) => detail.parent)
  @JoinColumn()
  details: AgFinancingMatriculaDetailModel[];

  @OneToMany((type) => AgFinancingFileModel, (file) => file.matricula)
  @JoinColumn()
  fieldMonitoringFiles: AgFinancingFileModel[];

  @Column({ default: false })
  includedInAnalysis: boolean;

  @Column({ default: false })
  includedInFormalization: boolean;
}

Ag Finance

1. Initial Improvements

Improve Dx

Dependency Injection (DI)

  • Decoupling of Components
  • Promote SOLID Principles
  • Support for Advanced Scenarios
  • Improve Code Quality
  • Flexibility and Reusability
@Injectable()
export default class AgFinancingMatriculaService {
  @Inject()
  private readonly agFinancingMatriculaDal: AgFinancingMatriculaDal;
  
  @Inject()
  private readonly agFinancingDal: AgFinancingDal;
  
  @Inject()
  private readonly phase2Dal: Phase2Dal;
  
  @Inject()
  private readonly matriculaDetailDal: AgFinancingMatriculaDetailDal;
  
  @Inject()
  private readonly agStateService: AgStateService;
  
  @Inject()
  private readonly creditApprovalService: CreditApprovalService;

}

Ag Finance

1. Initial Improvements

Improve Dx

GraphQL Decorators

  • Separation of Concerns
  • Declarative Syntax
  • Reusability
  • Enhanced Modularity
@Resolver()
export default class GrowerLeadResolver {
  @Inject()
  private readonly growerService: GrowerService;

  @Query()
  @Auth({ scope: Scope.BR, permissions: [PermissionNames.FA_INTERNAL, PermissionNames.FA_EXTERNAL] })
  async financingBrazilGrowerLead(parent: object, args: { leadId: string }, context: Context) {
    return this.growerService.findById(+args.leadId);
  }

  @ResolveField({ typeName: 'FinancingBrazilGrowerLead', fieldName: 'additionalInfo' })
  async lead(grower: GrowerLeadDTO, args: object, context: Context) {
    return this.growerService.getAdditionalInfo(grower, !!grower.salesforceId);
  }

  @ResolveField({ typeName: 'FinancingBrazilGrowerLead', fieldName: 'agFinancingProcesses' })
  async agFinancingProcesses(grower: GrowerLeadDTO, args: object, context: Context) {
    return this.growerService.getAgFinancingProcessesByGrower(+grower.id);
  }

  @Mutation()
  @Auth({ scope: Scope.BR, permissions: [PermissionNames.FA_ADMIN] })
  async createFinancingBrazilGrowerLead(
    parent: object,
    args: { data: FinancingBrazilGrowerLeadCreateInput },
    context: Context
  ) {
    return this.growerService.createLead(args.data);
  }
}

Ag Finance

2. Complex DB migrations

βš™οΈ πŸ—οΈ Β πŸ”§ 🧠

Due to the project's high complexity, often, we required complex DB migrations

Ag Finance

2. Complex DB migrations

  1. Planning, being thoughtful

  2. Development

  3. Staging Environment Testing

  4. Execution

  5. Monitoring and Verification

  6. Cleanup and Optimization

Ag Finance

2. Complex DB migrations

export default const mainScript: fnToExecuteType = async (dm: typeof DIManager, dbConnection: Connection): Promise<void> => {
  log.info('------- START -------');

  const currentStateDal = dm.get(AgCurrentStateDal);
  const agEventDal = dm.get(AgFinancingEventDal);
  const agStateDal = dm.get(AgStateDal);
  const agStateService = dm.get(AgStateService);
  const stateList = await currentStateDal.find({
    relations: ['agFinancing', 'agState'],
    where: {
      agState: { stateId: In([AgStateName.P3_PHYSICAL_DOCS_RECEIVED, AgStateName.P3_AWAITING_PHYSICAL_DOCS]) },
    },
  });

  for (const state of stateList) {
    await agStateService.insertAndClearStateChange(state.agFinancing.id, AgStateName.AWAITING_CONTRACT_VALIDATION);
  }

  const events = await agEventDal.find({
    agState: {
      stateId: In([
        AgStateName.P3_COMPLETE,
        AgStateName.P3_PHYSICAL_DOCS_RECEIVED,
        AgStateName.P3_AWAITING_PHYSICAL_DOCS,
      ]),
    },
  });
  for (const event of events) {
    await agEventDal.save(agEventDal.create({ id: event.id, agState: null }));
  }

  await agStateDal.delete({
    stateId: In([
      AgStateName.P3_COMPLETE,
      AgStateName.P3_PHYSICAL_DOCS_RECEIVED,
      AgStateName.P3_AWAITING_PHYSICAL_DOCS,
    ]),
  });

  log.info('------- DONE --------');
};

Ag Finance

2. Complex DB migrations

πŸ† 🌟 πŸ“ˆ

We run over 20 complex migrations successfully

Ag Finance

3. Scheduler

We required to have updates from Salesforce

  • Limited resources
  • Bad timing on implementation
  • Deadlines

Webhook is the best option, but:

Ag Finance

3. Scheduler

Implemented solution:

Scheduler or Cron Jobs β°πŸ”„

with DB lock

  • Simplicity
  • Independence
  • Development speed to meet tight deadlines

Why?

Ag Finance

3. Scheduler

  • Use Leader Election instead of DB lock
  • Using an External Scheduling Service
  • Optimize Salesforce queries
  • Consider OOO hours
  • Monitor API requests (Limits, Peaks, Warnings)

Today, What would I change?

Ag Finance

4. DevOps Leader

Go to person to perform DevOps task πŸ‘¨β€πŸ’»β­

  • CI pipelines
  • Linux servers
  • Bash scripts
  • Docker
  • Networking

Ag Finance

4. DevOps Leader

Migration from dedicated RDS to OneDB

Ag Finance

4. DevOps Leader

Terraform

data "aws_caller_identity" "current" {}

locals {
  name        = "financing-api"
  env         = var.environment
  description = "Infrastructure for financing-api"

  bucket_name = "indigo-financing-api-${local.env}-us-east-1"

  db_role = "financing_api"

  tags = {
    project     = "financing-api"
    team        = "gefion"
    environment = local.env
    product     = "AgFinancing"
    repo-name   = local.name
    slack       = "squad-gefion"
    alerts      = "@alerts-financing"
    tier        = "infra"
  }
}

resource "aws_s3_bucket" "financing_api_bucket" {
  bucket = local.bucket_name
  acl    = "private"

  tags = merge(local.tags, {
    "Name" = "Financing API Documents",
    }
  )

  versioning {
    enabled = true
  }

  cors_rule {
    allowed_headers = ["*"]
    allowed_methods = ["GET", "PUT"]
    allowed_origins = var.main_bucket_allowed_domains
    expose_headers  = ["ETag"]
    max_age_seconds = 3000
  }
}
resource "aws_s3_bucket" "financing_api_bucket_brazil" {
  bucket = "${local.bucket_name}-brazil-orders"
  acl    = "private"

  tags = merge(local.tags, {
    "Name" = "Financing API Documents for Brazil Orders",
    }
  )

  versioning {
    enabled = true
  }

  cors_rule {
    allowed_headers = ["*"]
    allowed_methods = ["GET", "PUT"]
    allowed_origins = var.main_bucket_allowed_domains
    expose_headers  = ["ETag"]
    max_age_seconds = 3000
  }
}

module "yggdrasil_remote_state" {
  source      = "app.terraform.io/indigoag/lookup_indigo_terraform_remote_state/aws"
  version     = "1.0.0"
  environment = local.env
  state_name  = "yggdrasil"
}


data "aws_iam_policy_document" "assume_role" {
  statement {
    actions = ["sts:AssumeRole"]
    effect  = "Allow"
    principals {
      type        = "Service"
      identifiers = ["ecs-tasks.amazonaws.com"]
    }
  }
}

data "aws_iam_policy_document" "rds_yggdrasil_iam_auth" {
  statement {
    sid    = "rdsYggdrasilIamAuth"
    effect = "Allow"
    resources = [
      "arn:aws:rds-db:us-east-1:${data.aws_caller_identity.current.account_id}:dbuser:${module.yggdrasil_remote_state.outputs.rds_cluster_resource_identifier}/${local.db_role}"
    ]
    actions = ["rds-db:connect"]
  }

  statement {
    sid       = "rdsYggdrasilDescribeDBClusterEndpoints"
    effect    = "Allow"
    resources = ["*"]
    actions   = ["rds:DescribeDBClusterEndpoints"]
  }
}

module "service_scoped_secrets" {
  source  = "app.terraform.io/indigoag/service_scoped_secrets_app_policy/aws"
  version = "1.0.0"

  environment  = var.environment
  service_name = local.name
}

data "aws_cloudformation_stack" "sns_main" {
  # this stack still lives in the infrastrucutre repository
  # https://github.com/indigo-ag/infrastructure/blob/develop/cloudformation/sns/platform-events-stack.yml
  name = "sns-main"
}

resource "aws_iam_role" "ecs_task_role" {
  name                = "${local.db_role}_task_role"
  description         = "Role to be utilized by ${local.name} containers run by ECS"
  assume_role_policy  = data.aws_iam_policy_document.assume_role.json
  tags                = local.tags
  managed_policy_arns = [module.service_scoped_secrets.read_only_policy_arn]

  inline_policy {
    name   = "rds_yggdrasil_iam_auth"
    policy = data.aws_iam_policy_document.rds_yggdrasil_iam_auth.json
  }

  inline_policy {
    name = "s3_policy"
    policy = jsonencode({
      Version = "2012-10-17"
      Statement = [
        {
          Sid    = ""
          Action = ["s3:*"]
          Effect = "Allow"
          Resource = ["arn:aws:s3:::indigo-financing*", "arn:aws:s3:::indigo-financing*/*"
          ]
        },
        {
          Sid    = "1"
          Action = ["s3:GetObject", "s3:List*"]
          Effect = "Allow"
          Resource = ["arn:aws:s3:::ag-finance-attachments-${local.env}", "arn:aws:s3:::ag-finance-attachments-${local.env}/*"
          ]
        }
      ]
    })
  }

  inline_policy {
    name = "notify_schema_change"
    policy = jsonencode({
      Version = "2012-10-17"
      Statement = [
        {
          Sid      = ""
          Action   = ["cloudformation:DescribeStacks", "elasticloadbalancing:Describe*"]
          Effect   = "Allow"
          Resource = ["*"]
        }
      ]
    })
  }

  inline_policy {
    name = "sns_policy"
    policy = jsonencode({
      Version = "2012-10-17"
      Statement = [
        {
          Sid      = "SnsAccess"
          Action   = ["sns:Publish"]
          Effect   = "Allow"
          Resource = [data.aws_cloudformation_stack.sns_main.outputs["SNSTopicARN"]]
        }
      ]
    })
  }
}

# Load Balancer and associated resources for the api container
module "indigo_api" {
  source                = "app.terraform.io/indigoag/indigo_api/aws"
  version               = "1.0.0"
  name                  = local.name
  container_name        = "api"
  environment           = local.env
  product               = local.tags.product
  project               = local.tags.project
  repo_name             = local.tags["repo-name"]
  team                  = local.tags.team
  health_check_interval = 16
  health_check_timeout  = 15
  deregistration_delay  = 60
  publicly_accessible   = var.publicly_accessible
}

COntract Management API

Contract Generator for a Marketplace

  • πŸ“ Generates contracts dynamically
  • βœ… Handles processing and reviewing
  • πŸ–‹οΈ Supports both physical and digital signatures

Process Automation using BPMN

(Business Process Model and Notation)

CMA

CMA

CMA

Why world-class?

  • πŸ†•Β New Stack, still performing as seniors
  • πŸ“ˆ Impact, reduce manual effort, scale operations
  • 🎯 Leading Features
  • πŸ“Β Code Quality and Best Practices

What would I change?

More time for POC or Camunda expert

  • Reduce the opportunity costΒ 
  • Documentation difficult to process

Be clear with the intention of camunda

CMA

Template Engine

Requirement

Use the web app to allow the manager to create the contract template

CMA

Template Engine

Challenges

  • No clear scope
  • Possible minimalistic programming language
  • It required considerable training on the user side
  • Not meeting the deadline

Use the web app to allow the manager to create the contract template

CMA

Template Engine

My solution walkthroughΒ 

Use the web app to allow the manager to create the contract template

  • Meet with the product manager to discuss the feature's context and North Star.
  • Architect a solution to meet both deadlines and core demands.
  • Discuss the technical approach with the engineering director.

1

Define contract type

  • common template
  • variables

2

Build template

  • manual process
  • set tags/placeholdersΒ 

3

Develop Tag Resolvers

  • Business rules

4

Create repository

  • Match tag with resolver

My solution walkthroughΒ 

CMA

Template Engine

My solution walkthroughΒ 

Use the web app to allow the manager to create the contract template

print("Code time πŸ’»")

Benefits

  • Easy to reuse, functional

  • Easy to: understand, implement, maintain, debug, and scale
  • Doesn't require any training

  • Meeting the deadline

Downsides

  • Managers are not fully independent
  • Requires engineer team for new implementations

CMA

Template Engine

Use the web app to allow the manager to create the contract template

Improvements

  • Manage versions of contracts for audit purposes
  • Support rich text on tag resolvers

Valid8 Migration @ HeroDevs

AngularJS to Angular migration

  • πŸ”„ Migration service
  • πŸ“ˆ Large Financing web app
  • πŸ‘₯ Lead Engineer in a team of 4

V8 Migration

  • Step-by-step migration
    • User experience continuity
    • Feature prioritization
    • Continuous Delivery
    • Time-to-market reduced
  • Hybrid app​

MORE THAN A SIMPLE RE-WRITE

V8 Migration

Legend:

Legacy

New

HYBRID APP?

V8 MIGRATION

Why world-class?

  • πŸ”„ Migration with Zero Downtime
  • 🧠 High technical complexity
  • πŸ“… Seasonal Deadlines met
  • πŸ’‘ Architectural Solutions
  • πŸ‘₯ Effective Team Leadership

What would I change?

  • Create company standards

V8 Migration

Challange: Communicate both frameworks

Let's imagine the following scenario

INNOVATIVE ARCHITECTURAL SOLUTIONS

V8 Migration

INNOVATIVE ARCHITECTURAL SOLUTIONS

  • Redux Pattern
  • Single source of truth
  • Standardize state management

V8 Migration

Facade Pattern

// Traditional Ngrx
this.store.dispatch(AccountsActions.deleteProjectAccount({ accountId }));

// Facade
projectFacade.deleteAccount(accountId);

INNOVATIVE ARCHITECTURAL SOLUTIONS

V8 Migration

Bridge

INNOVATIVE ARCHITECTURAL SOLUTIONS

V8 Migration

Another Problem 🫠

Change Detection on both frameworks

INNOVATIVE ARCHITECTURAL SOLUTIONS

Solution

Create a wrapper to execute the required steps to comply with the change detection

V8 Migration

INNOVATIVE ARCHITECTURAL SOLUTIONS

Simply frameworks comunication

@decorators

V8 Migration

INNOVATIVE ARCHITECTURAL SOLUTIONS

var checksFacade = 
    bridge.store.getFacade('checks');

LEGACY

Get Facade

@FacadeLegacySupport({
  registrationKey: 'checks'
})
@Injectable()
export class ChecksFacade {
}

New

Register Facade

Facade

V8 Migration

INNOVATIVE ARCHITECTURAL SOLUTIONS

@actionLegacySupport()
load() {
  this.store.dispatch(ChecksActions.load());
}

New

Add Legacy Support

Action

LEGACY

Trigger Action

var checksFacade = bridge.store.getFacade('checks');
entitiesFacade.load_legacySupport();

V8 Migration

INNOVATIVE ARCHITECTURAL SOLUTIONS

@selectorLegacySupport()
checkList$ = this.store.pipe(
  select(ChecksSelectors.getAllChecks)
);

New

Add Legacy Support

Selectors

LEGACY

Use Selector

var checksFacade = bridge.store.getFacade('checks');

checksFacade.checkList$_legacySupport
  .subscribe(console.log)
@selectorLegacySupport({promisfy: true})
checkList$ = this.store.pipe(
  select(ChecksSelectors.getAllChecks)
);
var checksFacade = bridge.store.getFacade('checks');

checksFacade.checkList$_legacySupport_promise
  .then(console.log)

V8 Migration

  • Streamline communication between frameworks
  • Reduce complexity
  • Enhanced productivity
  • Minimizing migration and onboarding time

Benefits

INNOVATIVE ARCHITECTURAL SOLUTIONS

V8 Migration

MANAGER OF ONE

  • Facilitated discussions on business needs
  • Transform requirements into tasks
  • Regular meetings to manage scope, prioritization, and project status

  • Agile Methodology

  • Mentorship

  • 🌟 Top Performer Project

    • High Client Satisfaction

    • High efficient team

    • Driving substantial operational improvements

World-Class Projects

Market Enabler

AG FINANCE

Contract Generator for a Marketplace

CMA

Framework migration

VALID8 MIGRATION

Thank you

dianjuar@gmail.com

linkedin.com/in/dianjuar

Minimal

By Diego Juliao

Minimal

  • 31