# beliyzy/task-tracker-golang architecture

> Architecture diagram of the GitHub repository beliyzy/task-tracker-golang, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/beliyzy/task-tracker-golang
- Repository: https://github.com/beliyzy/task-tracker-golang

## Overview

##### Project Type and Purpose
The Task Tracker is a microservice-based task management system written in Go. It provides RESTful APIs for user/project/task operations, asynchronous task processing, real-time notifications via Telegram, and uses Redis, PostgreSQL, RabbitMQ, and a dedicated gRPC notification service.

##### Main Components
a. API Service (cmd/api)
- Exposes HTTP endpoints for authentication, tasks, and projects.
- Layers:
- Handlers (internal/handlers)
- Services (internal/service)
- Repositories (internal/repository)
- Domain models (internal/domain)
- Integrations: PostgreSQL, Redis, RabbitMQ (publishing), JWT auth (pkg/auth).

b. Worker Service (cmd/worker)
- Consumes messages from RabbitMQ (pkg/queue)
- Executes asynchronous task logic (internal/service)
- Calls Notification Service via gRPC client (internal/client/notification.go)

c. Notification Service (cmd/notification)
- gRPC server (internal/proto) implementing NotificationService
- Sends real-time alerts to Telegram (internal/client/telegram.go)

d. Infrastructure
- PostgreSQL (docker-compose “postgres” service) for persistence
- Redis (docker-compose “redis”) for caching/session management (pkg/cache)
- RabbitMQ (docker-compose “rabbitmq”) for message queuing
- External Telegram Bot API

##### Relationships and Data Flows
- Clients (UI or curl/Postman) → HTTP (API Service)
- API Service → read/write → PostgreSQL
- API Service ↔ cache → Redis
- API Service → publish → RabbitMQ “task” queue
- Worker Service ← consume ← RabbitMQ
- Worker Service → gRPC call → Notification Service
- Notification Service → HTTP → Telegram API

##### Architectural Patterns and Principles
- Microservices: each service has a single responsibility and can scale independently.
- Layered architecture within services: separation of handlers, business logic, data access.
- Asynchronous messaging: decouple API requests from long-running tasks via RabbitMQ.
- gRPC contract: well-typed notification protocol (internal/proto/*.proto).
- Configuration via environment variables or YAML (internal/config).
- Reusable utility packages in pkg/ (auth, cache, queue).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Clients["Clients (UI / Postman)"]:::external

    %% API Service
    subgraph "API Service" 
        direction TB
        API["cmd/api/main.go"]:::service
        Handlers["Handlers"]:::service
        Services["Services"]:::service
        Repos["Repositories"]:::service
        Domain["Domain Models"]:::service
        Auth["pkg/auth/jwt.go"]:::utility
        Cache["pkg/cache/redis.go"]:::utility
        QueuePub["pkg/queue/rabbitmq.go"]:::messaging
        ConfigAPI["internal/config/config.go"]:::service
    end

    %% Data Stores
    PG[(PostgreSQL\n5432)]:::database
    Redis[(Redis\n6379)]:::database
    Rabbit[(RabbitMQ\n5672)]:::messagingStore

    %% Worker Service
    subgraph "Worker Service"
        direction TB
        WorkerMain["cmd/worker/main.go"]:::service
        WService["internal/service"]:::service
        WQueue["pkg/queue/rabbitmq.go"]:::messaging
        WClient["internal/client/notification.go"]:::service
        ConfigWorker["internal/config/config.go"]:::service
    end

    %% Notification Service
    subgraph "Notification Service"
        direction TB
        NotifMain["cmd/notification/main.go"]:::service
        NProto["internal/proto/notification.proto"]:::service
        NService["internal/service"]:::service
        NTelegram["internal/client/telegram.go"]:::service
        ConfigNotif["internal/config/config.go"]:::service
    end

    %% External Telegram
    TelegramAPI["Telegram API"]:::external

    %% Connections - API
    Clients -->|"HTTP 8080"| API
    API --> Handlers
    Handlers --> Services
    Services --> Repos
    Services --> Domain
    Services -->|"SQL 5432"| PG
    Services -->|"Redis 6379"| Redis
    Services -->|"AMQP publish"| Rabbit
    Services --> Auth
    Services --> Cache
    Services --> QueuePub
    Services --> ConfigAPI

    %% Connections - Worker
    Rabbit -.-> WQueue
    WQueue --> WService
    WorkerMain --> WService
    WService --> WClient
    WorkerMain --> ConfigWorker

    %% Worker to Notification
    WClient -->|"gRPC 50051"| NotifMain

    %% Connections - Notification
    NotifMain --> NProto
    NotifMain --> NService
    NotifMain --> NTelegram
    NotifMain --> ConfigNotif
    NotifMain -->|"HTTPS"| TelegramAPI

    %% Click Events
    click API "https://github.com/beliyzy/task-tracker-golang/blob/main/cmd/api/main.go"
    click Handlers "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/handlers/user_handler.go"
    click Services "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/service/user_service.go"
    click Repos "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/repository/database.go"
    click Domain "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/domain/user.go"
    click Auth "https://github.com/beliyzy/task-tracker-golang/blob/main/pkg/auth/jwt.go"
    click Cache "https://github.com/beliyzy/task-tracker-golang/blob/main/pkg/cache/redis.go"
    click QueuePub "https://github.com/beliyzy/task-tracker-golang/blob/main/pkg/queue/rabbitmq.go"
    click ConfigAPI "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/config/config.go"
    click WorkerMain "https://github.com/beliyzy/task-tracker-golang/blob/main/cmd/worker/main.go"
    click WQueue "https://github.com/beliyzy/task-tracker-golang/blob/main/pkg/queue/rabbitmq.go"
    click WClient "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/client/notification.go"
    click NotifMain "https://github.com/beliyzy/task-tracker-golang/blob/main/cmd/notification/main.go"
    click NProto "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/proto/notification.proto"
    click NTelegram "https://github.com/beliyzy/task-tracker-golang/blob/main/internal/client/telegram.go"

    %% Styles
    classDef service fill:#0288D1,stroke:#000,color:#fff
    classDef database fill:#FB8C00,stroke:#000,color:#000
    classDef messaging fill:#8E24AA,stroke:#000,color:#fff
    classDef messagingStore fill:#8E24AA,stroke:#000,color:#fff
    classDef utility fill:#B0BEC5,stroke:#000,color:#000
    classDef external fill:#43A047,stroke:#000,color:#fff
```
