Skip to content

Commit

Permalink
writing(posts): Finish chapter 3 of simple-twitter (#84)
Browse files Browse the repository at this point in the history
* Upgrade theme

* Update algolia in github action

* Fix search

* Add text

* Add text

* Fix lightgallery

* Finish osint post

* Revert to version v0.2.6 of LoveIt theme

* Fix some typos

* Fix posts datas
  • Loading branch information
Nir Galon authored May 18, 2020
1 parent 31c8693 commit 60f842f
Show file tree
Hide file tree
Showing 70 changed files with 1,750 additions and 74 deletions.
7 changes: 7 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ googleAnalytics = "UA-87725724-1"
Reddit = "nirgn975"
Stackoverflow = "2040160/nirgn"
Email = "nir@galon.io"
RSS = true

# Header config
[params.header]
Expand Down Expand Up @@ -216,6 +217,12 @@ googleAnalytics = "UA-87725724-1"
copyTex = true
# KaTeX extension mhchem
mhchem = true
# Code config
[params.page.code]
# whether to show the copy button of the code block
copy = true
# the maximum number of lines of displayed code by default
maxShownLines = 10
# Mapbox GL JS config (Mapbox GL JS https://docs.mapbox.com/mapbox-gl-js)
[params.page.mapbox]
# access token of Mapbox GL JS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ categories: ["contribution"]
hiddenFromHomePage: false
hiddenFromSearch: false

featuredImage: "/images/posts/2017/jekyll-starter-kit-generator-2.1.0-is-out/jekyll-starter-kit.webp"
featuredImage: "/posts/2017/jekyll-starter-kit-generator-2.1.0-is-out/jekyll-starter-kit.webp"
featuredImagePreview: ""

toc:
Expand Down Expand Up @@ -47,7 +47,7 @@ What more cool stuff? Here are couple of examples.
* Automagically optimizes image before deploy.
* Deploy the website to gh-pages or firebase with only one command.

![The generator in action](/images/posts/2017/jekyll-starter-kit-generator-2.1.0-is-out/the-generator-in-action.webp "The generator in action")
![The generator in action](/posts/2017/jekyll-starter-kit-generator-2.1.0-is-out/the-generator-in-action.webp "The generator in action")


If you can’t wait and already want to try it, all you need to do is `npm install -g generator-jekyll-starter-kit` and then just `yo jekyll-starter-kit`. And if you want to help improve this project, just head up to the [repo page on GitHub](https://github.com/nirgn975/generator-jekyll-starter-kit).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ categories: ["contribution"]
hiddenFromHomePage: false
hiddenFromSearch: false

featuredImage: "/images/posts/2017/load-balancing-applications-with-haproxy-and-docker/lets-start.webp"
featuredImage: "/posts/2017/load-balancing-applications-with-haproxy-and-docker/lets-start.webp"
featuredImagePreview: ""

toc:
Expand Down Expand Up @@ -120,7 +120,7 @@ Let’s explain what the hell is happening here. We create 2 services:
2. The second service we create is `HAProxy` from the haproxy Docker (the compony) uses in their cloud (we don’t build it and doesn’t create a `Dockerfile` for it, we just specify from where to pull the image). It `depends_on` the `awesome` service, so it won’t boot until the `awesome` service is finished (i.e. all of the container are up and running). It’s also shared the `docker.sock` file (`volumes` field). This is the file the HAProxy container needs to look at to learn about the containers in it’s network (new and existing containers). We expose port 80, and put this container in the `web` network, In the `deploy` setting, we just tell it to always put this container on the manager node (this settings is related to Docker Swarm, when we have couple of node (i.e. servers).
3. The last thing we do is to create the network (named `web`).

![Our project looks good so far, and we almost at the finish line!](/images/posts/2017/load-balancing-applications-with-haproxy-and-docker/our-project-looks-good-so-far.webp "Our project looks good so far, and we almost at the finish line!")
![Our project looks good so far, and we almost at the finish line!](/posts/2017/load-balancing-applications-with-haproxy-and-docker/our-project-looks-good-so-far.webp "Our project looks good so far, and we almost at the finish line!")

## 3. DockerCloud HAProxy

Expand All @@ -136,11 +136,11 @@ The network, the services, and all the containers called `stack`. To create our

When we’ll hit `http://localhost` we’ll get the container id in the response, and we can see it has a different id every request.

![Different container id every request](/images/posts/2017/load-balancing-applications-with-haproxy-and-docker/different-container-id-evert-request.webp "Different container id evert request")
![Different container id every request](/posts/2017/load-balancing-applications-with-haproxy-and-docker/different-container-id-evert-request.webp "Different container id evert request")

Now let’s look at our services by writing `docker service ls` and we’ll see all of our services and replicas

![All of our docker services](/images/posts/2017/load-balancing-applications-with-haproxy-and-docker/all-of-our-docker-services.webp "All of our docker services")
![All of our docker services](/posts/2017/load-balancing-applications-with-haproxy-and-docker/all-of-our-docker-services.webp "All of our docker services")

We can also create a second version of our `awesome` app. Let’s change the code a little bit (let’s add some exclamation marks at the end):

Expand All @@ -157,7 +157,7 @@ So we need to build the image again, but this time it’s the second version of

We can see our docker slowly (but surly) kill the old containers and create new ones with the second version of our app. And when we hit `http://localhost` we still get a response, there is no downtime.

![Some containers are already use the second version. No Downtime (:](/images/posts/2017/load-balancing-applications-with-haproxy-and-docker/some-containers-are-already-use-the-second-version.webp "Some containers are already use the second version. No Downtime (:")
![Some containers are already use the second version. No Downtime (:](/posts/2017/load-balancing-applications-with-haproxy-and-docker/some-containers-are-already-use-the-second-version.webp "Some containers are already use the second version. No Downtime (:")

Also, if we want to scale the service to more than 20 containers, we can do it with only one command: `docker service scale prod_awesome=50` and docker will start 30 more containers from the `awesome:v2` image.

Expand Down
12 changes: 6 additions & 6 deletions content/posts/2020/chapter-1-simple-twitter.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Simple Twitter - Chapter 1: Setup"
subtitle: ""
date: 2020-04-30T22:00:00+03:00
lastmod: 2020-04-30T22:00:00+03:00
date: 2020-05-01T09:00:00+03:00
lastmod: 2020-05-01T09:00:00+03:00
draft: false
author: "Nir Galon"
authorLink: "https://nir.galon.io"
Expand All @@ -14,7 +14,7 @@ categories: ["development"]
hiddenFromHomePage: false
hiddenFromSearch: false

featuredImage: "/images/posts/2020/chapter-1-simple-twitter/simple-twitter-cover.webp"
featuredImage: "/posts/2020/chapter-1-simple-twitter/simple-twitter-cover.webp"
featuredImagePreview: ""

toc:
Expand Down Expand Up @@ -51,13 +51,13 @@ $ brew install git

That's it, now if you'll write `git` on your command line of choice you'll get as an output all the git commands you can use.

![git bash output](/images/posts/2020/chapter-1-simple-twitter/macbook_git_installed.webp "git bash output")
![git bash output](/posts/2020/chapter-1-simple-twitter/macbook_git_installed.webp "git bash output")

### 1.2. Open a GitHub account

GitHub is a web based git with some extra features. We don't need to install anything to use GitHub, just open an account and configure some stuff. So let's do it! Let's go to https://github.com and pick a `username`, `email`, and `password` and click on the big green button says *Sign up for GitHub*.

![GitHub Sign Up Page](/images/posts/2020/chapter-1-simple-twitter/github_sign_up_page.webp "GitHub Sign Up Page")
![GitHub Sign Up Page](/posts/2020/chapter-1-simple-twitter/github_sign_up_page.webp "GitHub Sign Up Page")

After you sign up you'll need to confirm your account, so check your email. Now we need to config our local `git` with our `email` and `username`. We can do it by typing those command:

Expand Down Expand Up @@ -109,7 +109,7 @@ Now we have MongoDB installed and running on our local machine. But how can we s

Robo 3T is a free and open-source cross-platform MongoDB GUI. With it we can see our databases, collections and even documents in a nice and easy way with a [GUI (Graphical User Interface)](https://en.wikipedia.org/wiki/Graphical_user_interface). Let's continue to install things with the same convenient way, with `brew`. This is a GUI software so it will no be on `brew`, but we already have the `cask` extension for `brew`, so let's search it there: https://formulae.brew.sh.

![Homebrew Cask Robo 3T Search](/images/posts/2020/chapter-1-simple-twitter/homebrew-cask.webp "Homebrew Cask Robo 3T Search")
![Homebrew Cask Robo 3T Search](/posts/2020/chapter-1-simple-twitter/homebrew-cask.webp "Homebrew Cask Robo 3T Search")

Success! so let's install it with `brew cask`

Expand Down
22 changes: 11 additions & 11 deletions content/posts/2020/chapter-2-simple-twitter.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Simple Twitter - Chapter 2: Planning"
subtitle: ""
date: 2020-06-14T10:00:00+03:00
lastmod: 2020-06-14T10:00:00+03:00
date: 2020-07-01T10:00:00+03:00
lastmod: 2020-07-01T10:00:00+03:00
draft: false
author: "Nir Galon"
authorLink: "https://nir.galon.io"
Expand All @@ -14,14 +14,14 @@ categories: ["development"]
hiddenFromHomePage: false
hiddenFromSearch: false

featuredImage: "/images/posts/2020/chapter-2-simple-twitter/simple-twitter-cover.webp"
featuredImage: "/posts/2020/chapter-2-simple-twitter/simple-twitter-cover.webp"
featuredImagePreview: ""

toc:
enable: true
math:
enable: false
lightgallery: false
lightgallery: true
license: ""
---

Expand Down Expand Up @@ -134,7 +134,7 @@ We'll also use some more tools like GitHub repositories and GitHub actions (for

How we're going to connect everything? Here is our technical product schema:

![Architecture Schema](/images/posts/2020/chapter-2-simple-twitter/architecture-schema.webp "Architecture Schema")
![Architecture Schema](/posts/2020/chapter-2-simple-twitter/architecture-schema.webp "Architecture Schema")

Every request to our website in going to first hit our domain. From there it'll get to a load balancer how sits in front of our bucket and will serve the user the static files in the bucket (our Angular app).

Expand All @@ -150,7 +150,7 @@ Every request or error will be logged to `stdout`. And other services in GCP (th

The way we'll deploy new code to the cloud will use GitHub actions, and GCP Cloud Build triggers.

![CI/CD Schema](/images/posts/2020/chapter-2-simple-twitter/ci-cd-schema.webp "CI/CD Schema")
![CI/CD Schema](/posts/2020/chapter-2-simple-twitter/ci-cd-schema.webp "CI/CD Schema")

In our repo we'll have GitHub action that run a linter, run the tests and make sure there isn't any error when build the projects. When we'll merge Pull Requests to the `master` branch, the action will run and if everything is good it'll create a new tag for the new commit.

Expand All @@ -166,29 +166,29 @@ The frontend will build the Angular app and will copy the files to a public buck

In order to be on the same page I took a bunch of screenshots of Tweeter and cleaned it up a bit (remove some of the feature we'll not build), let's go over them and see what we're building.

![Home Page](/images/posts/2020/chapter-2-simple-twitter/twitter-home-page.webp "Home Page")
![Home Page](/posts/2020/chapter-2-simple-twitter/twitter-home-page.webp "Home Page")

After we hit the Home Page we can *Sign up* or *Log in*, in twitter the *Sign-up* button will bring a popup and the *Log in* will move us to a new page. We'll not do data, the *Sign up* will bring a popup with couple of `input`s to fill to sign up, and the *Log in* will just try to login the user using the `username` and `password` `input`s above.

![Feed Page](/images/posts/2020/chapter-2-simple-twitter/twitter-feed-page.webp "Feed Page")
![Feed Page](/posts/2020/chapter-2-simple-twitter/twitter-feed-page.webp "Feed Page")

When the user logged in, or sign up and activate his account via the email confirmation he will get to the Feed Page. This is a list of tweets from the users that he follows, ordered by time (the most recent is at the top).

This is the main page of the website. From this page he can post a new tweet (at the top of the feed there is a `textarea`), and at the left side there is the navigation of the website. In the navigation there are links to: *Notifications* Page, *Profile* Page, and *Settings* page.

![Profile Page](/images/posts/2020/chapter-2-simple-twitter/twitter-profile-page.webp "Profile Page")
![Profile Page](/posts/2020/chapter-2-simple-twitter/twitter-profile-page.webp "Profile Page")

The Profile page (or timeline) has the same navigation in the left side, but in the right side of the page, instead of the feed, we see at the top the general user information, and under that a tab to see the user tweets by:
- *Tweets* (or timeline): this is all the user tweets in order (recent at the top).
- *Tweets & replies*: this will show all of the user tweets include the tweets that are replies to other users tweets.
- *Media*: Tweets that include some media type (in our case it can include only images).
- *Likes*: Tweets of other users that this users liked.

![Followers & Following Page](/images/posts/2020/chapter-2-simple-twitter/twitter-followers-and-following-page.webp "Followers & Following Page")
![Followers & Following Page](/posts/2020/chapter-2-simple-twitter/twitter-followers-and-following-page.webp "Followers & Following Page")

The Followers and Following Page has the same navigation the left side and the right is the same tab view of the Profile page with 2 lists. The first is users who followers after the current user and the second is a list of users who the current user follows after.

![Tweet Page](/images/posts/2020/chapter-2-simple-twitter/twitter-tweet-page.webp "Tweet Page")
![Tweet Page](/posts/2020/chapter-2-simple-twitter/twitter-tweet-page.webp "Tweet Page")

When the user clicks on a tweet he sees the original tweet (no more information that we didn't show in the Feed or Profile pages), but he sees some general info about the tweet (time of publish) and a list of tweets that replies to that tweet. The user also can click on the `334 Likes` and it'll open a popup with the list of users who liked that tweet (I'll not show a screenshot of this to keep the post lighter and because the list is actually looks the same as the list of Followers & Following).

Expand Down
Loading

0 comments on commit 60f842f

Please sign in to comment.