Skip to content

Commit b8596c2

Browse files
committed
Merge branch 'main' of github.com:graphprotocol/hypergraph into chris.whited/feat-typesync-pkg/mapping-generation
2 parents 4159167 + 0045798 commit b8596c2

File tree

343 files changed

+30507
-8992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+30507
-8992
lines changed

.DS_Store

-8 KB
Binary file not shown.

.github/workflows/fly-deploy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
2+
3+
name: Fly Deploy (Paused)
4+
on:
5+
push:
6+
branches:
7+
- main
8+
jobs:
9+
deploy:
10+
name: Deploy app
11+
runs-on: ubuntu-latest
12+
concurrency: deploy-group # optional: ensure only one action runs at a time
13+
steps:
14+
- uses: actions/checkout@v4
15+
# - uses: superfly/flyctl-actions/setup-flyctl@master
16+
# - run: flyctl deploy --remote-only
17+
# env:
18+
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ typings/
6666

6767
# typescript
6868
*.tsbuildinfo
69-
next-env.d.ts
69+
next-env.d.ts
70+
71+
.DS_Store
72+
73+
# tanstack router output
74+
.tanstack

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

CONTRIBUTING.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Contributing
2+
3+
## Upgrading Dependencies
4+
5+
```sh
6+
pnpm up --interactive --latest -r
7+
```
8+
9+
## Publishing
10+
11+
```sh
12+
pnpm build
13+
# publish hypergraph
14+
cd packages/hypergraph/publish
15+
pnpm publish
16+
# publish hypergraph-react
17+
cd packages/hypergraph-react/publish
18+
pnpm publish
19+
# publish typesync
20+
cd apps/typesync
21+
pnpm publish --tag latest
22+
```
23+
24+
## Deploying your own SyncServer to Fly.io (single instance)
25+
26+
```sh
27+
# change the name of the `app` and `primary_region` in the fly.toml file
28+
29+
# create a volume for the sqlite db file - replace `fra` with your region
30+
fly volumes create data -s 1 -r fra
31+
32+
# set the DATABASE_URL (not sure if it's necessary since already set in the Dockerfile)
33+
fly secrets set DATABASE_URL=file:/data/production.sqlite
34+
# set the Privy app secret, id and chain (fill in your values)
35+
fly secrets set PRIVY_APP_SECRET=<PRIVY_APP_SECRET>
36+
fly secrets set PRIVY_APP_ID=<PRIVY_APP_ID>
37+
fly secrets set HYPERGRAPH_CHAIN=<HYPERGRAPH_CHAIN>
38+
39+
# deploy (ha=false to avoid starting multiple instances)
40+
fly launch --ha=false
41+
42+
# probably not necessary, but better safe than sorry
43+
fly scale count 1
44+
```
45+
46+
Resources:
47+
- https://fly.io/docs/js/prisma/sqlite/
48+
- https://programmingmylife.com/2023-11-06-using-sqlite-for-a-django-application-on-flyio.html
49+
- https://community.fly.io/t/backup-and-restore-sqlite-db-to-server/21232/2
50+
51+
### Multi-region deployments
52+
53+
As an alternative you might want to setup a lite-fs volume for multi-region deployments.
54+
55+
Resources:
56+
- https://github.com/epicweb-dev/node-sqlite-fly-tutorial/tree/main/steps
57+
- https://www.epicweb.dev/tutorials/deploy-web-applications/multi-region-data-and-deployment/prepare-for-multi-region-data-with-litefs
58+
- https://fly.io/docs/litefs/speedrun/

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ RUN --mount=type=cache,id=workspace,target=/root/.local/share/pnpm/store pnpm in
2424
# Build stage for the server.
2525
FROM base AS build
2626
# TODO: Remove this when we switch to an actual database.
27-
ENV DATABASE_URL="file:./dev.db"
27+
ENV DATABASE_URL="file:/data/production.sqlite"
2828
RUN \
2929
# TODO: This initalizes the database. But we should probably remove this later.
30-
pnpm --filter server prisma migrate reset --force && \
30+
# pnpm --filter server prisma migrate reset --force && \
3131
# Build the monorepo packages
3232
pnpm build && \
3333
# Generate the prisma client
@@ -37,13 +37,19 @@ RUN \
3737
# Create an isolated deployment for the server.
3838
pnpm --filter server deploy --prod deployment --legacy && \
3939
# Move the runtime build artifacts into a separate directory.
40-
mkdir -p deployment/out && mv deployment/dist deployment/prisma deployment/node_modules deployment/package.json deployment/out
40+
mkdir -p deployment/out && mv deployment/dist deployment/node_modules deployment/package.json deployment/out && \
41+
# Add prisma client in dist
42+
mv deployment/prisma/generated/client/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node deployment/out/dist/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node && \
43+
mv deployment/prisma/generated/client/libquery_engine-linux-musl-openssl-3.0.x.so.node deployment/out/dist/libquery_engine-linux-musl-openssl-3.0.x.so.node && \
44+
mv deployment/prisma deployment/out
4145

