Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
114 changes: 52 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,54 @@
# Process

Fork the repository into your account. Once your code is ready open a pull-request on this repository and we will review it.

# Introduction

The aim of the test is to develop a mini-application for managing a Binance websocket pricing update.

1. The appliction should consume this endpoint `GET` https://api.binance.com/api/v3/exchangeInfo and list it.
2. Users should be able create a list of symbols.
3. Users should be able to add symbols to a list for watching the last price updates, best bid price, best ask price and price change percent.
1. For that, the application should connect to a websocket using the symbols previously selected by the user.
2. The update should occur in almost near real time.
3. Use the following url for connection to the websocket. wss://data-stream.binance.com/stream?streams={symbol}/{symbol}
1. Example: wss://data-stream.binance.com/stream?streams=ethbtc/bnbbtc

Websocket sample response:
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default tseslint.config({
extends: [
// Remove ...tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```
{
Β  "e": "24hrTicker",Β  // Event type
Β  "E": 123456789,Β Β Β Β  // Event time
Β  "s": "BNBBTC",Β Β Β Β Β  // Symbol
Β  "p": "0.0015",Β Β Β Β Β  // Price change
Β  "P": "250.00",Β Β Β Β Β  // Price change percent
Β  "w": "0.0018",Β Β Β Β Β  // Weighted average price
Β  "x": "0.0009",Β Β Β Β Β  // First trade(F)-1 price (first trade before the 24hr rolling window)
Β  "c": "0.0025",Β Β Β Β Β  // Last price
Β  "Q": "10",Β Β Β Β Β Β Β Β Β  // Last quantity
Β  "b": "0.0024",Β Β Β Β Β  // Best bid price
Β  "B": "10",Β Β Β Β Β Β Β Β Β  // Best bid quantity
Β  "a": "0.0026",Β Β Β Β Β  // Best ask price
Β  "A": "100",Β Β Β Β Β Β Β Β  // Best ask quantity
Β  "o": "0.0010",Β Β Β Β Β  // Open price
Β  "h": "0.0025",Β Β Β Β Β  // High price
Β  "l": "0.0010",Β Β Β Β Β  // Low price
Β  "v": "10000",Β Β Β Β Β Β  // Total traded base asset volume
Β  "q": "18",Β Β Β Β Β Β Β Β Β  // Total traded quote asset volume
Β  "O": 0,Β Β Β Β Β Β Β Β Β Β Β Β  // Statistics open time
Β  "C": 86400000,Β Β Β Β Β  // Statistics close time
Β  "F": 0,Β Β Β Β Β Β Β Β Β Β Β Β  // First trade ID
Β  "L": 18150,Β Β Β Β Β Β Β Β  // Last trade Id
Β  "n": 18151Β Β Β Β Β Β Β Β Β  // Total number of trades
}
````

# Technical Requirements

- React 14+
- Use context for data flow
- Must be responsive
- Typescript
- Usage of functional components

# Bonus
- unit-tests for the UI
- integration-test (one (or more) just in order to show that you know what is it (: )

# Docs

Binance documentation:
- https://binance-docs.github.io/apidocs/spot/en/#introduction

UI Sample to use as a guide:
![Screenshot 2023-03-15 at 10 51 49](https://user-images.githubusercontent.com/20883536/225329370-30ff8f83-7493-4b91-9ae1-561b6fe6bda3.png)
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default tseslint.config({
plugins: {
// Add the react-x and react-dom plugins
'react-x': reactX,
'react-dom': reactDom,
},
rules: {
// other rules...
// Enable its recommended typescript rules
...reactX.configs['recommended-typescript'].rules,
...reactDom.configs.recommended.rules,
},
})
```
16 changes: 16 additions & 0 deletions __mocks__/binanceMocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { SymbolInfo } from '../src/utils/types';

export const mockSymbols: SymbolInfo[] = [
{
symbol: 'BTCUSDT',
baseAsset: 'BTC',
quoteAsset: 'USDT',
status: 'TRADING'
},
{
symbol: 'ETHUSDT',
baseAsset: 'ETH',
quoteAsset: 'USDT',
status: 'TRADING'
}
];
2 changes: 2 additions & 0 deletions __mocks__/fileMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const fileMock = "test-file-stub";
export default fileMock;
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Frontend Test Fontiana</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
globals: {
'ts-jest': {
tsconfig: './tsconfig.jest.json',
},
},
moduleNameMapper: {
'\\.(css|scss)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|webp|svg)$': '<rootDir>/__mocks__/fileMock.ts',
'^@/(.*)$': '<rootDir>/src/$1'
},
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
}
};
Loading