Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Chores: readmes (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
luixo authored May 23, 2023
1 parent 332a05e commit c8ab661
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 84 deletions.
57 changes: 34 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

[![CI](https://github.com/near/near-explorer/actions/workflows/continuous-integration-workflow.yml/badge.svg?event=push)](https://github.com/near/near-explorer/actions/workflows/continuous-integration-workflow.yml)

In development.

## Setup

### Docker-based Setup
Expand All @@ -13,40 +11,53 @@ Prerequisite:
- Docker
- Docker-Compose

Build Docker images:
Build & run the containers (choose a network):

```
$ docker-compose build
$ npm run docker:up:mainnet
or
$ npm run docker:up:testnet
or
$ npm run docker:up:shardnet
or
$ npm run docker:up:guildnet
```

Run them:
NOTE: You may want to run them in background, so just add `-- --detach` flag.

```
$ docker-compose up
```
Now you can reach the service at http://localhost:3000/

### Node.js Setup (hot reload)

Prerequisite:

NOTE: You may want to run them in background, so just add `--detach` flag.
- Node.js (run `nvm use` to switch to the proper version)

Now you can reach the services:
Install dependencies:

- http://localhost:3000/ -- frontend server
- http://localhost:10000/trpc -- backend server (you don't need it unless you are a developer)
- ws://localhost:10000/ws -- pubsub server (you don't need it unless you are a developer)
```
$ npm install
```

## Development Q&A
Run backend (choose a network):

Q: How to run the local development version of the frontend/backend?
```
$ npm run -w backend dev:mainnet
or
$ npm run -w backend dev:testnet
or
$ npm run -w backend dev:shardnet
or
$ npm run -w backend dev:guildnet
```

A: It is recommended to use `docker-compose` to run all the services and then stop the one that
you want to develop locally (`docker-compose stop frontend`). (Follow the execution instructions
written in the relevant README file of the subproject)
Run frontend in a separate window:

Q: How to auto-format the source code on commit?
```
$ npm run -w frontend dev
```

A: Use `npm install` from the root of the project, so it sets up the git hooks which
automatically run `prettier` on every commit. (We wish we don't need to have the root
`package.json`, but [husky](https://github.com/typicode/husky/issues/36) does not support
subpackages nicely)
Now you can reach the service at http://localhost:3000/

## Contributing

Expand Down
31 changes: 17 additions & 14 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
# NEAR Explorer Backend

## Naming Conventions

- Use kebab-case to name general modules (put them into `src/` structure)
- Use camelCase to name variables, constants, functions, and methods
- Use PascalCase to name classes
- Use a single underscore in front of a method name to indicate private (non-public) methods

## Run Backend
## Run in development

The simplest way to get started is to use [Indexer for Explorer](https://github.com/near/near-indexer-for-explorer) data.
Conveniently, there are all the basic settings done in `package.json` and `mainnet.env` / `testnet.env` / `shardnet.env` / `guildnet.env`, so you can just run:

```
$ npm run dev:mainnet
$ npm run -w backend dev:mainnet
or
$ npm run -w backend dev:testnet
or
$ npm run -w backend dev:shardnet
or
$ npm run -w backend dev:guildnet
```

NOTE: There are also configurations for `testnet`, `shardnet`, and `guildnet`, just change command suffix.

NOTE: To override `mainnet.env` values during local development, create file `mainnet.env.local` and export all the necessary environment variables there

## Run Backend for Production
## Build & run in production

If you want to build a release bundle and run it:

```
$ npm run build
$ npm run start
$ npm run -w backend build
$ npm run -w backend start:mainnet
or
$ npm run -w backend start:testnet
or
$ npm run -w backend start:shardnet
or
$ npm run -w backend start:guildnet
```
56 changes: 9 additions & 47 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,32 @@
# NEAR Explorer Frontend

## Project Structure

```
Project Root
├── "configuration-files"
│ 
├── public
│   └── static
│ 
└── src
   ├── components
   │   ├── dash-case-component-group
   │   │   └── PascalCaseComponent.tsx
   │   └── utils
   │   └── PascalCaseComponent.tsx
   │
  ├── libraries
   │   └── kebab-case-module
   │      ├── index.ts
   │      └── kebab-case-module.ts
   │
   └── pages
      └── kebab-case-page-name
         ├── index.tsx
         └── [id].tsx
```

## Naming Conventions

- Use PascalCase to name React Components (put them into `src/components/` structure), and
`export default` an unnamed component
- Use kebab-case to name general modules (put them into `src/libraries/` structure)
- Use kebab-case and [Dynamic Routing rules](https://github.com/zeit/next.js/#dynamic-routing) to
name the pages (put them into `src/pages/` structure)
- Use camelCase to name variables, constants, functions, and methods
- Use PascalCase to name classes
- Use a single underscore in front of a method name to indicate private (non-public) methods

## Run Frontend for Development
## Run in development

Frontend required running backend to be run in the background to be usable.
Follow the [backend instructions](../backend/README.md) and start frontend like this:

```
$ npm run dev
$ npm run -w frontend dev
```

## Run Frontend for Production
## Build & run in production

If you want to build a release bundle and run it:

```
$ npm run build
$ npm run start
$ npm run -w frontend build
$ npm run -w frontend start
```

## Run Tests
## Unit & e2e tests

To run unit tests, use the following command:
To run unit tests (using Jest), use the following command:

```
$ npm run test
$ npm run -w frontend test
```

To run end-to-end testing against the local backend server:
To run end-to-end tests (using Playwright) against the local server:

```
$ npm run build
Expand Down

0 comments on commit c8ab661

Please sign in to comment.