# mehmetali10/task-planner architecture

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

- Interactive diagram: https://gitdiagram.com/mehmetali10/task-planner
- Repository: https://github.com/mehmetali10/task-planner

## Overview

##### Console Application (backend/cmd/console)
- Responsible for fetching external tasks using a CLI built on Cobra.
- Utilizes worker pools and Go concurrency primitives (goroutines, channels) to handle multiple providers.
- Designed for extensibility so new task providers can be integrated easily.

##### Task Service (backend/cmd/task)
- Acts as the core backend service for managing tasks and developers.
- Implements an optimized scheduling algorithm, backed by PostgreSQL for persistent storage.
- Exposes REST APIs (documented via Swagger) and handles task distribution concurrently using Go channels.

##### Frontend Application (frontend)
- A React-based web interface that provides a dynamic UI for viewing task schedules, developers, and task details.
- Communicates with the task service backend via API calls to present scheduling results and other task data.

- A separate block for the Database (PostgreSQL) indicating where data (tasks, developers, etc.) is stored.
- Optionally, include an “External Providers” component to show where task data originates, which the Console App interacts with.

b. Relationships and interactions:
- From "External Providers" to the "Console Application" (showing fetching and input of tasks).
- From "Console Application" to "Database" (storing fetched tasks).
- From "Task Service" to "Database": both reading and writing task/developer data, as well as scheduling logic.
- From "Frontend Application" to "Task Service": REST API calls to display and manage tasks.
- Concurrent operations in the console and task service (e.g., annotate “Worker Pool” and “Go Channels”).

c. Architectural patterns/design principles:
- Use of the Worker Pool pattern in the Console App and go concurrency (goroutines, channels) in both the Console App and Task Service for efficient parallel processing.
- Microservice-like separation between the backend services and the frontend UI while also noting containerization (Docker files for each component) as part of deployment.
- A dedicated section for API documentation and monitoring (Swagger, Prometheus) if desired.

d. Relevant technologies and frameworks:
- Backend (Go, Cobra CLI, Go channels, worker pool, PostgreSQL, Testcontainers for testing, Swagger for API docs).
- Frontend (React with related libraries from package.json).
- Deployment components (Docker, Docker Compose, Kubernetes in deployment folder).

- For a full-stack application:
- Clearly separate the frontend (React UI) from the backend services.
- API layer within the Task Service that bridges the frontend with the core scheduling functionalities.

- For highlighting core functionality:
- Scheduling algorithm and task distribution logic, along with the worker pool in the Console App, are distinctly visualized.

- Clear, labeled blocks for each component with names (e.g., "Console Application: Task Fetcher", "Task Service: Scheduler & API", "Frontend UI: React App", "Database: PostgreSQL").
- Technological specifics inside or beside each block (e.g., "Goroutines & Worker Pools" in the Console App, "Swagger, Go Channels" in Task Service, "React" in Frontend).

- Every major module in the project, from the CLI-based Console Application and detailed Task Service to the interactive Frontend Application.
- All integration points including the database, API interactions, external providers, and the deployment architecture (Docker, Docker Compose).
- Specific patterns and technologies to clearly communicate how tasks are fetched, processed, scheduled, and displayed to end-users.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Providers
    subgraph "External Providers"
        EP("External Providers"):::external
    end

    %% Console Application
    subgraph "Console Application"
        CA("Console Application: Task Fetcher\n(Goroutines & Worker Pools)"):::backend
        WP("Worker Pool (Console)"):::backend
        TP("Task Provider (Console)"):::backend
        CA --> WP
        CA --> TP
    end

    %% PostgreSQL Integration (Database)
    subgraph "PostgreSQL Integration"
        DB("Database: PostgreSQL"):::database
        PC("Postgres Connect"):::database
        TT("Task Table"):::database
        DT("Developer Table"):::database
        AC("Autocrudder"):::database
        DB --> PC
        DB --> TT
        DB --> DT
        DB --> AC
    end

    %% Task Service
    subgraph "Task Service"
        TS("Task Service: Scheduler & API\n(Swagger, Go Channels)"):::backend
        SA("Scheduling Algorithm"):::backend
        AH("API Handlers"):::backend
        SD("Swagger Docs"):::backend
        TS --> SA
        TS --> AH
        TS --> SD
    end

    %% Frontend Application
    subgraph "Frontend Application"
        FE("Frontend UI: React App"):::frontend
    end

    %% Connections
    EP -->|"fetches_tasks"| CA
    CA -->|"stores_tasks"| DB
    TS -->|"reads/writes_tasks/developers"| DB
    FE -->|"REST_API_calls"| TS

    %% Click Events
    click CA "https://github.com/mehmetali10/task-planner/tree/main/backend/cmd/console"
    click WP "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/console/worker/pool.go"
    click TP "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/console/provider/fetch.go"
    click EP "https://github.com/mehmetali10/task-planner/tree/main/backend/internal/console/provider"
    
    click TS "https://github.com/mehmetali10/task-planner/tree/main/backend/cmd/task"
    click SA "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/task/service/schedule.go"
    click AH "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/task/handler/handler.go"
    click SD "https://github.com/mehmetali10/task-planner/tree/main/backend/internal/task/docs"
    
    click FE "https://github.com/mehmetali10/task-planner/tree/main/frontend"
    
    click DB "https://github.com/mehmetali10/task-planner/tree/main/backend/internal/pkg/database/postgres"
    click PC "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/pkg/database/postgres/connect.go"
    click TT "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/pkg/database/tables/task.go"
    click DT "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/pkg/database/tables/developer.go"
    click AC "https://github.com/mehmetali10/task-planner/blob/main/backend/internal/pkg/database/postgres/autocrudder.go"

    %% Styles
    classDef backend fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef frontend fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef database fill:#cce5ff,stroke:#003399,stroke-width:2px;
    classDef external fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
```
