# recepgunes1/searchengine architecture

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

- Interactive diagram: https://gitdiagram.com/recepgunes1/searchengine
- Repository: https://github.com/recepgunes1/searchengine

## Overview

##### Main Components
- Clients:
- Mobile Application (clients/Mobile) targeting multiple platforms.
- Web Application (clients/Web) serving the browser-based UI.
- Backend Gateway:
- The Gateway service (services/Gateway) that acts as an API aggregator or reverse proxy (using Ocelot configuration files) to route requests to the right microservices.
- Microservices:
- SearchHub, PageDownloader, Summarizer, TagExtractor, UrlExtractor, and UrlRegister.
- Each service is separated into infrastructure (data access, event consumers, extensions, etc.) and WebAPI or Worker projects that implement their business logic.
- Shared Library:
- Under services/Shared, which contains common DTOs, entities, and event definitions that are used across multiple microservices.
- External Systems:
- Databases for various microservices – indicated by deployment YAML files under “deployments/Production/databases”.
- An ElasticSearch instance (see deployments/Production/elastic) used by SearchHub along with possibly other services that reference elastic functionality.
- RabbitMQ (deployments/Production/rabbitmq) for message queuing between services.

##### Relationships & Interactions
- Clients communicate with the Gateway service that routes the requests to the appropriate microservice. For instance:
- A search request from the mobile or web client is forwarded by the Gateway to SearchHub.
- Other requests (e.g., upload of pages, tag extraction) may be directed to services such as PageDownloader, TagExtractor, or UrlRegister.
- Microservices communicate with shared databases and possibly with each other via messaging queues (as seen with consumer classes and RabbitMQ definitions).
- External API calls (for summarization, for example) are contained in the Summarizer service.
- As a complete system, internal events, DTOs, and messaging are mediated using the shared library.

##### Key Architectural Patterns
- Microservices architecture: Independent services for different business domains.
- API Gateway: Central point for routing client requests to backend services.
- Distributed messaging: Use of RabbitMQ for communication between services.
- Containerization & orchestration: Dockerfiles, docker-compose, and Kubernetes configuration indicate containerized deployment and orchestration.
- Multi-platform clients: The mobile app supports Android, iOS, Windows, etc., while the web client covers browser interactions.

##### Relevant Technologies
- .NET (for both backend and mobile/web clients).
- .NET MAUI for mobile application development.
- Blazor/ASP.NET Core (likely) for the web application.
- Docker and Kubernetes for deployment.
- RabbitMQ for messaging.
- Elasticsearch for indexing and search functionality.
- Ocelot for API gateway configuration.

