# abhiraa/dataanalyticshub architecture

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

- Interactive diagram: https://gitdiagram.com/abhiraa/dataanalyticshub
- Repository: https://github.com/abhiraa/dataanalyticshub

## Overview

##### Project Type and Purpose
- This is a desktop full-stack MVC application built with JavaFX, using an embedded SQLite database for persistence, and JUnit for testing.
- Key functions: user/profile management, posting, CSV import, data analytics (pie charts, dashboards).

##### Top-Level Architectural Layers
- Presentation Layer (JavaFX UI)
- Controller Layer (UserController, PostController)
- Service Layer (UserService, PostService, ServiceFactory)
- Data Access Layer (DAO classes and DBManager)
- Persistence (SQLite database)
- Utilities & Exceptions
- External Libraries (javafx-sdk-21, sqlite-jdbc)

##### Main Components & Boundaries
a. Presentation (UI)
- JavaFX Views (LoginView, DashboardView, PostListView, etc.)
- GUIViewFacade (Facade Pattern) providing a simple interface for the views to call controllers.
b. Controllers
- UserController, PostController coordinate between Views and Services.
c. Service Layer
- UserService & PostService interfaces with implementations (Impl).
- ServiceFactory (Factory Pattern) to obtain service instances.
d. Data Access Layer
- DAOs: UserDAO, PostDAO for CRUD operations.
- DBManager (Singleton Pattern) managing the JDBC connection to the SQLite file DataAnalyticsHub.db.
e. Persistence
- SQLite database file under src/database.
f. Utilities & Exceptions
- CSVUtils, PasswordUtils, FileChooserUtils under utils.
- Custom exceptions under exceptions.
g. External Dependencies
- JavaFX runtime (javafx-sdk-21 jars)
- sqlite-jdbc-3.43.0.0.jar

##### Data Flow & Interactions
1) Application Start
- Main.java initializes JavaFX Application and shows LoginView via GUIViewFacade.
2) User Interaction
- User clicks on a View’s GUI control → View invokes a method on GUIViewFacadeInterface.
- GUIViewFacade routes call to the appropriate Controller.
3) Controller Layer
- Controller (e.g., UserController) processes input → calls Service layer via ServiceFactory.
4) Service Layer
- ServiceImpl applies business logic (e.g., password hashing via PasswordUtils) → calls DAO.
5) DAO & DBManager
- DAO uses DBManager’s singleton JDBC connection to execute SQL on the SQLite database.
- Data returns up the chain to Service → Controller → View.
6) Utilities
- CSVUtils reads/writes CSV files for bulk import/export.
7) Testing
- JUnit test classes bypass UI; instantiate Services and DAOs directly, using test data CSVs in src/csv.

##### Architectural Patterns & Principles
- MVC Pattern: clear separation of Models, Views, Controllers.
- Facade Pattern: GUIViewFacade hides complex controller interactions from Views.
- Factory Pattern: ServiceFactory centralizes creation of service objects.
- Singleton Pattern: DBManager ensures a single database connection.
- Layered Architecture: UI → Controllers → Services → DAOs → DB.

