Skip to content

Commit dd048e2

Browse files
committed
docs(mvp): add README
#2
1 parent edda1e6 commit dd048e2

File tree

4 files changed

+216
-30
lines changed

4 files changed

+216
-30
lines changed

README.cra.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
## Available Scripts
4+
5+
In the project directory, you can run:
6+
7+
### `yarn start`
8+
9+
Runs the app in the development mode.<br />
10+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
12+
The page will reload if you make edits.<br />
13+
You will also see any lint errors in the console.
14+
15+
### `yarn test`
16+
17+
Launches the test runner in the interactive watch mode.<br />
18+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
20+
### `yarn build`
21+
22+
Builds the app for production to the `build` folder.<br />
23+
It correctly bundles React in production mode and optimizes the build for the best performance.
24+
25+
The build is minified and the filenames include the hashes.<br />
26+
Your app is ready to be deployed!
27+
28+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29+
30+
### `yarn eject`
31+
32+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33+
34+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35+
36+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37+
38+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39+
40+
## Learn More
41+
42+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43+
44+
To learn React, check out the [React documentation](https://reactjs.org/).

README.md

+36-30
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,50 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
# React App with graphql + ts
22

3-
## Available Scripts
3+
React app example with data fetching by graphql
44

5-
In the project directory, you can run:
5+
- api source: https://graphqlzero.almansi.me/
66

7-
### `yarn start`
7+
## Tech stack
8+
- **UI**: `react`, `antd`, `classnames`
9+
- **Lang**: `typescript` (3.7+)
10+
- **Fetching**: `graphql`, `apollo-client`
11+
- **API Codegen**: `graphql-codegen`
12+
- **Routing**: `react-router`
813

9-
Runs the app in the development mode.<br />
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
14+
---
1115

12-
The page will reload if you make edits.<br />
13-
You will also see any lint errors in the console.
16+
## Usage
1417

15-
### `yarn test`
18+
### Start local stand
1619

17-
Launches the test runner in the interactive watch mode.<br />
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
20+
```bash
21+
# install deps
22+
npm i
23+
# run stand
24+
npm run start
25+
```
1926

20-
### `yarn build`
27+
### (IN PLAN) Run linter
28+
```bash
29+
npm run lint:fix
30+
```
2131

22-
Builds the app for production to the `build` folder.<br />
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
32+
### (IN PLAN) Run tests
33+
```bash
34+
# Run all tests
35+
npm run test (запуск всех тестов)
36+
# Run unit tests
37+
npm run unit (unit тесты)
38+
# Run lint tests
39+
npm run lint (тесты линтера)
40+
```
2441

25-
The build is minified and the filenames include the hashes.<br />
26-
Your app is ready to be deployed!
42+
---
2743

28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
44+
## Structure
2945

30-
### `yarn eject`
46+
- [STRUCTURE.MD](/STRUCTURE.MD)
3147

32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
48+
## Recommendations
3349

34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
50+
- [RECOMMENDATIONS.MD](/RECOMMENDATIONS.MD)

RECOMMENDATIONS.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Recommendations
2+
3+
## Code
4+
- Don't be blinded by `DRY` principle
5+
> TODO: add comments
6+
- Add comments - only if it's required
7+
- Describe props/types
8+
```ts
9+
type TreeItem = {
10+
/** Unique identifier */
11+
id: TreeNodeId;
12+
/** Name */
13+
name: string;
14+
/** Amount of related items */
15+
count: number;
16+
/** Parent identifier */
17+
parentId?: TreeNodeId;
18+
}
19+
```
20+
- Use `tsdoc`-like style
21+
```ts
22+
/**
23+
* Tooltip
24+
* @remark If you should not specify `title` props - tooltip'll be invisible
25+
*/
26+
const Tooltip = (props: Props) => {
27+
```
28+
29+
## Styles
30+
- Use `css` vars
31+
- specially - with work with colors
32+
- not only on app level, also at component's level
33+
34+
```css
35+
.app {
36+
--clr-base: #4d97fd;
37+
--clr-base-hover: #4d97fd1f;
38+
...
39+
}
40+
```

STRUCTURE.MD

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Structure
2+
Project was structured by [Feature Driven Development](https://www.notion.so/Feature-Driven-Development-dfe306d664ae4780bcf999ccdd15e532).
3+
4+
## Principles
5+
- low decoupling
6+
- **feature** should not depend from **other features**
7+
- **page** should not depend from **other pages**
8+
- **shared resources** should not depend from **each other**
9+
- all **needed** resources (store / async effects / components) - locate in `features/` dir
10+
- all **common used** resources (components / helpers / fixtures) - locate in `shared/` dir
11+
- about **premature optimization**
12+
- not need to strive to optimize modules for *changing*
13+
- because of we can't predict future
14+
- instead of this - *it's desirable* to optimize their for *deleting*
15+
- because of it's only one thing we know - that all code transform to chaos =)
16+
- and it's easier to refactor **totally (clean up)** only few modules, instead of one app totally
17+
18+
## Folders
19+
```markdown
20+
└── src/ # Source files
21+
├── app/ # Base app's resources
22+
├── features/ # Crucial domain splitted app's features
23+
├── pages/ # App's pages (build from features, shared)
24+
└── shared/ # Common modules for dev
25+
├── components/ # **Common used** React components
26+
├── helpers/ # **Common used** Helpers
27+
├── hocs/ # **Common used** React HOCs
28+
├── hooks/ # **Common used** React Hooks
29+
├── fixtures/ # **Common used** data helpers / dataSets
30+
├── get-env # Module with **env**-vars
31+
├── mixins.scss # **Common used** SCSS mixins
32+
└── consts.scss # **Common used** SCSS consts (not colors)
33+
```
34+
35+
## Feature
36+
37+
**Feature - a self-contained user facing reusable complex building block
38+
**Feature** - a <u>self-contained</u>, <u>user-facing</u>, (maybe) <u>reusable</u> between pages and <u>complex logic</u> contained building block (module).
39+
40+
> More details - [here](https://www.notion.so/Summary-YouTube-Feature-Driven-Arhitecture-b8609fd4452b41f499703c841e56b8e9#18cb1679b2754951ae92627d371d1a88)
41+
42+
```markdown
43+
└── features/
44+
└── feature-name/
45+
├── components/ # UI components (`React`, `Canvas`)
46+
├── store/ # Redux store of component
47+
│ ├── slice.ts # Feature state's `slice`
48+
│ ├── types.ts # Required `types` of slice
49+
│ ├── selectors.ts # `Selector`s of slice
50+
│ ├── effects.ts # `Thunks` with async side-effects
51+
│ └── helpers.ts # Required `helpers`
52+
├── {...}/ # Potentially, you can locate here and other **required** modules (but without fanaticism)
53+
└── index.ts # Feature's `entry-point` (with declared public feature's API)
54+
```
55+
56+
## Api
57+
- `src/models.ts` - generated models types from graphql schema
58+
- `src/{path/to/feature}/{query}.gql` - request file (query / mutation) for fetch / post information by server API
59+
- `src/{path/to/feature}/{query}.gen.ts` - **READONLY** module with generated ts code of related request (in same dir with same name)
60+
61+
### Usage:
62+
```tsx
63+
import { useTodoQuery } from "./query.gen";
64+
...
65+
function YourComponent(props: Props) {
66+
const { data, loading, error } = useTodoQuery({ variables: { id }});
67+
...
68+
}
69+
```
70+
71+
> codegen by `@graphql-codegen`, more details in [codegen.yml][/codegen.yml]
72+
73+
#### Assets
74+
Perfectly, all static *assets* files should locate on related components level (**on using level**).
75+
76+
> Because of - generally - there is own **unique** icons collection for every UI area
77+
78+
If you its **very necesary and matter** for you - to have common-used icons, then locate their in `shared` folder (in this case - you can import them from any point of app)
79+
80+
```markdown
81+
└── shared/
82+
├── assets/
83+
```
84+
85+
#### Shared
86+
There is public API declaration file (`index.ts`) in all shared modules (with module's API for other modules)
87+
88+
**Recommends to get all needed submodules namely with its**
89+
90+
Other words, if you want to import common component `Loader`:
91+
```ts
92+
// Bad (private module path using)
93+
import Loader from "shared/components/loader";
94+
// Good (API is controlled by module entry-point file)
95+
import { Loader } from "shared/components";
96+
```

0 commit comments

Comments
 (0)