Skip to content

Commit 4f4a09b

Browse files
authored
Merge pull request #193 from hypercerts-org/develop
Push to PRD
2 parents 8c970ab + 905d32d commit 4f4a09b

39 files changed

+4439
-1695
lines changed

.env.template

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1+
## SERVICE
2+
INDEXER_ENVIRONMENT=test
13
PORT=4000
2-
KEY=
3-
PROOF=
44

5-
SUPABASE_CACHING_DB_URL=
6-
SUPABASE_CACHING_ANON_API_KEY=
5+
### W3UP - https://github.com/storacha/w3up/tree/main/packages/w3up-client#bringing-your-own-agent-and-delegation
6+
KEY=""
7+
PROOF=""
78

8-
SUPABASE_DATA_DB_URL=
9-
SUPABASE_DATA_ANON_API_KEY=
10-
SUPABASE_DATA_SERVICE_API_KEY=
9+
### SUPABASE JS - https://www.npmjs.com/package/@supabase/supabase-js
1110

12-
SENTRY_DSN=
11+
SUPABASE_CACHING_DB_URL="http://127.0.0.1:54321"
12+
SUPABASE_CACHING_ANON_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
1313

14-
INDEXER_ENVIRONMENT=test
14+
SUPABASE_DATA_DB_URL="http://127.0.0.1:64321"
15+
SUPABASE_DATA_ANON_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
16+
SUPABASE_DATA_SERVICE_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
17+
18+
### KYSELY
19+
20+
CACHING_DATABASE_URL=postgresql://postgres:[email protected]:54322/postgres
21+
DATA_DATABASE_URL=postgresql://postgres:[email protected]:64322/postgres
22+
23+
### SENTRY
24+
SENTRY_ENVIRONMENT=local # local | staging | production
25+
SENTRY_DSN="" #disabled for local
26+
SENTRY_AUTH_TOKEN="" #disabled for local
27+
28+
### RPCs - we implement a fallback to the first available RPC
29+
30+
# https://www.alchemy.com/
31+
ALCHEMY_API_KEY=""
32+
33+
# https://www.infura.io/
34+
INFURA_API_KEY=""
35+
36+
# https://drpc.org/
37+
DRPC_API_KEY=""

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
build
33
coverage
44
dist
5-
**/__generated__/
5+
**/__generated__/
6+
src/types/graphql-env.d.ts

README.md

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,51 @@
11
# Hypercerts API
22

3-
The hypercerts API is the touchpoint for developers to interact with the hypercerts ecosystem. It provides endpoints for data upload and fetch, a GraphQL API for querying (on-chain) state and a health check endpoint.
3+
The hypercerts API is the touchpoint for developers to interact with the hypercerts ecosystem. It provides endpoints for data upload and fetching, a GraphQL API for querying (on-chain) state and a health check endpoint.
44

