You probably did, that's the whole point of this repo. But if you're doing some other maintenance or cleanup and
didn't touch the fact graph at all, feel free to skip this stuff:
1. In `/direct-file/direct-file/df-client/df-client-app` can you run `npm run generate-fact-dictionary` successfully?
2. After having run the generate-fact-dictionary step, do the fact dictionary tests pass? (from `/direct-file/direct-file/df-client/df-client-app/src/test` run `npm run test factDictionaryTests`)
### Did you modify the supported tax scope?
Awesome! There's no community standard for this yet, but there probably should be. Let's figure out the right
steps to verify correctness together.
### If you made any changes beyond documentation:
1. Run the client and manually verify that your changes work as expected. The Flamingo Fact Checker is an all-star
here. `debugFactGraph.get()` and `debugFactGraphScala` are likely to be your friends too.
The backend application is available at http://localhost:8080 and the postgres database is exposed on port 5432 with username and password `postgres`.
When you're finished, tear it down with `docker compose down`.
We typically recommend running the front end components locally instead of through Docker to allow for hot reloading when making changes. Run the following from /direct-file/df-client
```bash
npm run start
```
The front end application is available at http://localhost:3000
# Codebase Overview
The below provides an introduction to various portions of the codebase. Most applications in our system come with a readme.md to explain what they are for. Follow the instructions there on how to build.
> n.b. Most, but not all, of the applications run in docker via running `docker-compose up --build` in the /direct-file directory. In particular, the applications that interact with MeF (status and submit) are read-only and are not included in the docker compose file.
>
> Direct File consists of a frontend React application, a suite of backend Java services, and a shared Scala library that ensures that taxpayers receive accurate error messages and UX flow for the tax rules that apply to them.
#### direct-file
Direct file is the home for the vast majority of our code. It is split into sub directories, many of which are applications in and of themselves.
#### direct-file/fact-graph-scala
The fact graph is the logical framework by which we store user information and calculate tax information. It is written in Scala and transpiled to JavaScript so that it can be used on the front end. It can be helpful to think of it like Excel. There are cells that a person writes in, and then there are a bunch of formulae that use the user entered information and calculated information.
#### direct-file/js-factgraph-scala
This is the module that contains the fact graph and the operations in the fact graph for the front end.
#### direct-file/backend
This application is the front door to our non-UI systems. It is responsible for integrating with an auth provider, generating tokens for our system, accepting user data, and maintaining user information. A bit more monolithic than we might have wanted but oh well.
#### direct-file/df-client/
Taxpayer facing frontend and UI. Utilizes the transpiled fact graph as the logical engine to control which screens are displayed. This is also the home for the flow, which is the configuration of which screens will be shown and under what conditions.
The frontend app is further in the `df-client-app` directory, whereas other frontend packages can exist at the `df-client` level. We use npm workspaces to connect our packages.
#### direct-file/submit
Submits tax returns to MeF
#### direct-file/status
Polls MeF for tax return acknowledgements
#### direct-file/email-service
SMTP relay service for sending emails to taxpayers, triggered on various system or MeF events
#### direct-file/state-api
Backend service responsible for the handling A2A traffic from state tax software providers via a REST API. These APIs are used to access federal return data (XML and return status). After a taxpayer submits their federal return, they may authorize the transfer of their federal return data with their state and the state tax software will pull that data through state-api.
## Local Environment Setup
__Table of Contents__
1. [Software Installs](#software-installs)
* [Required Software](#required-software)
* [Optional Software](#optional-software)
* [Installing software using Homebrew](#installing-software-using-homebrew)
* [Installing software using SDKMAN!](#installing-software-using-sdkman)
* [Stand up development containers](#stand-up-development-containers)
* [Build individual Spring Boot projects](#build-individual-spring-boot-projects)
* [Email-service](#email-service)
* [Build the client app](#build-the-client-app)
### Software Installs
Table of Contents
1. [Required Software](#required-software)
2. [Optional Software](#optional-software)
3. [Installing software using Homebrew](#installing-software-using-homebrew)
4. [Installing software using SDKMAN!](#installing-software-using-sdkman)
#### Required Software
* Java
* Scala
* Maven
* SBT
* coursier
* Docker for Desktop
There are instructions below for using `Homebrew` or `SDKMAN` to install the required software. You should only follow one path or the other, unless the instructions tell you to do otherwise (i.e. `SDKMAN` doesn't currently support `coursier`, so you might use `Homebrew` for that).
#### Optional Software
* Homebrew
* SDKMAN!
* Visual Studio Code
* IntelliJ Community Edition
#### Installing software using Homebrew
You will need to install SBT (a build tool for Scala, does it mean Scala Build Tool?) in order to run some of the below steps, if using macOS, it is recommended that you install [Homebrew](https://brew.sh/) first and then use brew to install SBT
* Then either in your `.zshrc` or `.zprofile` file paste the following
```sh
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"
```
* Then simply install SBT as documented [here](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Mac.html#)
```sh
brew install sbt
```
* You will also need to install Scala, Coursier, Java, Maven, and Docker
```sh
brew install --cask docker
```
```sh
brew install scala maven openjdk@21 coursier
```
* If you had another JDK installed, you may need to link the java 21 JDK
```sh
brew unlink openjdk
```
```sh
brew link --force openjdk@21
```
* Add to your `.bash_profile` to ensure maven finds the correct version of java
```sh
export JAVA_HOME=$(brew --prefix openjdk@21)
```
* Configure Coursier to use the right version of Java for the direct file project. You may wish to add this to your .bash_profile or .zshrc to ensure it runs every time you load a new terminal.
```sh
eval "$(coursier java --jvm 21 --env)"
```
* Run Docker (from spotlight search on Mac). The Docker icon should appear in your status bar. You may wish to configure Docker to run at login/startup.
#### Installing software using SDKMAN!
Most of the project dependencies can be installed using [SDKMAN!](https://sdkman.io/), a CLI and API for managing SDKs from the JVM and beyond. SDKMAN! supports installation of Java, Scala, sbt, and Maven.
> Please note that support for installation of Coursier using SDKMAN! is currently under development, so this is the one tool we'll need to install manually.
* First, install SDKMAN! using the following command in a terminal:
```sh
curl -s "https://get.sdkman.io" | bash
```
* Then, open a new terminal OR run the following in the same shell to enable SDKMAN! in the current terminal:
```sh
source "$HOME/.sdkman/bin/sdkman-init.sh"
```
> SDKMAN! will configure your $JAVA_HOME automatically to point to `"$HOME/.sdkman/candidates/java/current"` by default.
* You can install the latest stable version of your SDK tools using its canonical name without specifying a version:
> You can use the `sdk list {package}` command to list out available versions. (eg., `sdk list java` will show you available OpenJDK builds).
```sh
sdk install java
```
```sh
sdk install sbt
```
```sh
sdk install scala
```
```sh
sdk install maven
```
* Until SDKMAN! supports Coursier officially, you'll need to manually install it here.
* Either consult the Homebrew instructions above, or follow their official [CLI installation](https://get-coursier.io/docs/cli-installation) steps:
You'll want to make sure that `cs` is available on your `$PATH`.
* Then, configure Coursier to use the right version of Java for the direct file project. You may wish to add this to your .bash_profile or .zshrc to ensure it runs every time you load a new terminal.
```sh
eval "$(coursier java --jvm 21 --env)"
```
* Run Docker (from spotlight search on Mac). The Docker icon should appear in your status bar. You may wish to configure Docker to run at login/startup.
### Source Code
* Clone this repo
### Environment Variables
1. Add the following environment variables to your system, on macOS you can add the following lines to your shell's root config file (i.e. the `.zshenv`, `.zshrc`, or `.bashrc` file). Note that you will need to edit most variables.
2. From the root directory of this repo, run the following command to generate a value for LOCAL_WRAPPING_KEY:
```sh
./direct-file/scripts/local-setup.sh
```
3. Re-load your environment so that the new `LOCAL_WRAPPING_KEY` value is loaded. If you set the values in one of your shell dotfiles (e.g. `.zshrc`), open a new terminal.
### Building with Docker
1. To work with the Direct File docker setup, change into the `direct-file` subdirectory of this repo.
```sh
cd direct-file/
```
#### Default Services/Containers
1. Run the following command to build and start the default services and containers:
```sh
docker compose up -d --build
```
1. You should see the following (among other) containers start up:
Need to run/develop the client app? Check out the [df-client/README](/direct-file/df-client/README.md) for info on getting your local environment setup.
## Application Tests
Each application has its own set of tests. To run server-side tests within an app, navigate to the root of the app. Run:
```sh
cd direct-file/<project>
./mvnw test
```
To run a test individually, run `./mvnw -Dtest=<Name of Test> test` with the test name. For example:
```sh
./mvnw -Dtest=TaxReturnServiceTest test
```
__NOTE__ - add the `-X` flag to any maven command to switch on debug logging