> ## Documentation Index
> Fetch the complete documentation index at: https://docs.specterops.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Dapr

Nemesis 2.0 makes heavy use of [Dapr](https://dapr.io/), the Distributed Application Runtime. The Dapr components that Nemesis utilizes are detailed in the following sections. Images in this page were pulled from the appropriate locations from the [Dapr Documentation](https://docs.dapr.io/).

## Pubsub

Nemesis utilizes the [Dapr Publish & subscribe](https://docs.dapr.io/developing-applications/building-blocks/pubsub/) building block for its internal queueing system. Currently, Nemesis utilizes RabbitMQ for the queue, but this can easily be easily swapped for [alternative systems](https://docs.dapr.io/reference/components-reference/supported-pubsub/) like Kafka or Redis Streams by ensuring the provider is stood up in the [docker-compose.yml](https://github.com/SpecterOps/Nemesis/docker-compose.yml), modifying the [pubsub.yaml](https://github.com/SpecterOps/Nemesis/infra/dapr/components/pubsub.yaml) file with an alternative provider, and ensuring the connection string is passed through via an environment variable as in the current pubsub.yaml example.

<img src="https://mintcdn.com/specteropsdocs/p-HS7mR7kxSK3hXw/nemesis-docs/docs/images/dapr-pubsub-overview-components.png?fit=max&auto=format&n=p-HS7mR7kxSK3hXw&q=85&s=1bf197e9166ed7ec3370782dce53d1ce" alt="Dapr Pubsub" width="1093" height="707" data-path="nemesis-docs/docs/images/dapr-pubsub-overview-components.png" />

## Workflows

[Dapr Workflows](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-overview/) enable developers to build reliable, long-running business processes as code. They provide a way to orchestrate microservices with built-in state management, error handling, and retry logic for complex distributed applications.

<img src="https://mintcdn.com/specteropsdocs/p-HS7mR7kxSK3hXw/nemesis-docs/docs/images/dapr-workflow-overview.png?fit=max&auto=format&n=p-HS7mR7kxSK3hXw&q=85&s=3d45daefc5b8f0607ad24ee4fc411bb4" alt="Dapr Workflow Overview" width="2057" height="892" data-path="nemesis-docs/docs/images/dapr-workflow-overview.png" />

Nemesis uses in two specific places/services. First, in the [file\_enrichment](https://github.com/SpecterOps/Nemesis/projects/file_enrichment/file_enrichment/workflow.py) project, Dapr workflows are used to control the main file enrichment processing logic. The **enrichment\_workflow()** function controls the main enrichment workflow, with the **enrichment\_module\_workflow()** function invoked as a child workflow.

The [document\_conversion](https://github.com/SpecterOps/Nemesis/projects/document_conversion/document_conversion/main.py) project also implements a Dapr workflow in the **document\_conversion\_workflow()** function to handle converting documents and extracting text. This is broken out into a separate project as it's a time-consuming task.

## Secrets

Nemesis uses the [Dapr Secrets management](https://docs.dapr.io/developing-applications/building-blocks/secrets/secrets-overview/) building block to protect secrets internally (like Postgres connection strings). Currently the [Local environment variables](https://docs.dapr.io/reference/components-reference/supported-secret-stores/envvar-secret-store/) component is used. These secrets are also refereced within some Dapr files such as [pubsub.yaml](https://github.com/SpecterOps/Nemesis/infra/dapr/components/pubsub.yaml).

This reason for using this abstraction is so alternative secret management systems like [Vault or Kubernetes secrets](https://docs.dapr.io/reference/components-reference/supported-secret-stores/) can be used in the future:

<img src="https://mintcdn.com/specteropsdocs/p-HS7mR7kxSK3hXw/nemesis-docs/docs/images/dapr-secrets-overview-cloud-stores.png?fit=max&auto=format&n=p-HS7mR7kxSK3hXw&q=85&s=18c64d7911c776486504131d8d2e6fc8" alt="Dapr Secrets" width="973" height="612" data-path="nemesis-docs/docs/images/dapr-secrets-overview-cloud-stores.png" />

An example of retrieving a secret is at the top of the the [housekeeping code](https://github.com/SpecterOps/Nemesis/projects/housekeeping/housekeeping/main.py) to retrieve the `POSTGRES_CONNECTION_STRING` string.

## Service Invocation

In a few places in Nemesis, Dapr's [Service Invocation](https://docs.dapr.io/developing-applications/building-blocks/service-invocation/service-invocation-overview/) building block is used to ease the complexity of some API invocations. This building block is specifically used when calling the Gotenberg API and when calling some of the internal file enrichment APIs by the web API.
