# jbqneto/covid-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/jbqneto/covid-tracker
- Repository: https://github.com/jbqneto/covid-tracker

## Overview

##### Project Type and Purpose
- This is a lightweight, web-based application developed with Java and Spring Boot that displays live COVID-19 case data.
- Its main purpose is to fetch COVID data (via HTTP GET calls) from an external GitHub repository (which hosts CSV data), process it, and display it on HTML pages using Thymeleaf.
- The project also serves as a practice implementation of Spring’s MVC structure and integration with external libraries like Apache HttpClient and Apache CSV Commons.

##### File Structure
- Top-Level structure:
- A Maven build with files like pom.xml, mvnw, and wrapper configuration indicates that Maven is used for dependency management and builds.
- The existence of a src/main directory containing Java source code and resources (including Thymeleaf templates in src/main/resources/templates) confirms a typical Spring Boot application.
- Within src/main/java/io/jbqneto/covidtracker:
- CovidTrackerApplication.java serves as the entry point for the Spring Boot application.
- The controller folder (e.g., HomeController.java) handles incoming HTTP requests.
- The service folder (CovidService.java) contains business logic and integrations (like calling external APIs).
- The model folder holds data representations (e.g., CovidData.java and TimeSeries.java) used across the application.
- The resources directory holds configuration (application.properties) and view templates, indicating use of Thymeleaf for dynamic HTML generation.

##### Insights from the README
- The README highlights that this project uses Spring for the backend logic and Thymeleaf for rendering HTML, following a tutorial route but with notable customizations (like using Java 8, HttpClient, and CSV Commons).
- It describes the inclusion of features (e.g., viewing confirmed, recovered, and death cases) and explicitly mentions external dependencies and URL sources.
- The README confirms that this is a single-application, MVC patterned system with external data integration.

a. Main Components to Include:
- External COVID Data Source:
- GitHub repository (or remote raw CSV file source) where COVID data is hosted.
- HttpClient Integration:
- Component (likely inside the service layer) responsible for making HTTP GET requests to the external COVID data source.
- COVID Tracker Application (Spring Boot):
- Controller Layer: (e.g., HomeController) handles HTTP requests from users.
- Service Layer: (e.g., CovidService) fetches and processes external data. Make clear that it uses Apache HttpClient for requesting external data and Apache CSV Commons for parsing CSV files.
- Model/Domain Layer: Contains data objects like CovidData and TimeSeries.
- View Layer: Represented by Thymeleaf templates, for example, home.html, which renders data into HTML views.
b. Relationships and Interactions:
- Users (Client Browser) initiate HTTP requests which are routed to the HomeController.
- The Controller calls the CovidService to fetch and process COVID data.
- The Service makes an outgoing HTTP request (using HttpClient) to the remote GitHub data source.
- After retrieving data, the service uses Apache CSV Commons to parse the CSV data into model objects.
- The processed data is then forwarded back through the Controller to be rendered in the Thymeleaf-generated view.
c. Architectural Patterns and Design Principles:
- Model-View-Controller (MVC) pattern.
- The separation of concerns is clear: external integration and data processing are encapsulated within the service layer, while the controller handles routing and the view layer is solely responsible for rendering.
d. Technologies, Frameworks, and Libraries:
- Java 8, Spring Boot for application framework.
- Thymeleaf for dynamic HTML templating.
- Apache HttpClient for HTTP requests.
- Apache CSV Commons for CSV parsing.
- Maven for build and dependency management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application & Config"
        SpringApp["CovidTrackerApplication"]:::app
        AppConfig["Application Properties"]:::config
        Maven["Maven Build (pom.xml)"]:::build
    end

    subgraph "Client Layer"
        Browser["User/Browser"]:::client
    end

    subgraph "Controller Layer"
        HomeController["HomeController"]:::controller
    end

    subgraph "Service Layer"
        CovidService["CovidService\n(Apache HttpClient + CSV Commons)"]:::service
    end

    subgraph "Model Layer"
        CovidData["CovidData"]:::model
        TimeSeries["TimeSeries"]:::model
    end

    subgraph "View Layer"
        Thymeleaf["Thymeleaf Template (home.html)"]:::view
    end

    subgraph "External Integration"
        ExternalSource["External COVID Data Source"]:::external
    end

    Browser -->|"HTTP_Request"| HomeController
    HomeController -->|"Calls_Service"| CovidService
    CovidService -->|"HttpGET_Request"| ExternalSource
    ExternalSource -->|"CSV_Data"| CovidService
    CovidService -->|"Updates_CovidData"| CovidData
    CovidService -->|"Updates_TimeSeries"| TimeSeries
    CovidService -->|"Returns_Data"| HomeController
    HomeController -->|"Renders_View"| Thymeleaf

    SpringApp --> HomeController
    SpringApp --> CovidService
    SpringApp --> CovidData
    SpringApp --> TimeSeries
    SpringApp --> Thymeleaf
    SpringApp --> AppConfig
    SpringApp --> Maven

    classDef client fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef controller fill:#A3E4D7,stroke:#117864,stroke-width:2px;
    classDef service fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef model fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef view fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#2471A3,stroke-width:2px;
    classDef app fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef config fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef build fill:#FDEBD0,stroke:#CA6F1E,stroke-width:2px;

    click SpringApp "https://github.com/jbqneto/covid-tracker/blob/master/src/main/java/io/jbqneto/covidtracker/CovidTrackerApplication.java"
    click HomeController "https://github.com/jbqneto/covid-tracker/blob/master/src/main/java/io/jbqneto/covidtracker/controller/HomeController.java"
    click CovidService "https://github.com/jbqneto/covid-tracker/blob/master/src/main/java/io/jbqneto/covidtracker/service/CovidService.java"
    click CovidData "https://github.com/jbqneto/covid-tracker/blob/master/src/main/java/io/jbqneto/covidtracker/model/CovidData.java"
    click TimeSeries "https://github.com/jbqneto/covid-tracker/blob/master/src/main/java/io/jbqneto/covidtracker/model/TimeSeries.java"
    click Thymeleaf "https://github.com/jbqneto/covid-tracker/blob/master/src/main/resources/templates/home.html"
    click AppConfig "https://github.com/jbqneto/covid-tracker/blob/master/src/main/resources/application.properties"
    click Maven "https://github.com/jbqneto/covid-tracker/blob/master/pom.xml"
```
