# @trinityresearch/app

> Build new apps quickly

Latest version **0.1.4** (published 2022-06-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install @trinityresearch/app
pnpm add @trinityresearch/app
yarn add @trinityresearch/app
bun add @trinityresearch/app
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2022-06-01 |
| First published | 2022-06-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 20 |
| Unpacked size | 367.8 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | dennismjefferson@gmail.com |
| Maintainers | cpu0101 |
| Keywords | typescripts, react, next.js, graphql, fullstack, application, development, boilerplate |

## Links

- npm: https://www.npmjs.com/package/@trinityresearch/app
- Repository: https://github.com/djfrsn/trinity-app
- Homepage: https://github.com/djfrsn/trinity-app#readme
- Issues: https://github.com/djfrsn/trinity-app/issues
- npm.io page: https://npm.io/package/@trinityresearch/app

## Dependencies (20)

- [color](https://npm.io/package/color.md) ^4.2.3
- [micro](https://npm.io/package/micro.md) 9.3.4
- [nexus](https://npm.io/package/nexus.md) 1.3.0
- [express](https://npm.io/package/express.md) 4.18.1
- [graphql](https://npm.io/package/graphql.md) 15.8.0
- [classnames](https://npm.io/package/classnames.md) ^2.3.1
- [micro-cors](https://npm.io/package/micro-cors.md) 0.1.1
- [graphql-tag](https://npm.io/package/graphql-tag.md) 2.12.6
- [react-icons](https://npm.io/package/react-icons.md) ^4.3.1
- [@apollo/client](https://npm.io/package/@apollo/client.md) 3.6.4
- [@prisma/client](https://npm.io/package/@prisma/client.md) 3.14.0
- [react-markdown](https://npm.io/package/react-markdown.md) ^8.0.2
- [@prismicio/next](https://npm.io/package/@prismicio/next.md) ^0.1.2
- [graphql-scalars](https://npm.io/package/graphql-scalars.md) 1.17.0
- [is-absolute-url](https://npm.io/package/is-absolute-url.md) ^4.0.1
- [@prismicio/react](https://npm.io/package/@prismicio/react.md) ^2.3.0
- [@prismicio/client](https://npm.io/package/@prismicio/client.md) ^6.4.3
- [@prismicio/helpers](https://npm.io/package/@prismicio/helpers.md) ^2.3.0
- [apollo-server-micro](https://npm.io/package/apollo-server-micro.md) 3.7.0
- [@prismicio/slice-simulator-react](https://npm.io/package/@prismicio/slice-simulator-react.md) ^0.2.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2022-06-01
- 0.1.3 — 2022-06-01

## README

# Trinity Research Application

This repo contains an implementation of a **fullstack web application** designed to author and display research content. The underlying code is a general purpose library and architecture reference for creating new modern web applications. The core techonologies are **programming language - [TypeScript](https://www.typescriptlang.org/), web framework - [Next.js](https://nextjs.org/), UI library - [React](https://reactjs.org/), CSS framework - [TailwindCSS](https://tailwindcss.com/) and State management - [Apollo Client](https://www.apollographql.com/docs/react/)**. The application interfaces with a **backend built using a [GraphQL](https://graphql.org/) server, via Schema and Resolvers - [Nexus Schema](https://nxs.li/components/standalone/schema), a Database client - [Prisma Client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client) and data stored in [SQLite](https://www.sqlite.org/index.html)**.

## Getting started

### 1. Clone repo and install dependencies

Clone this repository:

```
git clone git@github.com:djfrsn/trinity-lib.git --depth=1
```

Install npm dependencies:

```
cd trinity-lib
npm install
```

<details><summary><strong>Alternative:</strong> Install package and import code</summary>

Run NPM install lib:

```
npm i @trinityresearch/lib
```

Import code via JS/TS/Node:

```
import parseUrl from '@trinityresearch/lib'
```

</details>

<br />

### 2. Generate database client/types and seed data

Run this command to setup the database:

```
npm run setup
```

The above runs commands for the following:

<details><summary><strong>a.</strong> Generate the database client and type files</summary>

The following command to create your Prisma client and Nexus type files. The Prisma client creates an interface to the DB and Nexus provides the schema, this mostly happens in [`/pages/api`](./pages/api). The frontend depends on the Apollo server to allow us to access the generated client via GraphQL. To generate the files, we run the generate:prisma and generate:nexus with the following:

```
npm run generate
```

</details>

<br />

<details><summary><strong>b.</strong> Create and seed the database</summary>

The following command to create your SQLite database file. This also creates the `User` and `Post` tables that are defined in [`prisma/schema.prisma`](./prisma/schema.prisma):

Create your SQLite database file by running the following command. The `User` and `Post` tables defined in [`prisma/schema.prisma`](./prisma/schema.prisma) will be created.

```
npm run migrate:prisma
```

The data from the seed file [`prisma/seed.ts`](./prisma/seed.ts) will be used to populate the database with mock data.

</details>

<br />

### 3. Run the app

```
npm run dev
```

Visit [`http://localhost:3000/`](http://localhost:3000/) in your browser to see the app running.

<br />

## Modify the application

The application defaults to displaying a UI with db seed data and example Prismic CMS data for this repo. You can add applications features via [Prisma Schema](https://github.com/prisma/prisma-examples/blob/latest/typescript/graphql-nextjs/README.md#evolving-the-app) or add new UI by replacing the `apiEndpoint` in [`sm.json`](./sm.json) with a new [Prismic Repository](https://prismic.io/docs/core-concepts/repository), then create new [template slices](https://prismic.io/docs/technologies/template-content-nextjs).

<br />

Modifying the application usually means one of the following will happen:

- Create a new repeatable page section with React and the Slice Machine
- Add new React components for feature update
- Author new pages without code via Prismic UI
- Update schema and server [`API`](./pages/api) to support feature update

<br />

### Create a new Slice

A reusable section of a page, in the form of a slice allows us to create building blocks to form pages.

**Run Slice Machine**

```
npm run slicemachine
```

- Create a new [slice](https://prismic.io/docs/technologies/model-content-nextjs#create-your-first-slice) or [content-type](https://prismic.io/docs/technologies/model-content-nextjs#create-your-first-custom-type) via the [Slice Machine](http://localhost:9999) on localhost.

**Reference the patterns established** in [UtilBarTitle.tsx](./slices/UtilBarTitle) for slices. The slice should contain code that makes for a unique component and import resuable code. Reference the [/create](<(./pages/create.tsx)>) page when creating new content-types.

<br />

### Create a new Page with Prismic

New pages can be created without code on Prismic using the "Page" content type and existing app sections with unique content. If a new [static zone](https://prismic.io/concepts/content-modeling/introduction-to-content-modeling#static-fields) is required the content type "Create" along with the [associated React UI](./pages/create.tsx) establishes this pattern.

- Create a new Prismic document with a content type of "Page", the field `uid` will be the path for the page and render using the [[uid].tsx](./pages/[uid].tsx) file. Title and description are used in the HTML `head`.

<br />

### Create a new React component

Components are any reusable UI code found in [`/pages`](./pages) or [`/slices`](./slices).

- Add new components in the dir [./components](./components/) and export them in [`./index.ts`](./index.ts) to allow for use as an npm package.

<br />

### Add server side api code

Adding a new row or column is done by changing or adding Models in [schema.prisma](./prisma/schema.prisma). Fetching this data requires an update to object type resolvers in [/pages/api](./pages/api/). Once this is done, the change in backend data can be used in the front end GraphQL queries and components.

- Follow the 4 step process for doing so is laid out in the **Evolving the app** section of the official [Prisma Next.js example](https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql-nextjs#evolving-the-app).

<br />

## References

### General

- [Official Prisma Next.js/GraphQL example](https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql-nextjs)
- [Prismic.io Next.js Documentation](https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql-nextjs)
- [Prismic Content Modeling](https://prismic.io/concepts/content-modeling)
- [Prismic Helpers](https://prismic.io/docs/technical-reference/prismicio-helpers)
- [Prismic Client](https://prismic.io/docs/technical-reference/prismicio-client)

### Frontend

- [Next.js](https://nextjs.org/)
- [React](https://reactjs.org/)
- [TailwindCSS](https://tailwindcss.com/)
- [Apollo Client](https://www.apollographql.com/docs/react/)
- [Prismic Templating](https://prismic.io/docs/technologies/template-content-nextjs#intro-to-templating)

### Backend

- [GraphQL](https://graphql.org/graphql-js/)
- [Nexus Schema](https://nxs.li/components/standalone/schema)
- [Prisma Client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client)
- [Prismic/Next](https://prismic.io/docs/technical-reference/prismicio-next)
- [SQLite](https://www.sqlitetutorial.net/)

---
_Source: https://npm.io/package/@trinityresearch/app · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
