# jessmed749/sentiment_analyzer_defeel architecture

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

- Interactive diagram: https://gitdiagram.com/jessmed749/sentiment_analyzer_defeel
- Repository: https://github.com/jessmed749/sentiment_analyzer_defeel

## Overview

##### Project type and purpose
- This is an event-driven microservice application (“Sentiment Analyzer DeFeel”) that uses Apache Kafka as its messaging backbone.
- The producer service ingests raw text events into a Kafka topic; the inference service consumes raw events, scores them using a sentiment model, and publishes scored events back to Kafka.
- Docker Compose (in infra/) orchestrates Kafka and Zookeeper locally.

##### File structure
- infra/
- docker-compose.yml – Defines Kafka and Zookeeper containers and exposes ports.
- producer/
- producer.py & prod.py – Logic to read/generate raw messages and publish to `events.raw`.
- run.py – Entry point for starting the producer service.
- inference/
- worker.py – Kafka consumer that reads `events.raw`, invokes the model, and produces to `events.scored`.
- models.py – The sentiment-scoring logic/class.
- Dockerfile & requirements.txt – Container and dependency setup for the inference service.
- docs/ – Markdown docs and design notes.
- Root requirements.txt – Common Python dependencies.
- .env.dev – Environment variables for development.

##### Key architectural patterns and components
a. Producer microservice (“Raw Event Emitter”)
b. Kafka cluster (broker + Zookeeper)
c. Two Kafka topics: events.raw and events.scored
d. Inference microservice (“Sentiment Scorer”)
e. (Optional) Downstream consumers or dashboards (not yet implemented)

- Use rectangles for services (producer, inference).
- Use a cloud/container outline for the Docker-Compose orchestrated environment.
- Blue for compute services,
- Orange for message bus components,
- Green for data stores or topics.

##### Detail level
- Environment variable usage from .env.dev (e.g., Kafka bootstrap address).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Docker Compose (Kafka + Zookeeper)"
        direction TB
        infraLabel["Docker Compose\nKafka Broker:9092\nZookeeper"]:::infra
        eventsRaw[(events.raw)]:::topic
        eventsScored[(events.scored)]:::topic
    end

    subgraph "Producer Service"
        direction TB
        PS_Run["run.py"]:::service
        PS_ProdPy["producer.py"]:::service
        PS_Prod2["prod.py"]:::service
    end

    subgraph "Inference Service"
        direction TB
        IS_Worker["worker.py"]:::service
        IS_Models["models.py"]:::service
        IS_Dockerfile["Dockerfile"]:::service
        IS_Req["requirements.txt"]:::service
    end

    subgraph "Supporting Files"
        direction TB
        Env[".env.dev"]:::support
        Docs["docs/"]:::support
        CommonReq["requirements.txt"]:::support
    end

    PS_Run -->|"produce to events.raw"| eventsRaw
    PS_ProdPy --> eventsRaw
    PS_Prod2 --> eventsRaw

    eventsRaw -->|"consume from events.raw"| IS_Worker
    IS_Models --> IS_Worker
    IS_Worker -->|"produce to events.scored"| eventsScored

    infraLabel --> eventsRaw
    infraLabel --> eventsScored

    classDef service fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef topic fill:#90EE90,stroke:#000,stroke-width:1px,shape:cylinder
    classDef infra fill:#FFA500,stroke:#000,stroke-width:1px
    classDef support fill:#D3D3D3,stroke:#000,stroke-width:1px

    click PS_Run "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/producer/run.py"
    click PS_ProdPy "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/producer/producer.py"
    click PS_Prod2 "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/producer/prod.py"
    click IS_Worker "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/inference/worker.py"
    click IS_Models "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/inference/models.py"
    click IS_Dockerfile "https://github.com/jessmed749/sentiment_analyzer_defeel/tree/main/inference/Dockerfile"
    click IS_Req "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/inference/requirements.txt"
    click infraLabel "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/infra/docker-compose.yml"
    click Env "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/.env.dev"
    click Docs "https://github.com/jessmed749/sentiment_analyzer_defeel/tree/main/docs/"
    click CommonReq "https://github.com/jessmed749/sentiment_analyzer_defeel/blob/main/requirements.txt"
```
