# stevenferrer/solr-go architecture

> Architecture diagram of the GitHub repository stevenferrer/solr-go, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stevenferrer/solr-go
- Repository: https://github.com/stevenferrer/solr-go

## Overview

##### Project Type Analysis
This is a Go client library for Apache Solr, focusing on providing a programmatic interface to interact with Solr's various APIs. It's an API wrapper/client library type project.

##### Main Components

A. Client Layer:
- JSONClient (json_client.go) as the main entry point
- RequestSender (request_sender.go) for handling HTTP communications
- Core client interface (client.go)

B. API Features Layer:
- Collections API handler
- Core Admin API handler
- Query API handler
- Update API handler
- Schema API handler
- Config API handler
- Suggester API handler

C. Query Building Components:
- Query Parser (query_parser.go)
- Facet Builder (facet.go)
- Collection Parameters (collection_params.go)
- Core Parameters (core_params.go)
- Suggester Parameters (suggester_params.go)

D. Response Handling:
- Response processor (response.go)

**[Client Application] → [Solr-Go Client] → [Solr Server]**

**┌─ Client Layer ─────────┐**
- JSONClient           │
- RequestSender        │
- ┬────────────┘
- ↓
**┌─ API Features Layer ───┐**
- Collections API      │
- Core Admin API       │
- Query API           │
- Update API          │
- Schema API          │
- Config API          │
- Suggester API       │
- ┬────────────┘
- ↓
**┌─ Query Building ───────┐**
- Query Parser        │
- Facet Builder       │
- Parameters Handlers │
- ┬────────────┘
- ↓
**┌─ Response Handling ────┐**
- Response Processor  │
- ┘

##### Additional Elements
- A note about Basic Authentication support
- Interaction patterns with Solr server
- Supported content types (JSON)
- Error handling flow

##### Important Details to Highlight
- The JSON-centric nature of the client
- The modular design of different API handlers
- The separation of concerns between query building and execution
- The extensible nature of the parameter handlers

##### The central role of the JSONClient as the main entry point

This design reflects a well-structured Go library that follows good separation of concerns and provides a clean API for interacting with Solr's various features.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client[Client Application]
        Solr[Solr Server]
    end

    subgraph ClientLayer
        JSONClient["JSONClient"]:::client
        RequestSender["RequestSender"]:::client
        CoreClient["Core Client Interface"]:::client
    end

    subgraph APILayer
        ConfigAPI["Config API"]:::api
        SchemaAPI["Schema API"]:::api
        QueryAPI["Query API"]:::api
        CollectionsAPI["Collections API"]:::api
        CoreAdminAPI["Core Admin API"]:::api
        UpdateAPI["Update API"]:::api
        SuggesterAPI["Suggester API"]:::api
    end

    subgraph QueryBuildingLayer
        QueryParser["Query Parser"]:::query
        FacetBuilder["Facet Builder"]:::query
        CollectionParams["Collection Parameters"]:::query
        CoreParams["Core Parameters"]:::query
        SuggesterParams["Suggester Parameters"]:::query
    end

    subgraph ResponseLayer
        ResponseProcessor["Response Processor"]:::response
        MIMEHandler["MIME Type Handler"]:::response
    end

    Client --> JSONClient
    JSONClient --> RequestSender
    RequestSender --> APILayer
    APILayer --> QueryBuildingLayer
    QueryBuildingLayer --> ResponseLayer
    ResponseLayer --> Solr

    %% Click events for component mapping
    click JSONClient "https://github.com/stevenferrer/solr-go/blob/main/json_client.go"
    click RequestSender "https://github.com/stevenferrer/solr-go/blob/main/request_sender.go"
    click CoreClient "https://github.com/stevenferrer/solr-go/blob/main/client.go"
    click ConfigAPI "https://github.com/stevenferrer/solr-go/blob/main/config.go"
    click SchemaAPI "https://github.com/stevenferrer/solr-go/blob/main/schema.go"
    click QueryAPI "https://github.com/stevenferrer/solr-go/blob/main/query.go"
    click QueryParser "https://github.com/stevenferrer/solr-go/blob/main/query_parser.go"
    click FacetBuilder "https://github.com/stevenferrer/solr-go/blob/main/facet.go"
    click CollectionParams "https://github.com/stevenferrer/solr-go/blob/main/collection_params.go"
    click CoreParams "https://github.com/stevenferrer/solr-go/blob/main/core_params.go"
    click SuggesterParams "https://github.com/stevenferrer/solr-go/blob/main/suggester_params.go"
    click ResponseProcessor "https://github.com/stevenferrer/solr-go/blob/main/response.go"
    click MIMEHandler "https://github.com/stevenferrer/solr-go/blob/main/mime_type.go"

    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef query fill:#e67e22,stroke:#d35400,color:white
    classDef response fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        ClientComp["Client Component"]:::client
        APIComp["API Component"]:::api
        QueryComp["Query Component"]:::query
        ResponseComp["Response Component"]:::response
        ExternalComp["External System"]:::external
    end
```
