# daevmithran/dacona architecture

> Architecture diagram of the GitHub repository daevmithran/dacona, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/daevmithran/dacona
- Repository: https://github.com/daevmithran/dacona

## Overview

##### Project Type and Purpose
- This is a Node.js-based CLI demo application.
- Its purpose is to demonstrate creating and interacting with gated attestations using two external protocols: the Ethereum Attestation Service (EAS) and the Lit Protocol.
- Additionally, it showcases a decentralized identity demo called “Anon Aadhaar” for creating and verifying zero-knowledge proofs through QR code generation and attestation resolution.

##### Analyzing the File Structure
- Top-level files like package.json, tsconfig.json, and .gitignore indicate a standard Node.js/TypeScript project.
- The entire logic resides in the src directory.
- You have dedicated clients:
- src/easClient.ts is responsible for interactions with the Ethereum Attestation Service.
- src/LitprotocolClient.ts handles interactions with the Lit Protocol.
- The main entry point (src/index.ts) likely serves as the CLI “orchestrator” that ties the functionality together.
- The src/types folder holds TypeScript definitions and constants, providing a clear boundary for internal data handling and configuration.

##### Key Components
a. CLI/Command Interface:
- The entry point (index.ts) that drives the application flow.
- This component manages user input and coordinates the attestation creation and resolution processes.

b. EAS Integration Module:
- EasClient.ts as a core component.
- How it communicates with the Ethereum Attestation Service, posting and retrieving attestation data.

c. Lit Protocol Integration Module:
- LitprotocolClient.ts as another key component.
- Role in encrypting attestation data and decrypting it when the attestation is resolved.

d. Types and Configuration:
- Types folder as a supporting element that standardizes environment configurations, constants, and type declarations.

e. External Services:
- Ethereum Attestation Service (depicted as an external system with which the project interacts).
- Lit Protocol (another external service that provides encryption/decryption capabilities).

f. Anon Aadhaar Demo Workflow:
- Generates a QR code from an external demo page.
- Uploads and processes the QR code image externally.
- Subsequently uses the result in the Dacona CLI to create and verify gated attestations.

##### Relationships and Data Flow
- The CLI component (index.ts) calls methods in both the EAS integration module and the Lit Protocol module.
- Data flowing from the CLI to the EAS client when creating or resolving attestations.
- Data flowing to/from the Lit Protocol client during encryption (attestation creation) and decryption (attestation resolution).
- Inputs such as the “minified proof JSON” coming from the Anon Aadhaar workflow should be indicated as external data sources.
- That the types/configuration layer supports both client modules.

##### Architectural Patterns and Design Principles
- The project follows a modular design by separating responsibilities:
- The communication with external services is encapsulated in dedicated client modules.
- The main CLI acts as the controller that orchestrates which module to use based on the user’s flow (create or resolve attestations).
- That the design intends to isolate service interfaces (EAS and Lit) from business logic to make the system maintainable and extensible.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Internal Modules
    subgraph "Internal Modules"
        CLI["CLI/Index Controller"]:::internal
        EAS["EAS Client"]:::internal
        Lit["Lit Protocol Client"]:::internal
        Types["Types & Configuration"]:::internal
    end

    %% External Services
    subgraph "External Services"
        ETH(("Ethereum Attestation Service")):::external
        LIT(("Lit Protocol")):::external
        Anon(("Anon Aadhaar (QR Code Input)")):::external
    end

    %% Relationships and Data Flow
    CLI -->|"callsAttestation"| EAS
    CLI -->|"callsEncryptDecrypt"| Lit
    EAS -->|"communicates"| ETH
    Lit -->|"communicates"| LIT
    Anon -->|"providesProofJSON"| CLI
    EAS -->|"usesConfig"| Types
    Lit -->|"usesConfig"| Types

    %% Click Events
    click CLI "https://github.com/daevmithran/dacona/blob/main/src/index.ts"
    click EAS "https://github.com/daevmithran/dacona/blob/main/src/easClient.ts"
    click Lit "https://github.com/daevmithran/dacona/blob/main/src/LitprotocolClient.ts"
    click Types "https://github.com/daevmithran/dacona/tree/main/src/types"

    %% Styles
    classDef internal fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#155724,stroke-width:2px;
```
