2022-10-13 09:48:09 -06:00
> This doc is a WIP and will be expanded shortly.
>
> In the meantime, please consider looking at the extensive docs in the [Fasten Docs Repository](https://github.com/fastenhealth/docs/tree/main/technical)
2022-10-15 14:33:38 -06:00
# Tech Stack
2022-08-22 18:51:46 -06:00
2022-10-15 14:33:38 -06:00
Fasten is made up of a handful of different components. Here's a summary of the technologies & languages used in Fasten:
**Frontend**
- NodeJS `v18.9.0`
- Yarn `1.22.19`
- Angular `v14.1.3`
**Backend**
- Go `v1.18.3`
- CouchDB `v3.2`
**Misc**
- Docker `v20.10.17`
## Setup
If you're on a Mac, you can run the following commands to install the necessary software to get setup:
```bash
brew install node
npm install -g @angular/cli@14 .1.3
brew install go
brew install docker
2022-08-22 18:51:46 -06:00
```
2022-10-15 14:33:38 -06:00
# Running Tests
Before making changes to Fasten, you'll want to run the test suites to ensure that your environment is setup correctly:
```bash
make test
# if you only want to run the frontend tests (Angular), you can run:
make frontend-test
# alternatively, if you only care about backend (Go) tests, you can run:
make backend-test
```
# Start Development Environment
To run Fasten from source, you'll need to create 3 separate processes:
- Angular Frontend
- Go Backend
- CouchDB Database
First we'll create a development config file (`config.dev.yaml`)
```yaml
version: 1
web:
listen:
port: 9090
host: 0.0.0.0
basepath: ''
src:
frontend:
path: ./dist
log:
file: '' #absolute or relative paths allowed, eg. web.log
level: INFO
```
Next we'll start the processes described above:
```bash
# In terminal #1, run the following
2022-08-22 19:28:59 -06:00
cd frontend
2022-08-22 18:51:46 -06:00
npm run dist
2022-10-15 14:33:38 -06:00
# In terminal #2, run the following
2022-08-22 18:51:46 -06:00
go mod vendor
2022-10-15 14:33:38 -06:00
go run backend/cmd/fasten/fasten.go start --config ./config.dev.yaml --debug
2022-10-09 13:30:26 -06:00
2022-10-15 14:33:38 -06:00
# In terminal #3, run the following
2022-10-09 13:30:26 -06:00
docker build -t fasten-couchdb -f docker/couchdb/Dockerfile .
2022-10-12 09:53:24 -06:00
docker run --rm -it -p 5984:5984 -v `pwd` /.couchdb/data:/opt/couchdb/data -v `pwd` /.couchdb/config:/opt/couchdb/etc/local.d fasten-couchdb
2022-09-21 22:08:21 -06:00
```
2022-10-09 13:30:26 -06:00
2022-10-15 14:33:38 -06:00
Now you can open a browser to `http://localhost:9090` to see the Fasten UI.
## Important URL's
The following URL's and credentials may be helpful as you're developing
2022-10-09 13:30:26 -06:00
- http://localhost:9090/web/dashboard - WebUI
2022-10-15 14:33:38 -06:00
- http://localhost:9090/database - CouchDB API proxy
2022-10-09 13:30:26 -06:00
- http://localhost:5984/_utils/ - CouchDB admin UI
2022-10-15 14:33:38 -06:00
### Credentials
2022-10-09 13:30:26 -06:00
- Couchdb:
- username: `admin`
- password: `mysecretpassword`
- WebUI:
- username: `testuser`
- password: `testuser`
2022-10-12 19:47:12 -06:00
2022-10-15 14:33:38 -06:00
# Source Code Folder Structure
The Fasten source code is organized into a handful of important folders, which we'll describe below:
## Frontend
```tree
├── frontend
│ ├── src
│ │ ├── app
│ │ │ ├── app-routing.module.ts
│ │ │ ├── app.component.html
│ │ │ ├── app.component.scss
│ │ │ ├── app.component.spec.ts
│ │ │ ├── app.component.ts
│ │ │ ├── app.module.ts
│ │ │ ├── components # contains shared/partial components reused on multiple pages.
│ │ │ │ ├── components-sidebar
│ │ │ │ ├── footer
│ │ │ │ ├── header
│ │ │ │ ├── list-fallback-resource
│ │ │ │ ├── list-generic-resource # A component containing a table view for every FHIR resource
│ │ │ │ ├── list-patient
│ │ │ │ ├── resource-list # Thin shim which populates template depending on FHIR resource type
│ │ │ │ ├── toast # Toast/notification component
│ │ │ │ └── utilities-sidebar
│ │ │ ├── models # contains classes for communicating with API's and transfering data between pages.
│ │ │ ├── pages
│ │ │ │ ├── auth-signin # Login/Signin page
│ │ │ │ ├── auth-signup # Signup page
│ │ │ │ ├── dashboard # Dashboard, visible after logging in
│ │ │ │ ├── medical-sources # Medical Provider connection page
│ │ │ │ ├── patient
│ │ │ │ ├── resource-detail # Page displaying detailed information about FHIR resource
│ │ │ │ └── source-detail # 2 column page displaying FHIR counts, and table listing FHIR resources for selected type
│ │ │ ├── services
│ │ │ │ ├── auth-interceptor.service.ts # service that looks for 401/403 API responses and triggers Logout
│ │ │ │ ├── can-activate.auth-guard.ts # service that checks if user is logged in
│ │ │ │ ├── fasten-api.service.ts # api service, used to commnunicate with Go backend (WILL BE REMOVED)
│ │ │ │ ├── fasten-db.service.ts # db service, used to communicate with CouchDB database
│ │ │ │ ├── lighthouse.service.ts # api service, used to communicate with auth-gateway (Lighthouse)
│ │ │ │ └── toast.service.ts # notifications service, used to send notifications
│ │ │ └── workers
│ │ │ ├── queue.service.spec.ts
│ │ │ ├── queue.service.ts # queue service, used to coordinate background work
│ │ │ └── source-sync.worker.ts # background job (web-worker) that syncs all FHIR resources from healthcare provider
│ │ ├── lib # root directory for libraries
│ │ │ ├── README.md
│ │ │ ├── conduit # Conduit Library - HealthCare provider communication layer (FHIR protocol)
2022-10-15 14:51:28 -06:00
│ │ │ │ ├── fhir # contains healthcare provider specific FHIR clients
│ │ │ ├── database # Database Library - PouchDB/CouchDB client, compatible with web-worker and browser env
2022-10-15 14:33:38 -06:00
│ │ │ │ ├── plugins
2022-10-15 14:51:28 -06:00
│ │ │ │ └── pouchdb_repository.ts
2022-10-15 14:33:38 -06:00
│ │ │ ├── models
2022-10-15 14:51:28 -06:00
│ │ │ │ ├── database # Classes used to store data in CouchDB
│ │ │ │ ├── fasten
│ │ │ │ └── lighthouse # Classes used to communicate with Lighthouse API
2022-10-15 14:33:38 -06:00
│ │ │ └── utils
2022-10-15 14:51:28 -06:00
│ │ ├── styles.scss # Main sylesheet
2022-10-15 14:33:38 -06:00
```
## Backend
2022-10-15 14:51:28 -06:00
The backend is incredibly simple (by design). The hope is to remove it completely if possible, allowing Fasten to be served by
a CDN or minimal Nginx deployment.
```
├── backend
│ ├── cmd
│ └── pkg
│ ├── config
│ ├── database # contains CouchDB client, allowing creation of new Users (and associated databases)
│ ├── errors
│ ├── models
│ └── web
│ ├── handler # contains code for API endpoints
│ │ ├── auth.go # authentication endpoints (create new user)
│ │ ├── cors_proxy.go # CORS proxy/relay for communicating with healthcare providers who do not support CORS
│ │ ├── couchdb_proxy.go # reverse proxy for CouchDB api, allowing for database API to be exposed (with limitations)
│ │ └── metadata.go # API endpoint returning metadata for healthcare providers
```
2022-10-15 14:33:38 -06:00
## Distribution/Docker
2022-10-15 14:51:28 -06:00
```
2022-10-15 14:54:13 -06:00
├── docker-compose.yml # docker-compose file which can be used to compile and run "all-in-one" image
├── Dockerfile # dockerfile for "all-in-one" image, containing frontend, backend & database
2022-10-15 14:51:28 -06:00
├── docker
│ ├── README.md
│ ├── couchdb
│ │ ├── Dockerfile # dockerfile for "couchdb" only image, used for development
│ │ └── local.ini
2022-10-15 14:54:13 -06:00
│ └── rootfs # filesystem configs, used in Dockerfiles to setup s6-overlay service manager
2022-10-15 14:51:28 -06:00
│ └── etc
│ ├── cont-init.d
│ │ ├── 01-timezone
│ │ └── 50-couchdb-init
│ └── services.d
│ ├── couchdb
│ └── fasten
```
2022-10-15 14:33:38 -06:00
2022-10-15 14:51:28 -06:00
# FAQ
2022-10-12 19:47:12 -06:00
2022-10-15 14:51:28 -06:00
### How do I run individual frontend tests?
2022-10-12 19:47:12 -06:00
- ng test --include='**/base_client.spec.ts'
- ng test --include='lib/**/*.spec.ts'