Skip to content

Commit 4ef4aa5

Browse files
committed
react.md
1 parent 8e6324a commit 4ef4aa5

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

README.md

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,76 @@
1-
# :postbox: Rails API for URL Shortening :outbox_tray:
1+
# :zap: React URL Shortener :cyclone:
22

33
What I'm gonna use:
44

5-
* [Rails](https://github.com/rails/rails) API 5.2.1
5+
* [React](https://github.com/facebook/react)
66

7-
* [MySQL2](https://github.com/brianmario/mysql2)
7+
* [Webpack](https://github.com/webpack/webpack) for bundling & developing
88

9-
* [RSpec](https://github.com/rspec/rspec-rails) for testing
9+
* [CoffeeScript2](https://github.com/jashkenas/coffeescript)
1010

11-
* [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) for simplier `RSpec` testing
11+
* [Stylus](https://github.com/stylus/stylus) CSS Preprocessor with [Rupture](https://github.com/jescalan/rupture) media queries
1212

13-
* [Faker](https://github.com/stympy/faker)
13+
* [PostCSS](https://github.com/postcss/postcss) for `lint`ing and `autoprefix`ing mostly
1414

15-
* [Heroku](https://heroku.com/) for deployment & development
15+
* [SugarSS](https://github.com/postcss/sugarss) to `lint` `Stylus`
1616

17-
* [Husky](https://github.com/typicode/husky) to manage GIT hooks & to run `RSpec` test on `pre-commit` & `pre-push`
17+
* [Babel](https://github.com/babel/babel) along with it's ***delightful*** breaking changes in `v7`
1818

19-
* [Rack::Attack](https://github.com/kickstarter/rack-attack) to prevent DOS
20-
* [Memcached/Dalli](https://github.com/petergoldstein/dalli) for requests throttling
19+
* [Jest](https://github.com/facebook/jest), [Enzyme](https://github.com/airbnb/enzyme) for testing (I would not call it testing, I'm new to `Jest` & `Enzyme` and to the whole `React` ecosystem)
2120

22-
* [Geocoder](https://github.com/alexreisner/geocoder) to track locations
21+
* [Husky](https://github.com/typicode/husky) to manage GIT hooks & to run `Jest` test on `pre-commit` & `pre-push`
22+
23+
* [Heroku](https://heroku.com) for delpoyment & for local development using `Rake` + `./Procfile.dev` in order to run my `Rails API` server along with `webpack-dev-server`. I belive it's okay to do like this.
2324

2425
----
2526

2627
## Development
2728

28-
Use `rails s` and [curl](https://github.com/curl/curl) for HTTP requests.
29+
Use `rake start` to boot `bundle exec rails -s` and `webpack-dev-server` simultaneously.
2930

3031
---
3132

3233
## Project Structure
3334

34-
### `app/`
35-
36-
You may know the `app/` structure since it's pretty default. It's the home to `models`, `controllers`, `validators`, `exception handlers` etc.
35+
### `client/public`
36+
Static files.
3737

38-
#### Controllers
38+
### `client/src/api`
39+
API module for `count`ing, `store`ing and `get`ing `Links`.
3940

40-
There are three controllers which are interesting for us:
41-
* `application_controller` with module dependencies;
42-
* `links_controller` handles `store`-ing, `get`-ing, `count`-ing for the `Link` model;
43-
* `redirect_controller` with a single method to `redirect` and store the `Redirect` itself (i.e. it's location) using the [Geocoder](https://github.com/alexreisner/geocoder);
41+
### `client/src/components`
42+
This one serves as the React `components'` storage. Usually `client/src/components/`.sample contains `.coffee` for the logic written in `CoffeeScript2`, `.sss` for the styles written in `Stylus/SugarSS` and the `.test.coffee` for testing with `Jest`.
4443

45-
#### Models
44+
***Sometimes*** it contains another folder `inline` which serves for inline styles for ***some*** components needed to be overwritten.
4645

47-
* `Link` to store `:url` and `:shortened`;
48-
* `Redirect` to store `:location` and `:time`;
4946

50-
A single `Link` has many `Redirects`. A single `Redirect` belongs to one `Link`.
47+
### `client/utils/*.js`
48+
`Jest` configuration.
5149

52-
#### Validators
50+
### `client/utils/encode`
51+
`base62` number encoder and the `.test.coffee` for it.
5352

54-
* `Base62Validator` to `validate :base62` shortening;
55-
* `UrlValidator` to `validate :url` formatting;
53+
### `client/utils/url`
54+
`process.env.APP_URL` passed using the `Webpack` bundler.
5655

57-
### `config/`
56+
### `client/utils/variables`
57+
`Stylus/SugarSS` variables.
5858

59-
* `initializers/rack_attack.rb` to configure [Rack::Attack](https://github.com/kickstarter/rack-attack);
59+
### `client/App.coffee`
60+
Entry point. We call it `instance` in `VueJS`. Has it's own `App.sss` with styles.
6061

61-
* `environments/*.rb` to manage heroku `production` and local environments (`development` and `testing`);
62+
### `client/index.(dev|prod).js`
63+
That's how `Webpack` knows what he should do in different `environments`. I need the `hot-loading` during the development.
6264

63-
### `spec/`
65+
### `client/jest.config.js`
66+
`Jest` configuration.
6467

65-
This is for [RSpec](https://github.com/rspec/rspec-rails) with [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) & [Faker](https://github.com/stympy/faker) testing.
68+
### `client/postcss.config.js`
69+
`PostCSS` plugins.
6670

67-
I belive that everything is backed by tests by now.
71+
### `webpack.(common|dev|prod).js`
72+
`.common` to be shared between `.dev` & `.prod` for different `env`
6873

69-
### Specific files
70-
71-
`.branch-ignore` is used by me to manage branch-specific `.gitignore` using [Husky](https://github.com/typicode/husky) and `.gitignore.<branch-name>` files.
74+
---
7275

73-
### `/.*|(other)/` folders & files are pretty default
76+
:tada:

0 commit comments

Comments
 (0)