# hivdb/sierra-client architecture

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

- Interactive diagram: https://gitdiagram.com/hivdb/sierra-client
- Repository: https://github.com/hivdb/sierra-client

## Overview

##### Project Type Analysis
This is a Python-based client library for interacting with the HIVdb web service, focusing on HIV and SARS-CoV-2 sequence analysis. It's structured as a command-line tool with modular components.

##### Key Components

A. Core Client Layer:
- Center the `SierraClient` (sierraclient.py) as the main component
- It as the primary interface between the application and the HIVdb web service

B. Command Interface Layer:
- CLI component (commands/cli.py)
- Command modules (mutations.py, fasta.py, seqreads.py, etc.)
- To the core client

C. Virus-Specific Handlers:
- Inheritance from the base virus class

D. Data Processing Components:
- FASTA reader component
- Recipe processors for different output formats
- GraphQL fragments for different analysis types

**[External System]**
**HIVdb Web Service**
- ↕
**[Core Layer]**
**SierraClient**
- ↕
**[Command Layer]**
- CLI Handler
- ↙    ↓    ↘
**Mutations  FASTA  Sequence Reads**
- ↓      ↓         ↓
**[Processing Layer]**
**FASTA Reader → Recipe Processors**
- ↓
**[Virus Handlers]**
**Base Virus Class**
- ↙     ↓    ↘
**HIV-1   HIV-2  SARS-CoV-2**

##### Important Details
- GraphQL fragment files for each virus type
- Different analysis types (mutations, sequence, sequence reads)
- Recipe processors for different output formats (TSV, alignment)
- Command-line interface entry points

##### Additional Recommendations
- Notes about the supported file formats (FASTA)
- Relationship between commands and their corresponding GraphQL queries
- Async/sync operations where relevant

##### Implementation Notes
- Maintain consistent spacing and alignment
- Related components visually
- Use clear, readable fonts and labels
- Version information if relevant

Remember to indicate the asynchronous nature of web service interactions and show how the different components work together to process biological sequence data and interact with the HIVdb service.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Service
    HIVdb[HIVdb Web Service]:::external

    %% Core Layer
    SierraClient[SierraClient]:::core
    click SierraClient "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/sierraclient.py"

    %% Command Layer
    subgraph CommandLayer[Command Interface Layer]
        CLI[CLI Handler]:::command
        click CLI "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/commands/cli.py"
        Mutations[Mutations Command]:::command
        click Mutations "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/commands/mutations.py"
        FASTA[FASTA Command]:::command
        click FASTA "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/commands/fasta.py"
        SeqReads[Sequence Reads Command]:::command
        click SeqReads "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/commands/seqreads.py"
    end

    %% Processing Layer
    subgraph ProcessingLayer[Data Processing Layer]
        FASTAReader[FASTA Reader]:::processing
        click FASTAReader "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fastareader.py"
        
        subgraph Recipes[Recipe Processors]
            AlignmentProc[Alignment Processor]:::processing
            click AlignmentProc "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/recipes/alignment.py"
            MutationTSV[Mutation TSV Processor]:::processing
            click MutationTSV "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/recipes/mutationtsv.py"
            SequenceTSV[Sequence TSV Processor]:::processing
            click SequenceTSV "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/recipes/sequencetsv.py"
        end
    end

    %% Virus Handlers Layer
    subgraph VirusLayer[Virus Handlers]
        BaseVirus[Base Virus Class]:::virus
        click BaseVirus "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/viruses/virus.py"
        HIV1[HIV-1 Handler]:::virus
        click HIV1 "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/viruses/hiv1.py"
        HIV2[HIV-2 Handler]:::virus
        click HIV2 "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/viruses/hiv2.py"
        SARS2[SARS-CoV-2 Handler]:::virus
        click SARS2 "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/viruses/sars2.py"
    end

    %% GraphQL Layer
    subgraph GraphQLLayer[GraphQL Fragments]
        HIV1Mut[HIV-1 Mutations]:::graphql
        click HIV1Mut "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fragments/hiv1_mutations_analysis_default.gql"
        HIV1Seq[HIV-1 Sequence]:::graphql
        click HIV1Seq "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fragments/hiv1_sequence_analysis_default.gql"
        HIV1Reads[HIV-1 Sequence Reads]:::graphql
        click HIV1Reads "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fragments/hiv1_sequence_reads_analysis_default.gql"
        HIV2Seq[HIV-2 Sequence]:::graphql
        click HIV2Seq "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fragments/hiv2_sequence_analysis_default.gql"
        SARS2Mut[SARS-CoV-2 Mutations]:::graphql
        click SARS2Mut "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fragments/sars2_mutations_analysis_default.gql"
        SARS2Seq[SARS-CoV-2 Sequence]:::graphql
        click SARS2Seq "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fragments/sars2_sequence_analysis_default.gql"
        SARS2Reads[SARS-CoV-2 Sequence Reads]:::graphql
        click SARS2Reads "https://github.com/hivdb/sierra-client/blob/master/python/sierrapy/fragments/sars2_sequence_reads_analysis_default.gql"
    end

    %% Relationships
    HIVdb <--> SierraClient
    SierraClient --> CLI
    CLI --> Mutations & FASTA & SeqReads
    Mutations & FASTA & SeqReads --> FASTAReader
    FASTAReader --> Recipes
    Mutations --> HIV1Mut & SARS2Mut
    FASTA --> HIV1Seq & HIV2Seq & SARS2Seq
    SeqReads --> HIV1Reads & SARS2Reads
    BaseVirus --> HIV1 & HIV2 & SARS2
    HIV1 & HIV2 & SARS2 --> GraphQLLayer

    %% Styles
    classDef external fill:#87CEEB
    classDef core fill:#90EE90
    classDef command fill:#FFA500
    classDef processing fill:#FFD700
    classDef virus fill:#DDA0DD
    classDef graphql fill:#F0E68C

    %% Legend
    subgraph Legend
        L1[External Service]:::external
        L2[Core Component]:::core
        L3[Command Interface]:::command
        L4[Processing Component]:::processing
        L5[Virus Handler]:::virus
        L6[GraphQL Fragment]:::graphql
    end
```
