Skip to content

Commit

Permalink
Initial Version
Browse files Browse the repository at this point in the history
  • Loading branch information
lguild-plaid committed May 28, 2019
1 parent 078266d commit 291babf
Show file tree
Hide file tree
Showing 92 changed files with 23,592 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[Makefile]
indent_style = tab

[*.md]
indent_size = 4
12 changes: 12 additions & 0 deletions .env.template
@@ -0,0 +1,12 @@
# Your Plaid keys, which can be found in the Plaid Dashboard.
# https://dashboard.plaid.com/account/keys

PLAID_CLIENT_ID=
PLAID_PUBLIC_KEY=
PLAID_SECRET_DEVELOPMENT=
PLAID_SECRET_SANDBOX=

# The Plaid environment to use ('sandbox' or 'development').
# https://plaid.com/docs/#api-host

PLAID_ENV=sandbox
62 changes: 62 additions & 0 deletions .gitignore
@@ -0,0 +1,62 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
database/last-cleared.dummy

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
19 changes: 19 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Docker: Attach to Server",
"type": "node",
"request": "attach",
"localRoot": "${workspaceFolder}/server",
"remoteRoot": "/opt/server",
"address": "localhost",
"port": 9229,
"protocol": "inspector",
"restart": true,
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2019 Plaid Technologies, Inc. <support@plaid.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
77 changes: 77 additions & 0 deletions Makefile
@@ -0,0 +1,77 @@
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
envfile := ./.env
clear_db_after_schema_change := database/last-cleared.dummy
db_schema := database/init/*

.PHONY: help start start-no-webhooks debug sql logs stop clear-db

# help target adapted from https://gist.github.com/prwhite/8168133#gistcomment-2278355
TARGET_MAX_CHAR_NUM=20

## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' make <target>'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " %-$(TARGET_MAX_CHAR_NUM)s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)

## Start the services
start: $(envfile) $(clear_db_after_schema_change)
@echo "Pulling images from Docker Hub (this may take a few minutes)"
docker-compose pull
@echo "Starting Docker services"
docker-compose up --detach
./wait-for-client.sh

## Start the services without webhooks
start-no-webhooks: $(envfile) $(clear_db_after_schema_change)
@echo "Pulling images from Docker Hub (this may take a few minutes)"
docker-compose pull
@echo "Starting Docker services"
docker-compose up --detach client
./wait-for-client.sh

## Start the services in debug mode
debug: $(envfile) $(clear_db_after_schema_change)
@echo "Starting services (this may take a few minutes if there are any changes)"
docker-compose -f docker-compose.yml -f docker-compose.debug.yml up --build --detach
./wait-for-client.sh

## Start an interactive psql session (services must running)
sql:
docker-compose exec db psql -U postgres

## Show the service logs (services must be running)
logs:
docker-compose logs --follow

## Stop the services
stop:
docker-compose down
docker volume rm $(current_dir)_client_node_modules || true
docker volume rm $(current_dir)_server_node_modules || true

## Clear the sandbox and development databases
clear-db: stop
docker volume rm $(current_dir)_pg_sandbox_data || true
docker volume rm $(current_dir)_pg_development_data || true

$(envfile):
@echo "Error: .env file does not exist! See the README for instructions."
@exit 1

# Remove local DBs if the DB schema has changed
$(clear_db_after_schema_change): $(db_schema)
@$(MAKE) clear-db
@touch $(clear_db_after_schema_change)
72 changes: 71 additions & 1 deletion README.md
@@ -1 +1,71 @@
# pattern
# Plaid Pattern

![Plaid Pattern client][client-img]

This is a reference application demonstrating an end-to-end [Plaid][plaid] integration, focused on linking items and fetching transaction data.

**This is not meant to be run as a production application.**

## Requirements

- [Docker][docker] Version 2.0.0.3 (31259) or higher, installed and running
- [Plaid API keys][plaid-keys] - [sign up][plaid-signup] for a free Sandbox account if you don't already have one

## Getting Started

1. Clone the repo.
```shell
git clone https://github.plaid.com/plaid/open-pfm.git
cd open-pfm
```
1. Create the `.env` file.
```shell
cp .env.template .env
```
1. Update the `.env` file with your [Plaid API keys][plaid-keys].
1. Start the services. The first run may take a few minutes as Docker images are pulled/built for the first time.
```shell
make start
```
1. Open http://localhost:3000 in a web browser.
1. When you're finished, stop the services.
```shell
make stop
```

## Additional Commands

All available commands can be seen by calling `make help`.

## Architecture

For more information about the individual services, see the readmes for the [client][client-readme], [database][database-readme], and [server][server-readme].

## Troubleshooting

See [`docs/troubleshooting.md`][troubleshooting].

## Additional Resources

- For an overview of the Plaid platform and products, refer to this [Quickstart guide][plaid-quickstart].
- Check out this high-level [introduction to Plaid Link](https://blog.plaid.com/plaid-link/).
- Find comprehensive information on Plaid API endpoints in the [API documentation][plaid-docs].
- Questions? Please head to the [Help Center][plaid-help] or [open a Support ticket][plaid-support-ticket].

## License

[MIT](LICENSE)

[client-img]: docs/pattern_screenshot.png
[client-readme]: client/README.md
[database-readme]: database/README.md
[docker]: https://www.docker.com/products/docker-desktop
[plaid]: https://plaid.com
[plaid-docs]: https://plaid.com/docs/
[plaid-help]: https://support.plaid.com/hc/en-us
[plaid-keys]: https://dashboard.plaid.com/account/keys
[plaid-quickstart]: https://plaid.com/docs/quickstart/
[plaid-signup]: https://dashboard.plaid.com/signup
[plaid-support-ticket]: https://dashboard.plaid.com/support/new
[server-readme]: server/README.md
[troubleshooting]: docs/troubleshooting.md
16 changes: 16 additions & 0 deletions client/.dockerignore
@@ -0,0 +1,16 @@
# node
node_modules
npm-debug.log

# docker
Dockerfile*
docker-compose*
.dockerignore

# other
.DS_Store
.env
.eslintrc*
.gitignore
.prettierrc*
README.md
7 changes: 7 additions & 0 deletions client/.eslintrc
@@ -0,0 +1,7 @@
{
"extends": "react-app",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
23 changes: 23 additions & 0 deletions client/.gitignore
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
9 changes: 9 additions & 0 deletions client/.prettierrc.json
@@ -0,0 +1,9 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid"
}
13 changes: 13 additions & 0 deletions client/Dockerfile
@@ -0,0 +1,13 @@
FROM node:10.15.3-alpine

COPY ["package.json", "/opt/client/"]
COPY ["package-lock.json", "/opt/client/"]

WORKDIR /opt/client

RUN npm ci

COPY ["src/", "/opt/client/src/"]
COPY ["public/", "/opt/client/public/"]

CMD ["npm", "start"]
8 changes: 8 additions & 0 deletions client/README.md
@@ -0,0 +1,8 @@
# Plaid Pattern - Client

The client-side code demonstrates a [Plaid Link](https://plaid.com/docs/#integrating-with-link) integration. It is written using [React](https://reactjs.org/) (bootstrapped with [Create React App](https://github.com/facebook/create-react-app)). The app runs on port 3000 by default, although you can modify this in [docker-compose.yml](../docker-compose.yml).

## Learn More

- [React documentation](https://reactjs.org/)
- [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started)

0 comments on commit 291babf

Please sign in to comment.