- Shared components:
- External systems:
- For deployment:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients"
        MobileClient["Mobile Client (.NET MAUI)"]:::client
        WebClient["Web Client (Blazor/ASP.NET Core)"]:::client
    end

    %% API Gateway Layer
    Gateway["API Gateway (Ocelot)"]:::gateway

    %% Microservices Layer
    subgraph "Microservices"
        SearchHub["SearchHub Microservice"]:::service

        subgraph "PageDownloader Microservice"
            PageDownloaderWorker["Worker"]:::service
            PageDownloaderInfrastructure["Infrastructure"]:::service
        end

        Summarizer["Summarizer Microservice"]:::service

        subgraph "TagExtractor Microservice"
            TagExtractorWorker["Worker"]:::service
            TagExtractorInfrastructure["Infrastructure"]:::service
        end

        subgraph "UrlExtractor Microservice"
            UrlExtractorWorker["Worker"]:::service
            UrlExtractorInfrastructure["Infrastructure"]:::service
        end

        UrlRegister["UrlRegister Microservice"]:::service
    end

    %% Shared Library
    Shared["Shared Library/DTOs"]:::shared

    %% External Systems Layer
    subgraph "External Systems"
        Databases["Databases"]:::external
        Elasticsearch["Elasticsearch"]:::external
        RabbitMQ["RabbitMQ"]:::external
    end

    %% Deployment/Orchestration Layer
    Deployment["Deployment/Orchestration (Docker, Kubernetes)"]:::deployment

    %% Connections
    %% Clients to Gateway
    MobileClient -->|"calls"| Gateway
    WebClient -->|"calls"| Gateway

    %% Gateway to Microservices
    Gateway -->|"routes_to"| SearchHub
    Gateway -->|"routes_to"| PageDownloaderWorker
    Gateway -->|"routes_to"| Summarizer
    Gateway -->|"routes_to"| TagExtractorWorker
    Gateway -->|"routes_to"| UrlExtractorWorker
    Gateway -->|"routes_to"| UrlRegister

    %% Microservices to Shared Library
    SearchHub -->|"uses"| Shared
    PageDownloaderWorker -->|"uses"| Shared
    PageDownloaderInfrastructure -->|"supports"| PageDownloaderWorker
    Summarizer -->|"uses"| Shared
    TagExtractorWorker -->|"uses"| Shared
    TagExtractorInfrastructure -->|"supports"| TagExtractorWorker
    UrlExtractorWorker -->|"uses"| Shared
    UrlExtractorInfrastructure -->|"supports"| UrlExtractorWorker
    UrlRegister -->|"uses"| Shared

    %% Microservices to External Systems
    SearchHub -->|"writes_to"| Elasticsearch
    SearchHub -->|"writes_to"| Databases
    PageDownloaderWorker -->|"writes_to"| Databases
    Summarizer -->|"calls_API"| Databases
    TagExtractorWorker -->|"writes_to"| Databases
    UrlExtractorWorker -->|"writes_to"| Databases
    UrlRegister -->|"writes_to"| Databases

    %% Microservices to RabbitMQ (Messaging)
    SearchHub ---|"pub_sub"| RabbitMQ
    PageDownloaderWorker ---|"pub_sub"| RabbitMQ
    Summarizer ---|"pub_sub"| RabbitMQ
    TagExtractorWorker ---|"pub_sub"| RabbitMQ
    UrlExtractorWorker ---|"pub_sub"| RabbitMQ
    UrlRegister ---|"pub_sub"| RabbitMQ

    %% Deployment connections (annotation)
    Deployment ---|"containerizes"| Gateway
    Deployment ---|"containerizes"| SearchHub
    Deployment ---|"containerizes"| PageDownloaderWorker
    Deployment ---|"containerizes"| PageDownloaderInfrastructure
    Deployment ---|"containerizes"| Summarizer
    Deployment ---|"containerizes"| TagExtractorWorker
    Deployment ---|"containerizes"| TagExtractorInfrastructure
    Deployment ---|"containerizes"| UrlExtractorWorker
    Deployment ---|"containerizes"| UrlExtractorInfrastructure
    Deployment ---|"containerizes"| UrlRegister
    Deployment ---|"orchestrates"| Shared

    %% Click Event Mappings
    click MobileClient "https://github.com/recepgunes1/searchengine/blob/master/clients/Mobile/Mobile.App"
    click WebClient "https://github.com/recepgunes1/searchengine/blob/master/clients/Web/Web.App"
    click Gateway "https://github.com/recepgunes1/searchengine/blob/master/services/Gateway/Gateway.WebAPI"
    click SearchHub "https://github.com/recepgunes1/searchengine/blob/master/services/SearchHub/SearchHub.WebAPI"
    click PageDownloaderWorker "https://github.com/recepgunes1/searchengine/blob/master/services/PageDownloader/PageDownloader.Worker"
    click PageDownloaderInfrastructure "https://github.com/recepgunes1/searchengine/blob/master/services/PageDownloader/PageDownloader.Infrastructure"
    click Summarizer "https://github.com/recepgunes1/searchengine/tree/master/services/Summarizer"
    click TagExtractorWorker "https://github.com/recepgunes1/searchengine/blob/master/services/TagExtractor/TagExtractor.Worker"
    click TagExtractorInfrastructure "https://github.com/recepgunes1/searchengine/blob/master/services/TagExtractor/TagExtractor.Infrastructure"
    click UrlExtractorWorker "https://github.com/recepgunes1/searchengine/blob/master/services/UrlExtractor/UrlExtractor.Worker"
    click UrlExtractorInfrastructure "https://github.com/recepgunes1/searchengine/blob/master/services/UrlExtractor/UrlExtractor.Infrastructure"
    click UrlRegister "https://github.com/recepgunes1/searchengine/blob/master/services/UrlRegister/UrlRegister.WebAPI"
    click Shared "https://github.com/recepgunes1/searchengine/tree/master/services/Shared/Shared"
    click Databases "https://github.com/recepgunes1/searchengine/tree/master/deployments/Production/databases"
    click Elasticsearch "https://github.com/recepgunes1/searchengine/tree/master/deployments/Production/elastic"
    click RabbitMQ "https://github.com/recepgunes1/searchengine/tree/master/deployments/Production/rabbitmq"

    %% Styles
    classDef client fill:#f9c,stroke:#333,stroke-width:2px;
    classDef gateway fill:#bbf,stroke:#083,stroke-width:2px;
    classDef service fill:#cfc,stroke:#080,stroke-width:2px;
    classDef shared fill:#ff9,stroke:#880,stroke-width:2px;
    classDef external fill:#fcc,stroke:#800,stroke-width:2px;
    classDef deployment fill:#ccf,stroke:#408,stroke-width:2px;
```
