diff --git a/.DS_Store b/.DS_Store
index f14155e..f206578 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 03f397c..cfccaaa 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index bc1552a..eec676b 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,34 @@
Please use this readme as your projects readme. You can find instructions for
the assignment in the [`INSTRUCTIONS.md`](INSTRUCTIONS.md) file.
+# Table of contents
+- [Setup instructions](#setup-instructions)
+- [Overview](#overview)
+ * [Classes and packages](#classes-and-packages)
+ + [Services](#services)
+ - [AppConfigService](#appconfigservice)
+ - [DatabaseService](#databaseservice)
+ - [ReportGenerationService](#reportgenerationservice)
+ + [Data](#data)
+ - [DTOs](#dtos)
+ - [Enums](#enums)
+ - [Repos](#repos)
+ - [Models](#models)
+ + [APIs](#apis)
+- [Improvements](#improvements)
+
+# Setup instructions
+1. Add the [postgresql-42.5.1.jar](libs/postgresql-42.5.1.jar) as a library dependency in your IDE.
+ + Instructions for specific IDEs: [IntelliJ](https://stackoverflow.com/questions/1051640/correct-way-to-add-external-jars-lib-jar-to-an-intellij-idea-project), [Eclipse](https://www.edureka.co/community/4028/how-to-import-a-jar-file-in-eclipse)
+ + Per build-tool, for different version etc. [Maven](https://mvnrepository.com/artifact/mysql/mysql-connector-java), [Gradle](https://stackoverflow.com/a/50484781/11981966), [Ant](https://ant.apache.org/manual/api/org/apache/tools/ant/taskdefs/JDBCTask.html).
+2. Follow the Docker-setup instruction in [INSTRUCTIONS.md](INSTRUCTIONS.md#setup).
+
Overview
========
-
This project is a simple command-line application that communicates with a PostgreSQL database to retrieve data and generate reports based on that data. It's composed of several classes and packages that work together to accomplish this task.
+![Class UML](docs/ClassUML.png)
+
Classes and packages
--------------------
@@ -41,16 +64,18 @@ The application's main class is `Main` class, it runs the entire application. It
### APIs
`apis` package contains the `DatabaseApi` class. This class communicates with the database to perform final CRUD operations, returning any results. This class is responsible for executing SQL statements, which are passed to it in the form of a QueryDTO class. It receives a QueryDTO object and a JDBC connection, then it processes the query and returns a PreparedStatement object. This class is designed to handle any exception that may occur during the execution of the query and it can be extended in the future to handle other types of queries if needed.
-### Improvements
+# Improvements
Here are some points that I could have improved upon, but did not go through with it because of either time constraints, or because it might be too much for the scope of this assignment.
+ Ideally all the services, and inner services and APIs being used, should be injected in by dependency injection. In Dart, [get_it](https://pub.dev/packages/get_it), is makes this very easy with a Locator file. But for Java, I was not able to find something that was as easy.
++ Ideally the AppConfigService should be more generalized to acecpt N number of user inputs, for the scalability.
+ + That would have also helped with making the pipeline in `run()` better, as the list of config vars could be supplied directly, instead of manually specifying.
+ The DatabaseService class is tightly coupling the DatabaseApi class. It's better to make the DatabaseApi class a singleton and inject it into the DatabaseService class.
+ The DatabaseApi class is doing more than just communicating with the database, it's also handling error handling. It would be better to extract the error handling logic into a separate class.
+ Could be rectified by using lots of custom Exceptions in general, but overkill for this scope.
+ The QueryResultsRepository class is tightly coupled to the PersistentResultSetModel class. It would be better to extract the PersistentResultSetModel class into a separate package, and use a factory pattern to create instances of it.
+ The App class is doing too much. It would be better to extract the logic for each endpoint into separate classes, and use a factory pattern to create instances of them.
- + But then again, too much inheritance.
+ + But then till it is needed, composition was preferred over inheritance.
+ The Main class should be refactored to use dependency injection, so that the dependencies can be easily swapped out for testing.
+ The AppConfigService class should be refactored to use a more robust input validation library, to handle more edge cases.
+ The ReportGenerationService class should be refactored to support more output formats, such as HTML, CSV and PDF.
diff --git a/docs/ClassUML.png b/docs/ClassUML.png
index 3535f4b..01f84b9 100644
Binary files a/docs/ClassUML.png and b/docs/ClassUML.png differ
diff --git a/src/Main.java b/src/Main.java
index 6cb5faa..47969fd 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -93,8 +93,6 @@ class App {
resultsRepository = databaseService.getReadReportsEndpoint(new QueryDTO(query, new Object[]{appConfigService.getCountryName(), appConfigService.getDate(),}));
reportGenerationService.reportBaseResults(resultsRepository);
}
-
-
} catch (SQLException e) {
throw new RuntimeException(e);
}
diff --git a/src/constants/ConstFormatters.java b/src/constants/ConstFormatters.java
deleted file mode 100644
index 5cec3c3..0000000
--- a/src/constants/ConstFormatters.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package constants;
-
-import java.text.SimpleDateFormat;
-
-public class Formatters {
- final public static SimpleDateFormat APPLICATION_DATE_FORMATTER = new SimpleDateFormat("dd-MM-yyyy");
-}
diff --git a/src/constants/ConstValues.java b/src/constants/ConstValues.java
deleted file mode 100644
index 24d4cbd..0000000
--- a/src/constants/ConstValues.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package constants;
-
-public class ConstValues {
- //I
- final public static String inputCountryName = "Enter country: ";
- final public static String inputDate = "Enter date: ";
-}