ohif-viewer/docs/latest/advanced/architecture.md

110 lines
4.2 KiB
Markdown
Raw Normal View History

2019-04-24 21:41:23 +02:00
# Architecture
2019-05-10 15:51:41 +02:00
Looking to extend your instance of the OHIF Viewer? Want learn how to reuse _a
portion_ of the Viewer in your own application? Or maybe you want to get
involved and draft or suggest a new feature? Regardless, you're in the right
place!
2019-04-25 05:54:26 +02:00
2019-05-10 15:51:41 +02:00
The OHIF Viewer aims to be decoupled, configurable, and extensible; while this
allows our code to be used in more ways, it also increases complexity. Below, we
aim to demistify that complexity by providing insight into how our Viewer is
architected, and the role each of it's dependent libraries plays.
2019-04-25 05:54:26 +02:00
2019-04-25 04:30:18 +02:00
## Overview
2019-07-15 21:56:07 +02:00
The [`OHIF/Viewers`][viewers-project] project contains the source code for the
OHIF Medical Imaging Viewer. It is effectively a React [progressive web
app][pwa] (PWA) that combines the business logic housed in
[`OHIF/ohif-core`][core] and the components in our React Component library
[`OHIF/react-viewerbase`][component-library]. It provides customization for
common use cases through [configuration][configuration] and for adding
functionality via [extensions][extensions].
2019-04-25 04:30:35 +02:00
### Business Logic
2019-05-10 15:51:41 +02:00
Our goal is to maintain the majority of our business logic in
[`OHIF/ohif-core`](https://github.com/OHIF/ohif-core). `ohif-core` offers
pre-packaged solutions for features common to Web-based medical imaging viewers.
For example:
2019-04-25 04:30:35 +02:00
- Hotkeys
- DICOM Web
- Hanging Protocols
- Managing a study's measurements
- Managing a study's DICOM metadata
- A flexible pattern for extensions
- [And many others](https://github.com/OHIF/ohif-core/blob/master/src/index.js#L49-L69)
It does this while remaining decoupled from any particular view library or
2019-05-10 15:51:41 +02:00
rendering logic. While we use it to power our React Viewer, it can be used with
Vue, React, Vanilla JS, or any number of other frameworks.
2019-04-25 05:39:45 +02:00
### React Component Library
2019-05-10 15:51:41 +02:00
[`OHIF/react-viewerbase`](https://github.com/OHIF/react-viewerbase) is a React
Component library that contains the reusable components that power the OHIF
Viewer. It allows us to build, compose, and test components in isolation; easing
the development process by reducing the need to stand-up a local PACS with test
case data.
2019-04-25 05:39:45 +02:00
[Check out our component library!](https://react.ohif.org/)
2019-04-25 05:16:24 +02:00
### Misc. Extensions
2019-05-10 15:51:41 +02:00
Want to add custom logic or UI Components to the OHIF Viewer, but don't want to
maintain a fork? We expose common integration points via
[extensions](./extensions.md) to make that possible. For a list of extensions
maintained by OHIF,
[check out this helpful table](./extensions.html#ohif-maintained-extensions).
2019-04-25 05:16:24 +02:00
2019-05-10 15:51:41 +02:00
If you find yourself thinking "I wish the Viewer could do X", and you can't
accomplish it with an extension today, create a GitHub issue! We're actively
looking for ways to improve our extensibility ^\_^
2019-04-25 05:16:24 +02:00
[Click here to read more about extensions!](./extensions.md)
2019-04-25 05:25:43 +02:00
### Diagram
2019-05-10 15:51:41 +02:00
This diagram is a conceptual illustration of how the Viewer is architected.
2019-04-25 05:25:43 +02:00
2019-07-15 21:56:07 +02:00
1. (optional) `extensions` can be registered with `ohif-core`'s extension
2019-05-10 15:51:41 +02:00
manager
2019-07-15 21:56:07 +02:00
2. `ohif-core` provides bussiness logic and a way for `viewer` to access
2019-05-10 15:51:41 +02:00
registered extensions
2019-07-15 21:56:07 +02:00
3. The `viewer` composes and provides data to components from our component
2019-05-10 15:51:41 +02:00
library (`react-viewerbase`)
2019-07-15 21:56:07 +02:00
4. The `viewer` can be built and served as a stand-alone PWA, or as an
2019-05-10 15:51:41 +02:00
embeddable package
([`ohif-viewer`](https://www.npmjs.com/package/ohif-viewer))
2019-04-25 05:25:43 +02:00
2019-04-24 21:41:23 +02:00
![Architecture Diagram](../assets/img/architecture-diagram.png)
2019-04-25 05:16:14 +02:00
<center><i>architecture diagram</i></center>
## Common Questions
2019-05-10 15:51:41 +02:00
> When should I use the packaged source `ohif-viewer` versus building a PWA from
> the source?
2019-04-25 05:39:56 +02:00
...
2019-04-25 05:16:14 +02:00
> Can I create my own Viewer using Vue.js or Angular.js?
2019-05-10 15:51:41 +02:00
You can, but you will not be able to leverage as much of the existing code and
components. `ohif-core` could still be used for business logic, and to provide a
model for extensions. `react-viewerbase` would then become a guide for the
components you would need to recreate.
2019-07-15 21:50:47 +02:00
<!--
Links
-->
<!-- prettier-ignore-start -->
2019-07-15 21:56:07 +02:00
[viewers-project]: https://github.com/OHIF/Viewers
[pwa]: https://developers.google.com/web/progressive-web-apps/
[core]: https://github.com/OHIF/ohif-core
[component-library]: https://github.com/OHIF/react-viewerbase
[configuration]: ../essentials/configuration.md
[extensions]: ./extensions.m
2019-07-15 21:50:47 +02:00
<!-- prettier-ignore-end -->