4246
# Slim runtime image.
4347
FROM node:22-alpine AS server
4448
WORKDIR /app
4549
COPY --from=build /workspace/deployment/out .
4650
# TODO: Remove this when we switch to an actual database.
47-
ENV DATABASE_URL="file:./dev.db"
51+
ENV DATABASE_URL="file:/data/production.sqlite"
52+
RUN npm run prisma migrate deploy --skip-generate
4853
EXPOSE 3030
49-
CMD ["node", "dist/index.js"]
54+
# can't use fly.io release_command because it doesn't mount the volume containing the sqlite db file
55+
CMD ["sh", "-c", "npm run prisma migrate deploy && node dist/index.js"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024-present Geo Browser, PB LLC and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
# Graph Framework
1+
# Hypergraph
2+
3+
Hypergraph is a local-first framework for building web3 consumer applications.
4+
5+
*Status: Developer Preview* Don't use in production!
6+
7+
Build privacy preserving apps with interoperable data using the GRC-20 standard. Read the [Docs](https://docs.hypergraph.thegraph.com/docs/core-concepts), and get started using the Geo Testnet.
8+
9+
* TypeSync - A development environment for creating and managing your app schemas
10+
* Geo Connect - An authentication app for granting your app permissions to user's private spaces
11+
* GRC-20 TS - A knowledge graph SDK for writing and publishing knowledge in the GRC-20 format
12+
* Hypergraph - A local-first framework for building web3 consumer applications
13+
* Hypergraph React - React bindings for Hypergraph
214

315
## Development
416

@@ -8,6 +20,7 @@
820
pnpm install
921
cd apps/server
1022
cp .env.example .env
23+
# add the PRIVY_APP_SECRET & PRIVY_APP_ID to the apps/server/.env file
1124
pnpm prisma migrate dev
1225
```
1326

@@ -30,7 +43,25 @@ cd apps/server
3043
pnpm prisma migrate dev # this will also generate the Prisma client
3144
```
3245

33-
You can run the next example app with:
46+
To develop the Typesync CLI, you can run:
47+
48+
```sh
49+
cd apps/typesync
50+
pnpm dev
51+
```
52+
53+
To develop the Typesync frontend run:
54+
55+
```sh
56+
# open the vite.config.ts and comment out the server object that specifies the port to be 3000
57+
cd apps/typesync
58+
pnpm run dev:cli
59+
# in another tab
60+
cd apps/typesync
61+
pnpm dev:client
62+
```
63+
64+
You can run the Next example app with:
3465

3566
```sh
3667
# Notes:
@@ -39,8 +70,9 @@ cd apps/next-example
3970
pnpm dev
4071
```
4172

42-
## Upgrading Dependencies
73+
To run the docs locally, you can run:
4374

4475
```sh
45-
pnpm up --interactive --latest -r
76+
cd docs
77+
pnpm start
4678
```

apps/connect/.env.development

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="http://localhost:3030"
2+
VITE_HYPERGRAPH_CHAIN="geo-testnet"
3+
VITE_HYPERGRAPH_API_URL="https://v2-postgraphile.up.railway.app/graphql"
4+
VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz"
5+
VITE_PRIVY_APP_ID="cmbhnmo1x000bla0mxudtd8z9"
6+
VITE_PRIVY_PROVIDERS="development"
7+
# VITE_HYPERGRAPH_CHAIN="geogenesis"
8+
# VITE_HYPERGRAPH_API_URL="https://hypergraph-v2.up.railway.app/graphql"
9+
# VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-genesis-h0q2s21xx8.t.conduit.xyz"

apps/connect/.env.production

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="https://syncserver.hypergraph.thegraph.com"
2+
VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="https://hypergraph.fly.dev"
3+
VITE_HYPERGRAPH_CHAIN="geo-testnet"
4+
VITE_HYPERGRAPH_API_URL="https://v2-postgraphile.up.railway.app/graphql"
5+
VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz"
6+
VITE_PRIVY_APP_ID="cmcccikza007bjy0niawgutl0"
7+
VITE_PRIVY_PROVIDERS="production"

0 commit comments

Comments
 (0)