# jao-viquitor/intuitive architecture

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

- Interactive diagram: https://gitdiagram.com/jao-viquitor/intuitive
- Repository: https://github.com/jao-viquitor/intuitive

## Overview

##### Project Type & Purpose
- The project is a full-stack web application aimed at analyzing and visualizing public health operator (ANS) data.
- Its key functionalities include data preprocessing of CSV files (from ANS), a Flask-based REST API backend (with MySQL as the data store), and a Vue 3 Single-Page Application (SPA) frontend.
- Use cases include searching for operators, filtering by state, and displaying top operators based on health expenses.

##### Analyzing the File Structure
- Top-Level Directories:
- backend: Contains the Flask API (with files like api.py, config.py, db.py), utility scripts (preprocessamento.py), and API documentation via a Postman collection. This module handles business logic, data fetching, and database interactions.
- frontend: Holds the Vue 3 SPA with dedicated folders for components, pages, assets, routing, and services. Tailwind CSS and Vite configurations are utilized here.
- dados: Contains raw CSV data that are used for data processing.
- db: Contains SQL scripts to initialize schema and import data into MySQL.
- The separation of concerns (backend processing, frontend presentation, database setup, and data ingestion) is a key architectural element that must be clearly depicted.

##### Recommendations
a. Main Components:
- Frontend: Vue 3 SPA components, pages, routing (Vue Router) & services for API calls.
- Backend: Flask API handling endpoints, configuration and database connections, including pre-processing utilities.
- Database: MySQL database with its schema and import routines (SQL scripts).
- Data Ingestion: CSV files in 'dados/' that are preprocessed by a utility script (preprocessamento.py) before being loaded into the database.
- External Tools: Postman collection for testing API endpoints.

b. Relationships and Interactions:
- The Frontend interacts with the Backend via RESTful API calls (e.g., Axios is used in Vue services).
- The Backend communicates with MySQL using the connection parameters defined in configuration files, handling queries and updates.
- The Data Preprocessing module (found in backend/utils) ingests raw CSV files and prepares them for database import (executed prior to running the API).
- Interactions such as data flow from the data files (dados) → preprocessor → DB (MySQL) → API (Flask) → Frontend (Vue 3 SPA).

c. Architectural Patterns / Design Principles:
- Separation of concerns between backend and frontend.
- REST API principles in the Flask backend.
- SPA design in the Vue frontend that decouples UI rendering from business logic.
- Usage of modular design (components/ services in frontend; modular endpoints and configs in backend).
- Clear delineation of data processing pipelines from data ingestion to presentation.

d. Key Technologies and Frameworks:
- Backend: Python, Flask, MySQL, python-dotenv (for environment configuration), CORS for cross-domain requests.
- Frontend: Vue 3, Vite, Tailwind CSS, Axios, Vue Router.
- Data: CSV files from ANS, processed notably using Pandas (implied in preprocessamento.py).
- Utilities: Postman for API testing, environment management via .env files and virtual environments.

##### Elements
- Clear Labels: Every major component should be clearly labeled (such as "Vue 3 SPA", "Flask API", "MySQL Database", "Data Preprocessing", etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Ingestion & Database"
        csvFiles["CSV Files (ANS)"]:::datafill
        dataPreprocess["Data Preprocessing"]:::datafill
        mysqlDB["MySQL Database"]:::db
        csvFiles -->|"CSV_data"| dataPreprocess
        dataPreprocess -->|"Processed_data"| mysqlDB
    end

    subgraph "Backend Layer"
        flaskAPI["Flask API"]:::backend
        mysqlDB ---|"SQL_Query"| flaskAPI
        flaskAPI ---|"SQL_Response"| mysqlDB
        apiDoc["API Documentation (Postman)"]:::external
        flaskAPI -->|"Test_endpoints"| apiDoc
    end

    subgraph "Frontend Layer"
        vueSPA["Vue 3 SPA"]:::frontend
        vueSPA -->|"REST_API_calls"| flaskAPI
    end

    click csvFiles "https://github.com/jao-viquitor/intuitive/tree/master/dados/"
    click dataPreprocess "https://github.com/jao-viquitor/intuitive/blob/master/backend/utils/preprocessamento.py"
    click mysqlDB "https://github.com/jao-viquitor/intuitive/tree/master/db/"
    click flaskAPI "https://github.com/jao-viquitor/intuitive/tree/master/backend/app/"
    click vueSPA "https://github.com/jao-viquitor/intuitive/tree/master/frontend/"
    click apiDoc "https://github.com/jao-viquitor/intuitive/blob/master/backend/docs/intuitiveCare.postman_collection.json"

    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef db fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef datafill fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
