Skip to content

Latest commit

 

History

History
314 lines (206 loc) · 8.25 KB

README.md

File metadata and controls

314 lines (206 loc) · 8.25 KB

Social App Template Backend

This is a prototype for a DSNP Gateway to allow for simple provider setup.

📗 Table of Contents

📖 Social Application Template (SAT)

The Gateway Services are a suite of services designed to make interacting with Frequency easy for applications integrating with DSNP. The SAT is an example client that shows you how to use Gateway.

Gateway enables web2 companies to use a simple gateway into web3 using tooling they are accustomed to. It aims to let service providers self-serve with minimal help outside of docs and tools, rather than interacting with Frequency directly. Providers no longer need to fully understand blockchain tooling to build on DSNP over Frequency.

🔭 Arch Maps

Overview of the Social App Template in relation to Gateway Services.

Arch Map

Key: * = coming soon

(back to top)

🛠 Built With

Tech Stack

Key Features

  • Sign in with Frequency
  • Create a post
  • Create a comment on a post
  • Get feed data
  • Get users' profile data
  • Post graph data (i.e. follow/unfollow)
  • Get graph data (i.e.follow list)

(back to top)

🚀 Live Docs

(back to top)

💻 Getting Started

Prerequisites

In order to run this project you need to:

Setup

Clone this repository to your desired folder:

Example commands:

  git clone [email protected]:ProjectLibertyLabs/social-app-template.git
  cd social-app-template

Install

Install NPM Dependencies:

  npm install

Environment Variables

The application is configured by way of environment variables. A complete list of available environment variables is here. Environment variables are supplied to the application through environment files.

More Details The default scripts and images for this app are configured in a slightly different way from the usual method. Because this Gateway app is a template meant to be used with other services and built upon, the supplied scripts enable launching a full environment of all Frequency Gateway services needed by this Gateway application. To that end, each service has its own environment, which are specified in the `docker-compose-bare-metal.yaml` and `docker-compose.yaml` files. Additionally, when running in bare-metal mode, `npm run env:init` will create the necessary `.env.social-app-backend` file from the `env.social-app-backend.template` file.

Sample configuration files can be found here.

Initialize the env files using the templates:

npm run env:init

⚡ Quick Start (Dockerized)

This environment is the best for supporting frontend development.

To quickly start up a set of preconfigured services, including this sample backend Gateway, run:

./scripts/restart-chain-docker.sh

For more details on configuring and running the individual services, see Usage.

⚡ Quick Start (Bare Metal)

This environment is the best for supporting local backend development.

./scripts/restart-chain-bare-metal.sh
npm run start:dev

Usage

1. Start Frequency Node

Note: There are other options, but these are simplest to get started with.

Option 1: Use Public Frequency Rococo Testnet Nodes

This is best for Testnet interactions.

Setup the Environment Variables:

  • FREQUENCY_API_WS_URL="wss://rpc.paseo.frequency.xyz"
  • SIWF_NODE_RPC_URL="https://rpc.paseo.frequency.xyz"

Option 2: Local Network from Source

This is for simple local development work.

Run the provided Docker Compose script to launch a local Frequency node:

docker compose up -d frequency

2. Create Provider

Create Provider for //Alice on localhost Frequency node.

Note: There are other options, but these are simplest to get started with.

  • Option 1: Frequency Rococo Testnet

    Follow the instructions on the Frequency Provider Dashboard (coming soon).

  • Option 2: Local Network

    npm run local:init

3. Start Gateway Services and dependencies

Run the following command to start all Gateway Services and dependencies. For more info on what's included or if you want to run each service individually, check out the docker compose file.

docker compose --profile full up -d

4. Build

Option 1: Build a Docker image from the Dockerfile:

npm docker-build

--or--

Option 2: Build Docker images from the docker-compose.yml file for dev:

npm docker-build:dev

📋 Testing & Development

Run the tests

Run the test script, which uses Vitest:

npm test

Linting

npm run lint

Auto-format

npm run format

Generate Types

Generate types from openapi.json

npm run gen:types

Swagger UI

Check out the Swagger UI hosted on the app instance at <base url>/api/docs/swagger to view the API documentation and submit requests to the service.

Debugging Tips

  1. Stop all docker containers.
    docker compose down
  2. Go to Docker and delete all Volumes.
  3. Rerun quickstart or usage commands.
  4. If that doesn't work, repeat step 1 and 2, delete the relative Containers and Images, then repeat step 3.

Deployment

You can deploy using containers. Check the docker-compose.yaml file for more details.

(back to top)

📚 References

🤝 Contributing

Contributions, issues, and feature requests are welcome!

(back to top)

📝 License

This project is Apache 2.0 licensed.

(back to top)