Skip to content

Commit 4a92e5c

Browse files
committed
API.md
1 parent 3523c03 commit 4a92e5c

File tree

1 file changed

+57
-17
lines changed

1 file changed

+57
-17
lines changed

README.md

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,73 @@
1-
# Rails API + React Template
1+
# :postbox: Rails API for URL Shortening :outbox_tray:
22

3-
Includes:
3+
What I'm gonna use:
44

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

7-
* MySQL2
7+
* [MySQL2](https://github.com/brianmario/mysql2)
88

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

11-
* Stylus + PostCSS (SugarSS) + Rupture
11+
* [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) for simplier RSpec testing
1212

13-
* Husky
13+
* [Faker](https://github.com/stympy/faker)
1414

15-
* Jest
15+
* [Heroku](https://heroku.com/) for deployment & development
1616

17-
* Webpack for dev & prod
17+
* [Husky](https://github.com/typicode/husky) to manage GIT hooks
1818

19-
* And more
19+
* [Rack::Attack](https://github.com/kickstarter/rack-attack) to prevent DOS
20+
* [Memcached/Dalli](https://github.com/petergoldstein/dalli) for requests throttling
2021

22+
* [Geocoder](https://github.com/alexreisner/geocoder) to track locations
23+
24+
----
2125

2226
## Development
2327

24-
```bash
25-
rake start
26-
```
28+
Use `rails s` and [curl](https://github.com/curl/curl) for HTTP requests.
29+
30+
---
31+
32+
## Project Structure
33+
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.
37+
38+
#### Controllers
39+
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);
44+
45+
#### Models
46+
47+
* `Link` to store `:url` and `:shortened`;
48+
* `Redirect` to store `:location` and `:time`;
49+
50+
A single `Link` has many `Redirects`. A single `Redirect` belongs to one `Link`.
51+
52+
#### Validators
53+
54+
* `Base62Validator` to `validate :base62` shortening;
55+
* `UrlValidator` to `validate :url` formatting;
56+
57+
### `config/`
58+
59+
* `initializers/rack_attack.rb` to configure [Rack::Attack](https://github.com/kickstarter/rack-attack);
60+
61+
* `environments/*.rb` to manage heroku `production` and local environments (`development` and `testing`);
62+
63+
### `spec/`
64+
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.
66+
67+
I belive that everything is backed by tests by now.
2768

69+
### Specific files
2870

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

31-
```bash
32-
npm run build
33-
```
73+
### `/.*|(other)/` folders & files are pretty default

0 commit comments

Comments
 (0)