Skip to content

Crossbell-Box/newbie-villa

Repository files navigation

Crossbell Newbie Villa Backend Service

Newbie Villa facilitates a smooth transition from Web2 to Web3 on Crossbell. Users can start by registering with their email, automatically receiving a Character for on-chain social interactions. As users delve deeper, they can claim their Characters via a wallet address, unlocking the broader Web3 social realm on Crossbell.

Features

  • Seamless Web3 migration with familiar email authentication.
  • Automatic Character assignment for new registrations.
  • On-chain social interactions recorded, with server covering initial gas fees.
  • Progress to a genuine Web3 social user by claiming your Character with a wallet address.

Getting Started

Install deps:

npm install

Prepare environment variables:

copy .env.example .env

Setup wallet:

You will need to create a wallet and obtain the private key and address, then fill in the environment variables: NEWBIE_VILLA_WALLET_ADDRESS and NEWBIE_VILLA_WALLET_PRIVATE_KEY.

Setup mailer:

Follow this article to obtain the needed environment variables: MAILER_GMAIL_CLIENT_ID, MAILER_GMAIL_CLIENT_SECRET, MAILER_GMAIL_REFRESH_TOKEN and MAILER_USER.

Start Database instance:

npm run docker:db

Migrate database and generate types in development environment:

npm run prisma:migrate:dev

Start server:

npm run start:dev

Access the Swagger API docs:

Once the server starts, the Swagger API docs will be available at the /docs path. For example, if you are running the server locally at port 3987, you can access the docs at http://localhost:3987/docs.

Deployment

Docker:

# building new NestJS docker image
docker-compose build
# or
npm run docker:build

# start docker-compose
docker-compose up -d
# or
npm run docker

In Node.js Environment:

npm install
npm run build
NODE_ENV=production node dist/main

Migrate database

In development:

npm run prisma:migrate:dev

In production:

npm run prisma:migrate:deploy

Customizing Endpoints in Crossbell React Kits

Check out the customizing guide here.

Modules

NewbieJWT Module handles the account related features like login, register, reset password, delete account, etc.

NewbieTransaction Module handles the transactions like posting, commenting, liking, tipping, etc.

Mailer Module handles the email related features like sending verification email, sending reset password email, etc.

CsbManager Module provides some helper functions for interacting with the $CSB.

Contract Module used to initialize the contract instance.

Contribute

Feel free to contribute to the Newbie Villa service to help lower the barrier between Web2 and Web3!

🫡 This project was initially developed by @SongKeys. Original commit logs were deleted to protect sensitive information before open-sourcing.