##### Final Checklist
- All layers and components separated and labeled clearly.
- Pattern annotations (Facade, Factory, Singleton, MVC).
- External libs and resources depicted.
- Utility modules and exception handling paths shown.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Main Entry
    Main["Main.java"]:::main

    %% Presentation Layer
    subgraph "Presentation Layer"
        BaseView["BaseView"]:::ui
        LoginView["LoginView"]:::ui
        SignupView["SignupView"]:::ui
        DashboardView["DashboardView"]:::ui
        PostListView["PostListView"]:::ui
        PostFormView["PostFormView"]:::ui
        BulkImportView["BulkImportView"]:::ui
        PieChartView["PieChartView"]:::ui
        EntryView["EntryView"]:::ui
        ProfileView["ProfileView"]:::ui
        UpgradeToVIPView["UpgradeToVIPView"]:::ui
        ViewInterfaces["View Interfaces"]:::ui
    end

    %% Facade Layer
    subgraph "Facade Layer"
        GUIViewFacadeInterface["GUIViewFacadeInterface (Facade)"]:::facade
        GUIViewFacade["GUIViewFacade (Facade)"]:::facade
    end

    %% Controller Layer
    subgraph "Controller Layer"
        UserController["UserController"]:::controller
        PostController["PostController"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        UserService["UserService"]:::service
        UserServiceImpl["UserServiceImpl"]:::service
        PostService["PostService"]:::service
        PostServiceImpl["PostServiceImpl"]:::service
        ServiceFactory["ServiceFactory (Factory)"]:::service
        ServiceFactoryImpl["ServiceFactoryImpl"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DBManager["DBManager (Singleton)"]:::dao
        UserDAO["UserDAO"]:::dao
        PostDAO["PostDAO"]:::dao
    end

    %% Persistence
    subgraph "Persistence"
        SQLiteDB["DataAnalyticsHub.db"]:::db
    end

    %% Utilities
    subgraph "Utilities & Exceptions"
        CSVUtils["CSVUtils"]:::util
        PasswordUtils["PasswordUtils"]:::util
        FileChooserUtils["FileChooserUtils"]:::util
    end

    %% External Libraries
    subgraph "External Libraries"
        JavaFXSDK["JavaFX SDK"]:::external
        SQLiteJDBC["sqlite-jdbc-3.43.0.0.jar"]:::external
    end

    %% Interactions
    Main -->|"launch()"| LoginView
    LoginView -->|"loginRequest()"| GUIViewFacadeInterface
    SignupView -->|"signupRequest()"| GUIViewFacadeInterface
    DashboardView -->|"loadDashboard()"| GUIViewFacadeInterface
    PostListView -->|"fetchPosts()"| GUIViewFacadeInterface
    PostFormView -->|"submitPost()"| GUIViewFacadeInterface
    BulkImportView -->|"importCSV()"| GUIViewFacadeInterface
    PieChartView -->|"renderChart()"| GUIViewFacadeInterface

    GUIViewFacadeInterface -->|"toFacade()"| GUIViewFacade
    GUIViewFacade -->|"routeToUserController()"| UserController
    GUIViewFacade -->|"routeToPostController()"| PostController

    UserController -->|"loginUser() / registerUser()"| ServiceFactory
    PostController -->|"createPost() / getPosts()"| ServiceFactory

    ServiceFactory -->|"getUserService()"| UserServiceImpl
    ServiceFactory -->|"getPostService()"| PostServiceImpl

    UserServiceImpl -->|"hashPassword()"| PasswordUtils
    UserServiceImpl -->|"validateUser()"| UserDAO
    PostServiceImpl -->|"validatePost()"| PostDAO
    PostServiceImpl -->|"exportCSV()"| CSVUtils

    UserDAO -->|"executeQuery()"| DBManager
    PostDAO -->|"executeQuery()"| DBManager
    DBManager -->|"jdbcConnection()"| SQLiteDB

    BulkImportView -->|"bulkImport()"| CSVUtils
    CSVUtils -->|"parseCSV()"| UserDAO
    CSVUtils -->|"parseCSV()"| PostDAO

    JavaFXSDK -->|supports| LoginView
    JavaFXSDK -->|supports| DashboardView
    SQLiteJDBC -->|driver| DBManager

    %% Click Events
    click Main "https://github.com/abhiraa/dataanalyticshub/blob/master/src/main/Main.java"
    click BaseView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/BaseView.java"
    click LoginView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/LoginView.java"
    click SignupView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/SignupView.java"
    click DashboardView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/DashboardView.java"
    click PostListView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/PostListView.java"
    click PostFormView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/PostFormView.java"
    click BulkImportView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/BulkImportView.java"
    click PieChartView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/PieChartView.java"
    click EntryView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/EntryView.java"
    click ProfileView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/ProfileView.java"
    click UpgradeToVIPView "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/UpgradeToVIPView.java"
    click ViewInterfaces "https://github.com/abhiraa/dataanalyticshub/tree/master/src/views/interfaces/"
    click GUIViewFacadeInterface "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/facade/GUIViewFacadeInterface.java"
    click GUIViewFacade "https://github.com/abhiraa/dataanalyticshub/blob/master/src/views/facade/GUIViewFacade.java"
    click UserController "https://github.com/abhiraa/dataanalyticshub/blob/master/src/controllers/UserController.java"
    click PostController "https://github.com/abhiraa/dataanalyticshub/blob/master/src/controllers/PostController.java"
    click UserService "https://github.com/abhiraa/dataanalyticshub/blob/master/src/services/UserService.java"
    click UserServiceImpl "https://github.com/abhiraa/dataanalyticshub/blob/master/src/services/UserServiceImpl.java"
    click PostService "https://github.com/abhiraa/dataanalyticshub/blob/master/src/services/PostService.java"
    click PostServiceImpl "https://github.com/abhiraa/dataanalyticshub/blob/master/src/services/PostServiceImpl.java"
    click ServiceFactory "https://github.com/abhiraa/dataanalyticshub/blob/master/src/services/factory/ServiceFactory.java"
    click ServiceFactoryImpl "https://github.com/abhiraa/dataanalyticshub/blob/master/src/services/factory/ServiceFactoryImpl.java"
    click DBManager "https://github.com/abhiraa/dataanalyticshub/blob/master/src/database/DBManager.java"
    click UserDAO "https://github.com/abhiraa/dataanalyticshub/blob/master/src/database/UserDAO.java"
    click PostDAO "https://github.com/abhiraa/dataanalyticshub/blob/master/src/database/PostDAO.java"
    click SQLiteDB "https://github.com/abhiraa/dataanalyticshub/blob/master/src/database/DataAnalyticsHub.db"
    click SQLiteJDBC "https://github.com/abhiraa/dataanalyticshub/blob/master/src/database/sqlite-jdbc-3.43.0.0.jar"
    click CSVUtils "https://github.com/abhiraa/dataanalyticshub/blob/master/src/utils/CSVUtils.java"
    click PasswordUtils "https://github.com/abhiraa/dataanalyticshub/blob/master/src/utils/PasswordUtils.java"
    click FileChooserUtils "https://github.com/abhiraa/dataanalyticshub/blob/master/src/utils/FileChooserUtils.java"

    %% Styles
    classDef main fill:#ffe4b5,stroke:#333,stroke-width:1px
    classDef ui fill:#add8e6,stroke:#333,stroke-width:1px
    classDef facade fill:#87cefa,stroke:#333,stroke-width:1px
    classDef controller fill:#98fb98,stroke:#333,stroke-width:1px
    classDef service fill:#ffa500,stroke:#333,stroke-width:1px
    classDef dao fill:#dda0dd,stroke:#333,stroke-width:1px
    classDef db fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef util fill:#ffffe0,stroke:#333,stroke-width:1px
    classDef external fill:#ffc0cb,stroke:#333,stroke-width:1px
```