5-
## Endpoints
5+
## Getting started
6+
7+
### Environment variables
8+
9+
#### W3UP
10+
11+
In `env.template` you'll find KEY and PROOF which are [w3up](https://web3.storage/docs/w3up-client/) key and proofs which you need to set up yourself for local otherwise you'll be superadmin 😉
12+
13+
#### Supabase JS
14+
15+
SupabaseJS is used to connect to both the the caching and data service. The local variables are deterministic and provided in the template.
16+
17+
#### Kysely
18+
19+
Kysely is implemented in favor of SupabaseJS as it allows for more flexibility and complexity in queries. To connect to the database you need to set the `CACHING_DATABASE_URL` and `DATA_DATABASE_URL` in the `.env` file. By default, the local variables are set to the local Supabase instance.
20+
21+
#### Sentry
22+
23+
Sentry is used for monitoring and error reporting. You can read more about it [here](https://docs.sentry.io/platforms/javascript/guides/node/configuration/env-vars/). When Sentry is set to `local` it will be disabled by default.
24+
25+
#### RPCs
26+
27+
The API implements a fallback to the first available RPC. You can set the RPCs in the `.env` file.
28+
29+
### Supabase
30+
31+
* Install Docker
32+
* `git submodule init`
33+
* `git submodule update --remote`
34+
* `pnpm supabase:start:all`
35+
36+
This will spin up 2 Supabase instances in Docker, one for the indexer service (caching) and one for the data service (static data) which are both exposed by the API.
37+
38+
From both instances, you can get their respective keys and add them to the env vars. When in doubt you can run `supabase status` to fetch the keys again. By default this is not needed for local development.
39+
40+
### Run the API locally
41+
42+
`pnpm dev`
43+
44+
This will run a live production instance by running `swc` to compile the code and `nodemon` to restart the server on changes.
45+
46+
You can then find the API at `localhost:4000/spec` (Swagger instance) and the GraphQL at `localhost:4000/v1/graphql`
47+
48+
## Deployments
649

750
Production: `https://api.hypercerts.org/`
851
Staging: `https://staging-api.hypercerts.org`
@@ -16,4 +59,65 @@ Staging: `https://staging-api.hypercerts.org`
1659
- `build`: Denerates the OpenAPI specification and routes using `tsoa`, and then compiles the TypeScript code into JavaScript using `swc`. The compiled code is output to the `dist` directory.
1760
- `start`: Starts the application in production mode.
1861
- `lint`: Runs `eslint` on the codebase to check for linting errors.
19-
- `test`: Runs tests using `vitest`.
62+
- `test`: Runs tests using `vitest`
63+
64+
## Data
65+
66+
The API service exposes data from two sources:
67+
68+
- The static data service which contains off-chain data like user data, hypercert collections, signed order messages, etc.
69+
- The indexer service which contains on-chain data about hypercerts and the linked data on IPFS (hypercerts, ownerships, metadata, attestations, etc.)
70+
71+
### Static data service
72+
73+
The static data service is a Supabase database which is exposed by the API. This means that you can create, update and delete data through the API. For read functionality we recommend using the GraphQL API and playground to carefully compose the data model needed for your use case.
74+
75+
### Indexer service
76+
77+
The indexer service monitors our supported chains for relevant events and handles those events accordingly. All data exposed by the indexer service is available in different sources as well, like IPFS for metadata and EAS for attestations.
78+
79+
## Validations
80+
81+
The API also provides an upload and validation endpoint for hypercert and allow list data. In the [live docs](https://api.hypercerts.org/spec) you can find the endpoint and docs. Generally, by using `validate` you can post the data for validation without it being uploaded to IPFS.
82+
83+
## Architecture
84+
85+
```mermaid
86+
graph TB
87+
Client[Client Applications]
88+
API[Hypercerts API :4000]
89+
90+
subgraph "API Endpoints"
91+
Swagger["/spec\nSwagger Documentation"]
92+
GraphQL["/v1/graphql\nGraphQL Endpoint"]
93+
Upload["Upload & Validation\nEndpoints"]
94+
end
95+
96+
subgraph "Data Services"
97+
Static[("Static Data Service\n(Supabase DB)\n- User Data\n- Collections\n- Signed Orders")]
98+
Indexer[("Indexer Service\n(Supabase DB)\n- On-chain Data\n- IPFS Data")]
99+
end
100+
101+
subgraph "External Services"
102+
IPFS[(IPFS\nMetadata Storage)]
103+
Blockchain[(Blockchain\nSupported Chains)]
104+
EAS[(EAS\nAttestations)]
105+
end
106+
107+
Client --> API
108+
API --> Swagger
109+
API --> GraphQL
110+
API --> Upload
111+
112+
GraphQL --> Static
113+
GraphQL --> Indexer
114+
Upload --> IPFS
115+
116+
Indexer --> Blockchain
117+
Indexer --> IPFS
118+
Indexer --> EAS
119+
120+
class Swagger,GraphQL,Upload apiEndpoint;
121+
class Static,Indexer database;
122+
class IPFS,Blockchain,EAS external;
123+
```

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
"dependencies": {
2727
"@graphql-tools/merge": "^9.0.3",
2828
"@graphql-yoga/plugin-response-cache": "^3.5.0",
29-
"@hypercerts-org/marketplace-sdk": "0.3.36",
30-
"@hypercerts-org/sdk": "2.2.0-beta.3",
29+
"@hypercerts-org/contracts": "2.0.0-alpha.11",
30+
"@hypercerts-org/marketplace-sdk": "0.3.37",
31+
"@hypercerts-org/sdk": "2.3.0",
3132
"@ipld/car": "^5.2.5",
3233
"@openzeppelin/merkle-tree": "^1.0.5",
3334
"@sentry/integrations": "^7.114.0",

0 commit comments

Comments
 (0)