Table of Contents
- Quickstart
- Codebase Overview
- Local Environment Setup
- Software Installs
- Source Code
- Environment Variables
- Building with Docker - RECOMMENDED
- Building with command line — local builds)
- Application Tests
To run everything:
docker compose up -d --buildThe 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
npm run startThe front end application is available at http://localhost:3000
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 --buildin 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 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.
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.
This is the module that contains the fact graph and the operations in the fact graph for the front end.
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.
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.
Submits tax returns to MeF
Polls MeF for tax return acknowledgements
SMTP relay service for sending emails to taxpayers, triggered on various system or MeF events
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.
Table of Contents
- Software Installs
- Source Code
- Environment Variables
- Building with Docker - RECOMMENDED
- Building with command line — local builds)
Table of Contents
- Required Software
- Optional Software
- Installing software using Homebrew
- Installing software using SDKMAN!
- 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).
- Homebrew
- SDKMAN!
- Visual Studio Code
- IntelliJ Community Edition
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 first and then use brew to install SBT
-
Run the following command in a terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Then either in your
.zshrcor.zprofilefile paste the following# Set PATH, MANPATH, etc., for Homebrew. eval "$(/opt/homebrew/bin/brew shellenv)"
-
Then simply install SBT as documented here
brew install sbt
-
You will also need to install Scala, Coursier, Java, Maven, and Docker
brew install --cask docker
brew install scala maven openjdk@21 coursier
-
If you had another JDK installed, you may need to link the java 21 JDK
brew unlink openjdk
brew link --force openjdk@21
-
Add to your
.bash_profileto ensure maven finds the correct version of javaexport 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.
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.
Most of the project dependencies can be installed using SDKMAN!, 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:
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:
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 javawill show you available OpenJDK builds).sdk install java
sdk install sbt
sdk install scala
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 steps:
-
On Apple Silicon (M1, M2, ...):
$ curl -fL https://github.com/VirtusLab/coursier-m1/releases/latest/download/cs-aarch64-apple-darwin.gz | gzip -d > "$HOME/.local/bin/cs"
-
Otherwise:
curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-apple-darwin.gz | gzip -d > "$HOME/.local/bin/cs"
-
Then
chmod +x cs
./cs setup
You'll want to make sure that
csis available on your$PATH.
-
- Either consult the Homebrew instructions above, or follow their official CLI installation steps:
-
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.
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.
- Clone this repo
-
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.bashrcfile). Note that you will need to edit most variables.export MEF_REPO=~ export INSTALL_MEF=0 export LOCAL_WRAPPING_KEY="9mteZFY+gIVfMFywgvpLpyVl+8UIcNoIWpGaHX4jDFU=" export MEF_SOFTWARE_ID="[mef-software-id]" export MEF_SOFTWARE_VERSION_NUM="2023.0.1" export STATUS_ASID="[status-asid]" export STATUS_EFIN="[status-efin]" export STATUS_ETIN="[status-etin]" export SUBMIT_ASID=$STATUS_ASID export SUBMIT_EFIN=$STATUS_EFIN export SUBMIT_ETIN=$STATUS_ETIN export DF_TIN_VALIDATION_ENABLED=false export DF_EMAIL_VALIDATION_ENABLED=false export STATUS_KEYSTOREALIAS="[keystore-alias]" export STATUS_KEYSTOREBASE64="[base64-encoded-keystore]" export STATUS_KEYSTOREPASSWORD="[keystore-password]" export SUBMIT_KEYSTORE_KEYSTOREALIAS=$STATUS_KEYSTOREALIAS export SUBMIT_KEYSTORE_KEYSTOREBASE64=$STATUS_KEYSTOREBASE64 export SUBMIT_KEYSTORE_KEYSTOREPASSWORD=$STATUS_KEYSTOREPASSWORD export SUBMIT_ID_VAR_CHARS="zz" export GIT_COMMIT_HASH="$(cd /path/to/direct-file && git rev-parse --short main)"
-
From the root directory of this repo, run the following command to generate a value for LOCAL_WRAPPING_KEY:
./direct-file/scripts/local-setup.sh
-
Re-load your environment so that the new
LOCAL_WRAPPING_KEYvalue is loaded. If you set the values in one of your shell dotfiles (e.g..zshrc), open a new terminal.
-
To work with the Direct File docker setup, change into the
direct-filesubdirectory of this repo.cd direct-file/
-
Run the following command to build and start the default services and containers:
docker compose up -d --build
-
You should see the following (among other) containers start up:
- direct-file-app — df-client |
df-client - direct-file-db
- state-api-db
- direct-file-csp-simulator — csp-simulator |
/utils/csp-simulator - localstack
- direct-file-api — api |
/backend - state-api — state-api |
/state-api - direct-file-email-service — email-service |
/email-service - redis
- direct-file-app — df-client |
-
- If you get a build error with the
docker composecommand, you can try a few things.-
If the error is related to running out of memory, you may need to increase the amount of memory you've allocated to docker to 16 GB.
-
Otherwise, you can try building without cache:
docker compose build --no-cache
and then re-run the previous command:
docker compose up -d
-
That's it!
Some quick links:
- API documentation for the backend app can be viewed at http://localhost:8080/df/file/api/swagger-ui/index.html
- To access Direct File through the CSP simulator in browser, go to http://localhost:5000/ and use any email and select
IAL2to login
Note: Direct File shell scripts use Maven Wrapper; therefore they need to be executed from a working directory where it is present
-
Navigate to the
direct-file/libsdirectory which has the Maven Wrapper.cd direct-file/libs -
Run the
build-dependencies.shto build and install Direct File shared dependencies.INSTALL_MEF=1 ../scripts/build-dependencies.sh
Use Docker to build database containers and AWS mock services (referred to as "localstack")
```sh
docker compose up -d db mef-apps-db localstack
```
The command below will display all running containers and can be used to validate the above command was successful
```shell
docker ps
```
If successful, you should see three images running: localstack, direct-file-mef-apps-db, and direct-file-db.
Spring Boot projects
- backend
- email-services
- state-api
- status
- submit
Navigate to a <project> directory and use the Spring Boot Maven plugin to build and run.
./mvnw spring-boot:run -Dspring-boot.run.profiles=development# make sure the docker container for state-api is down as the following commands use the same localhost port
docker compose down state-api
# will start up the application using the blackhole profile
./mvnw spring-boot:run -Dspring-boot.run.profiles=development
# prints a log message to the console instead of attempting to send an email
./mvnw spring-boot:run -Dspring-boot.run.profiles=blackhole
# will attempt
./mvnw spring-boot:run -Dspring-boot.run.profiles=send-emailNeed to run/develop the client app? Check out the df-client/README for info on getting your local environment setup.
Each application has its own set of tests. To run server-side tests within an app, navigate to the root of the app. Run:
cd direct-file/<project>
./mvnw testTo run a test individually, run ./mvnw -Dtest=<Name of Test> test with the test name. For example:
./mvnw -Dtest=TaxReturnServiceTest testNOTE - add the -X flag to any maven command to switch on debug logging
./mvnw spring-boot:run -Dspring-boot.run.profiles=development -X
./mvnw -Dtest=TaxReturnServiceTest test -XWe use a plugin called Jacoco Maven to run code coverage. To run code coverage in any particular app:
./mvnw jacoco:reportTo view the generated report, go to <app_name>/target/site/jacoco/index.html and open it in a browser.