neon_arch commited on
Commit
e6c956f
β€’
1 Parent(s): a6383ee

πŸ“ docs: add a new development guide page (#340)

Browse files
Files changed (1) hide show
  1. docs/developing.md +629 -0
docs/developing.md ADDED
@@ -0,0 +1,629 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Developing
2
+
3
+ This page of the docs outlines how to get **Websurfx** up and running in a development environment, and outlines the common worflow, different ways to work on the project, a high level overview of how the project works, project structure and the best pratices that should be followed when working on the project.
4
+
5
+ <details>
6
+ <summary><b>Table of Contents</b></summary>
7
+ <p>
8
+
9
+ - [Setting up the Development Environment](#setting-up-the-development-environment)
10
+ - [Local Development](#local-development-)
11
+ - [Gitpod](#gitpod-)
12
+ - [NixOS Dev Shell using Nix Flake](#nixos-dev-shell-using-nix-flake-)
13
+ - [Local Development with Docker Compose](#local-development-with-docker-compose-)
14
+ - [Project Commands](#project-commands)
15
+ - [Environmental Variables](#environmental-variables)
16
+ - [Git Strategy](#git-strategy)
17
+ - [Flow](#git-flow)
18
+ - [Branches](#git-branch-naming)
19
+ - [Commit emojis](#commit-emojis)
20
+ - [PR Guidelines](#pr-guidelines)
21
+ - [Resources for Beginners](#resources-for-beginners)
22
+ - [App Info](#app-info)
23
+ - [Code Style Guide](#style-guide)
24
+ - [Application Structure](#application-structure)
25
+ - [Development Tools](#development-tools)
26
+ - [Misc / Notes](#notes)
27
+
28
+ </p>
29
+ </details>
30
+
31
+ ## Setting up the Development Environment
32
+
33
+ By default, we provide four different ways to work on the project. Which are as follows:
34
+
35
+ - [Local Development](#local-development-)
36
+ - [Gitpod](#gitpod-)
37
+ - [NixOS Dev Shell using Nix Flake](#nixos-dev-shell-using-nix-flake-)
38
+ - [Local Development with Docker Compose](#local-development-with-docker-compose-)
39
+
40
+ The diferent methods are explained in depth below.
41
+
42
+ ### Local Development
43
+
44
+ This section covers how to setup the project for development on your local machine (bare metal).
45
+
46
+ #### Prerequisites
47
+
48
+ Before you start working on the project. You will need the following packages installed on your system:
49
+
50
+ - A latest version of `cargo` installed on your system which is required to manage building and running the project. The installation instruction for this can be found [here](https://doc.rust-lang.org/cargo/getting-started/installation.html).
51
+ - A latest version of `npm` installed on your system which is required to allow the installation of other tools necessary for the project. The installation for this can be found [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
52
+ - A latest version of `redis` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation for this can be found [here](https://redis.io/docs/getting-started/installation/).
53
+ - A latest version of `stylelint` should be installed on your system which will be used by the pre-commit checks to lint the code before a commit can be made to ensure better code quality. Before you install `stylelint` on your system, make sure you have `npm` installed on you system. To install `stylelint` run the following command:
54
+
55
+ ```shell
56
+ $ npm i -g stylelint
57
+ ```
58
+
59
+ > **Note**
60
+ > In the above command the dollar sign(**$**) refers to running the command in privilaged mode by using utilities `sudo`, `doas`, `pkgexec` or any other privilage access methods.
61
+
62
+ - `Cargo-watch` installed on your system which will allow to auto build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command:
63
+
64
+ ```shell
65
+ cargo install cargo-watch
66
+ ```
67
+
68
+ - `Git` installed on your system. The installation instruction for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
69
+ - Finally, A latest version of `Docker` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
70
+
71
+ > **Note**
72
+ > For **rolling release linux distributions (distros)**, the above mentioned all required packages except for `stylelint` and `cargo-watch` can also be installed via the distro specific package manager.
73
+ >
74
+ > **For Example:**
75
+ >
76
+ > On `arch linux` the following packages could be installed by following link to the installation instructions provided down below:
77
+ >
78
+ > - `Cargo`: https://wiki.archlinux.org/title/rust
79
+ > - `Npm`: https://wiki.archlinux.org/title/Node.js
80
+ > - `Redis`: https://wiki.archlinux.org/title/redis
81
+ > - `Git`: https://wiki.archlinux.org/title/git
82
+ > - `Docker`: https://wiki.archlinux.org/title/docker
83
+ >
84
+ > But we do not recommend this method for **stable release linux distros** as they tend to not provide very up to date versions of the required packages.
85
+
86
+ #### Setting up Pre-commit Checks
87
+
88
+ Before you setup `pre-commit` checks, you will first need to clone **your fork of the project** and navigate into the cloned repository by running the following command:
89
+
90
+ ```shell
91
+ git clone https://github.com/<your_github_username>/websurfx.git
92
+ cd websurfx
93
+ ```
94
+
95
+ Once you have done finished running the above commands then run the following command to setup the `pre-commit` checks:
96
+
97
+ ```shell
98
+ cargo test
99
+ ```
100
+
101
+ By the running the above mentioned command, it will automatically setup all the pre-commit checks in the project.
102
+
103
+ #### Running the Project
104
+
105
+ If you have followed the above section then you should have a cloned repository folder present on your system. In the same directory run the following command to run the project:
106
+
107
+ ```shell
108
+ cargo watch -q -x "run" -w "."
109
+ ```
110
+
111
+ This will compile the app by default with the **In-Memory caching** feature. To compile, run and test the app with other features then follow the build options listed below:
112
+
113
+ ##### Hybrid Cache
114
+
115
+ To build and run the app with the `Hybrid caching` feature. Run the following command:
116
+
117
+ ```shell
118
+ cargo watch -q -x "run --features redis-cache" -w .
119
+ ```
120
+
121
+ ##### No Cache
122
+
123
+ To build and run the search engine with the `No caching` feature. Run the following command:
124
+
125
+ ```shell
126
+ cargo watch -q -x "run --no-default-features" -w .
127
+ ```
128
+
129
+ ##### Redis Cache
130
+
131
+ To build the search engine with the `Redis caching` feature. Run the following command:
132
+
133
+ ```shell
134
+ cargo watch -q -x "run --no-default-features --features redis-cache" -w .
135
+ ```
136
+
137
+ > Optionally, If you have build and run the app with the `Redis cache`or `Hybrid cache` feature (as mentioned above) then you will need to start the redis server alongside the app which can be done so by running the following command:
138
+ >
139
+ > ```shell
140
+ > redis-server --port 8082 &
141
+ > ```
142
+
143
+ Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to being rebuilt.
144
+
145
+ > For more info on all the project commands. See: [**Project Commands**](#project-commands-)
146
+
147
+ ### Gitpod
148
+
149
+ This section covers on how to use and setup the Gitpod development environment for working on the project.
150
+
151
+ > **Note**
152
+ > By default the project only supports the Vscode **IDE/Editor** for Gitpod.
153
+
154
+ #### Launching Gitpod
155
+
156
+ > For a full guide on how to fork the project. See: [**Forking**](#)
157
+
158
+ To launch gitpod and start working on the project from your fork of the Websurfx, Just navigate to the following link:
159
+
160
+ ```text
161
+ https://gitpod.io/#https://github.com/<your_github_username>/websurfx
162
+ ```
163
+
164
+ > For a full guide on how to use it and how to use it in different ways. See [**Learn Gitpod**](https://piped.kavin.rocks/playlist?list=PL3TSF5whlprXVp-7Br2oKwQgU4bji1S7H)
165
+
166
+ #### Default Plugins
167
+
168
+ The project by default provides a set of pre-installed plugins for gitpod which is done to improve productivity and efficiency while working on the project. Also to make working on the project more fun and engaging which can be customized from within the `Gitpod` instance.
169
+
170
+ The list of all the pre-installed plugins are listed down below:
171
+
172
+ **Productivity**
173
+
174
+ - [CodeLLDB](https://open-vsx.org/extension/vadimcn/vscode-lldb): Provides a native debugger for rust programming langauge.
175
+ - [GitHub Actions](https://open-vsx.org/extension/cschleiden/vscode-github-actions): Provides an easy to work with github actions.
176
+ - [rust-analyzer](https://open-vsx.org/extension/rust-lang/rust-analyzer): Provides a language server for rust programming langauge.
177
+ - [better-toml](https://open-vsx.org/extension/bungcip/better-toml): Provides support for toml files.
178
+ - [crates](https://open-vsx.org/extension/serayuzgur/crates): Makes managing rust dependencies easier.
179
+ - [Error Lens](https://open-vsx.org/extension/usernamehw/errorlens): Provides better highlighting of errors.
180
+ - [markdownlint](https://open-vsx.org/extension/DavidAnson/vscode-markdownlint): Provides a linter for linting markdown documents.
181
+ - [Prettier](https://open-vsx.org/extension/esbenp/prettier-vscode): Provides a code formatter.
182
+ - [Stylelint](https://open-vsx.org/extension/stylelint/vscode-stylelint): Provides a linter for CSS files.
183
+ - [ESLint](https://open-vsx.org/extension/dbaeumer/vscode-eslint): Provides a linter for JS files.
184
+ - [Syntax Highlighter](https://open-vsx.org/extension/evgeniypeshkov/syntax-highlighter): A better syntax highlighting for code.
185
+ - [Docker](https://open-vsx.org/extension/ms-azuretools/vscode-docker): Makes handling docker files easier.
186
+ - [indent-rainbow](https://open-vsx.org/extension/oderwat/indent-rainbow): Highlightes code idents for better visualization.
187
+ - [Auto Rename Tag](https://open-vsx.org/extension/formulahendry/auto-rename-tag): Provides a way to easily and quickly rename html tags.
188
+ - [Rust Test Explorer](https://open-vsx.org/extension/Swellaby/vscode-rust-test-adapter): View and run cargo tests easily from a convenient sidebar.
189
+ - [Search crates-io](https://open-vsx.org/extension/belfz/search-crates-io): Provides crates suggestions in the `cargo.toml` file.
190
+ - [Test Adapter Converter](https://open-vsx.org/extension/hbenl/test-adapter-converter): A vscode native way to view and run tests.
191
+ - [Test Explorer UI](https://open-vsx.org/extension/hbenl/vscode-test-explorer): Provides a way to run any test from a convenient sidebar.
192
+ - [GitLens](https://open-vsx.org/extension/eamodio/gitlens): Provides a better and more efficient way to manage common git workflows.
193
+
194
+ > Optionally, if you prefer more keyboard centric workflow then we would recommend using the following extension:
195
+ >
196
+ > - [VSCode Neovim](https://open-vsx.org/extension/asvetliakov/vscode-neovim): Provides complete vim emulation for vscode.
197
+
198
+ **Theming**
199
+
200
+ - [Catppuccin for VSCode](https://open-vsx.org/extension/Catppuccin/catppuccin-vsc): Provides the catpuccin theme for vscode.
201
+ - [Material Icon Theme](https://open-vsx.org/extension/PKief/material-icon-theme): Provides material design icons for files dependening on the file extension.
202
+
203
+ > If you have more ideas and ways to improve Gitpod for development purposes then feel free to do so by contributing a PR to this project [**here**](https://github.com/neon-mmd/websurfx/pulls).
204
+
205
+ ### NixOS Dev Shell using Nix Flake
206
+
207
+ This section covers on how to setup the project for development using the `NixOS dev-shell`.
208
+
209
+ #### Pre Setup Requirements
210
+
211
+ Before you start working on the project. You will need the following packages installed on your system:
212
+
213
+ - `Git` installed on your system. The installation instruction for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
214
+ - Finally, A latest version of `Docker` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
215
+
216
+ > Optionally, On `NixOS` the above mentioned all required packages except for `stylelint` and `cargo-watch` could also be installed by following link to the installation instructions provided down below:
217
+ >
218
+ > - `Git`: https://search.nixos.org/packages?channel=23.05&show=git&from=0&size=50&sort=relevance&type=packages&query=git
219
+ > - `Docker`: https://search.nixos.org/packages?channel=23.05&show=docker&from=0&size=50&sort=relevance&type=packages&query=docker
220
+
221
+ #### Setting up Pre-commit Checks
222
+
223
+ Before you setup `pre-commit` checks, you will first need to clone **your fork of the project** and navigate into the cloned repository by running the following command:
224
+
225
+ ```shell
226
+ git clone https://github.com/<your_github_username>/websurfx.git
227
+ cd websurfx
228
+ ```
229
+
230
+ Then run the following command to setup the `NixOS dev-shell`:
231
+
232
+ ```shell
233
+ nix develop
234
+ ```
235
+
236
+ Once you have done finished running the above commands then run the following command to setup the `pre-commit` checks:
237
+
238
+ ```shell
239
+ cargo test
240
+ ```
241
+
242
+ By the running the above mentioned command, it will automatically setup all the pre-commit checks in the project.
243
+
244
+ #### Post Setup Requirements
245
+
246
+ After you have done setting up pre-commit checks, then you may need to fullfill a few more requirements to finish setting up the development environment with `NixOS dev-shell`. These include:
247
+
248
+ - `Cargo-watch` installed on your system which will allow to auto build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command:
249
+
250
+ ```shell
251
+ cargo install cargo-watch
252
+ ```
253
+
254
+ #### Running the Project
255
+
256
+ If you have followed the above section then you should now be inside a `dev-shell` environment. In the same environment run the following command to run the project:
257
+
258
+ ```shell
259
+ cargo watch -q -x "run" -w "."
260
+ ```
261
+
262
+ This will compile the app by default with the **In-Memory caching** feature. To compile, run and test the app with other features then follow the build options listed below:
263
+
264
+ ##### Hybrid Cache
265
+
266
+ To build and run the app with the `Hybrid caching` feature. Run the following command:
267
+
268
+ ```shell
269
+ cargo watch -q -x "run --features redis-cache" -w .
270
+ ```
271
+
272
+ ##### No Cache
273
+
274
+ To build and run the search engine with the `No caching` feature. Run the following command:
275
+
276
+ ```shell
277
+ cargo watch -q -x "run --no-default-features" -w .
278
+ ```
279
+
280
+ ##### Redis Cache
281
+
282
+ To build the search engine with the `Redis caching` feature. Run the following command:
283
+
284
+ ```shell
285
+ cargo watch -q -x "run --no-default-features --features redis-cache" -w .
286
+ ```
287
+
288
+ > Optionally, If you have build and run the app with the `Redis cache`or `Hybrid cache` feature (as mentioned above) then you will need to start the redis server alongside the app which can be done so by running the following command:
289
+ >
290
+ > ```shell
291
+ > redis-server --port 8082 &
292
+ > ```
293
+
294
+ Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to being rebuilt.
295
+
296
+ ### Local Development with Docker Compose
297
+
298
+ This section covers how to setup the project for development on your local machine (bare metal) using `docker compose`.
299
+
300
+ #### Prerequisites
301
+
302
+ Before you start working on the project. You will need the following packages installed on your system:
303
+
304
+ - A latest version of `cargo` installed on your system which is required to manage building and running the project. The installation instruction for this can be found [here](https://doc.rust-lang.org/cargo/getting-started/installation.html).
305
+ - A latest version of `npm` installed on your system which is required to allow the installation of other tools necessary for the project. The installation for this can be found [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
306
+ - A latest version of `stylelint` should be installed on your system which will be used by the pre-commit checks to lint the code before a commit can be made to ensure better code quality. Before you install `stylelint` on your system, make sure you have `npm` installed on you system. To install `stylelint` run the following command:
307
+
308
+ ```shell
309
+ $ npm i -g stylelint
310
+ ```
311
+
312
+ > **Note**
313
+ > In the above command the dollar sign(**$**) refers to running the command in privilaged mode by using utilities `sudo`, `doas`, `pkgexec` or any other privilage access methods.
314
+
315
+ - `Git` installed on your system. The installation instruction for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
316
+ - Finally, A latest version of `Docker` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
317
+
318
+ > **Note**
319
+ > For **rolling release linux distributions (distros)**, the above mentioned all required packages can also be installed via the distro specific package manager.
320
+ >
321
+ > **For Example:**
322
+ >
323
+ > On `arch linux` the following packages could be installed by following link to the installation instructions provided down below:
324
+ >
325
+ > - `Cargo`: https://wiki.archlinux.org/title/rust
326
+ > - `Npm`: https://wiki.archlinux.org/title/Node.js
327
+ > - `Git`: https://wiki.archlinux.org/title/git
328
+ > - `Docker`: https://wiki.archlinux.org/title/docker
329
+ >
330
+ > But we do not recommend this method for **stable release linux distros** as they tend to not provide very up to date versions of the required packages.
331
+
332
+ #### Setting up Pre-commit Checks
333
+
334
+ Before you setup `pre-commit` checks, you will first need to clone **your fork of the project** and navigate into the cloned repository by running the following command:
335
+
336
+ ```shell
337
+ git clone https://github.com/<your_github_username>/websurfx.git
338
+ cd websurfx
339
+ ```
340
+
341
+ Once you have done finished running the above commands then run the following command to setup the `pre-commit` checks:
342
+
343
+ ```shell
344
+ cargo test
345
+ ```
346
+
347
+ By the running the above mentioned command, it will automatically setup all the pre-commit checks in the project.
348
+
349
+ #### Running the Project
350
+
351
+ If you have followed the above section then you should have a cloned repository folder present on your system. In the same directory, edit the `dev.docker-compose.yml` file as required before running the following command to run the project:
352
+
353
+ ```shell
354
+ $ docker compose -f dev.docker-compose.yml up
355
+ ```
356
+
357
+ > **Note**
358
+ > In the above command the dollar sign(**$**) refers to running the command in privilaged mode by using utilities `sudo`, `doas`, `pkgexec` or any other privilage access methods.
359
+
360
+ Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to being rebuilt.
361
+
362
+ ### Project Commands
363
+
364
+ #### Basics
365
+
366
+ - `cargo build`: Builds the project.
367
+
368
+ > **Note**
369
+ > When you build the project first time with the above command it will require the app to compile every dependency in the project which will then be cached on your system. So when you compile the app next time it will only compile for the new changes.
370
+
371
+ - `cargo run`: Starts the app and serves the project on http://127.0.0.1:8080.
372
+
373
+ > **Important**
374
+ > You must run the build command first.
375
+
376
+ #### Development
377
+
378
+ - `cargo watch -q -x "run" -w .`: Starts the development server with hot reloading.
379
+ - `cargo fmt -- --check`: Checks the code for proper formatting.
380
+ - `cargo clippy`: Lints code to ensure it follows a consistent, neat style.
381
+ - `cargo test`: Runs unit tests, integrations tests and doc tests.
382
+
383
+ ### Environment Variables
384
+
385
+ All environmental variables are optional. Currently there are not many environmental variables used, as most of the user preferences are stored under the `websurfx` folder (located under the codebase (`websurfx` directory)) in the `config.lua` file.
386
+
387
+ The list of all the available environment variables are listed down below:
388
+
389
+ - `PKG_ENV`: Sets the logging level for the app to **Trace** which can be useful for better debugging of the app. This environment variables accept two values `dev` or `prod` as strings.
390
+ - `RUST_BACKTRACE`: Rust specific environment variable useful for getting more elaborate error messages with an error stack to better diagnose the issue. This environment variable accepts three values `0` (off), `1` (on) and `full` (for long error stack to being printed out).
391
+
392
+ ## Git Strategy
393
+
394
+ ### Git Flow
395
+
396
+ Like most Git repos, we are following the [Github Flow](https://guides.github.com/introduction/flow) standard.
397
+
398
+ 1. Create a branch (or fork if you don'd have write access)
399
+ 2. Code some awesome stuff πŸ§‘β€πŸ’»
400
+ 3. Add, commit and push your changes to your branch/ fork
401
+ 4. Head over to GitHub and create a Pull Request
402
+ 5. Fill in the required sections in the template, and hit submit
403
+ 6. Follow up with any reviews on your code
404
+ 7. Merge πŸŽ‰
405
+
406
+ ### Git Branch Naming
407
+
408
+ The format of your branch name should be something similar to: `[TYPE]/[TICKET]_[TITLE]`
409
+ For example, `FEATURE/420_Awesome-feature` or `FIX/690_login-server-error`
410
+
411
+ ### Commit Emojis
412
+
413
+ Using a single emoji at the start of each commit message, issue title, and pull request title, to indicate the type task, makes the commit ledger, issue and pull request easier to understand, plus it looks cool.
414
+
415
+ - 🎨 `:art:` - Improve structure / format of the code.
416
+ - ⚑️ `:zap:` - Improve performance.
417
+ - πŸ”₯ `:fire:` - Remove code or files.
418
+ - πŸ› `:bug:` - Fix a bug.
419
+ - πŸš‘οΈ `:ambulance:` - Critical hotfix
420
+ - ✨ `:sparkles:` - Introduce new features.
421
+ - πŸ“ `:memo:` - Add or update documentation.
422
+ - πŸš€ `:rocket:` - Deploy stuff.
423
+ - πŸ’„ `:lipstick:` - Add or update the UI and style files.
424
+ - πŸŽ‰ `:tada:` - Begin a project.
425
+ - βœ… `:white_check_mark:` - Add, update, or pass tests.
426
+ - πŸ”’οΈ `:lock:` - Fix security issues.
427
+ - πŸ”– `:bookmark:` - Make a Release or Version tag.
428
+ - 🚨 `:rotating_light:` - Fix compiler / linter warnings.
429
+ - 🚧 `:construction:` - Work in progress.
430
+ - ⬆️ `:arrow_up:` - Upgrade dependencies.
431
+ - πŸ‘· `:construction_worker:` - Add or update CI build system.
432
+ - ♻️ `:recycle:` - Refactor code.
433
+ - 🩹 `:adhesive_bandage:` - Simple fix for a non-critical issue.
434
+ - πŸ”§ `:wrench:` - Add or update configuration files.
435
+ - 🍱 `:bento:` - Add or update assets.
436
+ - πŸ—ƒοΈ `:card_file_box:` - Perform database schema related changes.
437
+ - ✏️ `:pencil2:` - Fix typos.
438
+ - 🌐 `:globe_with_meridians:` - Internationalization and translations.
439
+
440
+ For a full list of options, see [gitmoji.dev](https://gitmoji.dev/)
441
+
442
+ ### PR Guidelines
443
+
444
+ Once you've made your changes, and pushed them to your fork or branch, you're ready to open a pull request!
445
+
446
+ For a pull request to be merged, it must:
447
+
448
+ - The build, lint and tests (run by GH actions) must pass
449
+ - There must not be any merge conflicts
450
+
451
+ When you submit your pull request, include the required info, by filling out the pull request template. Including:
452
+
453
+ - A brief description of your changes.
454
+ - The issue or ticket number (if applicable).
455
+ - For UI related updates include a screenshot.
456
+ - If any dependencies were added, explain why it was needed, state the cost. associated, and confirm it does not introduce any security, privacy or speed issues
457
+ - Optionally, provide a checklist of all the changes that was included in the pull request.
458
+
459
+ > **Important**
460
+ > Make sure to fill all the required/mandatory sections of the pull request as by filling them it helps us distinguish between spam pull requests and legitimate pull requests.
461
+
462
+ > **Note**
463
+ > The pull request template contains comments in the following form `<!-- -->` which are used to provide a guide on what should be provided under each heading of the template. These comments are never rendered when the pull request is either created or updated and hence anything provided in such comments is never displayed.
464
+
465
+ ## Resources for Beginners
466
+
467
+ New to Web Development? Or New to GitHub? Glad to see you're here!! :slightly_smiling_face: Websurfx is a pretty simple app, so it should make a good candidate for your first PR. The following articles (which has been divided into parts for convenience) should point you in the right direction for getting up to speed with the technologies used in this project:
468
+
469
+ **Development**
470
+
471
+ - [Basics of Rust](https://piped.kavin.rocks/playlist?list=PLai5B987bZ9CoVR-QEIN9foz4QCJ0H2Y8)
472
+ - [Introduction and deep dive into async/await in rust](https://piped.kavin.rocks/watch?v=ThjvMReOXYM)
473
+ - [Getting Started to Actix Guide](https://actix.rs/docs/getting-started)
474
+ - [Basics of Lua](https://learn.coregames.com/courses/intro-to-lua/)
475
+ - [Complete course on CSS](https://piped.kavin.rocks/watch?v=1Rs2ND1ryYc)
476
+ - [Complete course on JS](https://piped.kavin.rocks/playlist?list=PL_c9BZzLwBRLVh9OdCBYFEql6esA6aRsi)
477
+ - [Responsive web design](https://piped.kavin.rocks/watch?v=srvUrASNj0s)
478
+ - [Complete beginners guide to Docker](https://docker-curriculum.com/)
479
+ - [Docker Classroom - Interactive Tutorials](https://training.play-with-docker.com/)
480
+ - [Docker Compose Tutorial](https://docs.docker.com/compose/gettingstarted/)
481
+ - [ES6 Tutorial](https://piped.kavin.rocks/watch?v=nZ1DMMsyVyI)
482
+ - [Cargo Guide Book](https://doc.rust-lang.org/cargo/index.html)
483
+
484
+ **GitHub**
485
+
486
+ - [Complete Guide to Open Source - How to Contribute](https://piped.kavin.rocks/watch?v=yzeVMecydCE)
487
+ - [Forking a Project](https://piped.kavin.rocks/watch?v=FnxFwyzm4Z4)
488
+ - [A Tutorial on Git](https://piped.kavin.rocks/playlist?list=PL4lTrYcDuAfxAgSefXftJXbhw0qvjfOFo)
489
+ - [Git cheat sheet](http://git-cheatsheet.com/)
490
+
491
+ For Rust, CSS, JS, Html, Git and Docker- you'll need an IDE (e.g. [VSCode](https://code.visualstudio.com/) or [Neovim](https://neovim.io/) and a terminal (Windows users may find [WSL](https://docs.microsoft.com/en-us/windows/wsl/) more convenient).
492
+
493
+ ## App Info
494
+
495
+ ### Style Guides
496
+
497
+ Linting is done using [Cargo Clippy](https://doc.rust-lang.org/clippy/) and [StyleLint](https://stylelint.io/) or [ESLint](https://eslint.org/). Also, linting is run as a git pre-commit hook.
498
+
499
+ > **Important**
500
+ > All lint checks must pass before any PR can be merged.
501
+
502
+ Styleguides to follow:
503
+
504
+ - [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/naming.html)
505
+ - [Airbnb JS Guidelines](https://github.com/airbnb/javascript)
506
+ - [Google's Html and CSS Guidelines](https://google.github.io/styleguide/htmlcssguide.html)
507
+
508
+ ## Application Structure
509
+
510
+ > **Important**
511
+ > We follow the unix style naming conventions for all the file and folders in the project (except for all files under the `themes` and `colorschemes` folder in the frontend's source code which requires that the names of the files and folders should be in lowercase and the words be seperated with a hyphen.) which includes the name of the files and folders should be in lowercase and every word should be seperated with an underscore.
512
+
513
+ **Files in the root of the codebase:** `./`
514
+
515
+ ```
516
+ ./
517
+ β”œβ”€β”€ .dockerignore # Docker ignore file to ignore stuff being included in the file docker image.
518
+ β”œβ”€β”€ .gitignore # Git ignore file to ignore stuff from being
519
+ β”œβ”€β”€ Cargo.lock # Auto-generated list of current packages and version numbers.
520
+ β”œβ”€β”€ Cargo.toml # Project meta-data and dependencies.
521
+ β”œβ”€β”€ Dockerfile # The blueprint for building the Docker container.
522
+ β”œβ”€β”€ LICENSE # License for use.
523
+ β”œβ”€β”€ README.md # Readme, basic info for getting started.
524
+ β”œβ”€β”€ dev.Dockerfile # The blueprint for building the Docker container for development purposes.
525
+ β”œβ”€β”€ dev.docker-compose.yml # A Docker run command for development environments.
526
+ β”œβ”€β”€ docker-compose.yml # A Docker run command.
527
+ β”œβ”€β”€ flake.lock # NixOS auto-generated flake configuration.
528
+ β”œβ”€β”€ flake.nix # Nix flake package configuration.
529
+ β”œβ”€β”€ docs # Markdown documentation
530
+ β”œβ”€β”€ public # Project front-end source code
531
+ β”œβ”€β”€ src # Project back-end source code
532
+ β”œβ”€β”€ tests # Project integration tests for the back-end source code.
533
+ └── websurfx # Project folder containing config files for the app.
534
+ ```
535
+
536
+ **Frontend Source:** `./public/`
537
+
538
+ ```
539
+ ./public/
540
+ β”œβ”€β”€ robots.txt # Robots file for the Website.
541
+ β”œβ”€β”€ images # Images for the Website.
542
+ β”œβ”€β”€ static # The directory containing all the UI handlers.
543
+ β”‚ β”œβ”€β”€ cookies.js # Handles the loading of saved cookies.
544
+ β”‚ β”œβ”€β”€ error_box.js # Handles the toggling functionality of the error box on the search page.
545
+ β”‚ β”œβ”€β”€ index.js # Functions to handle the searching functionality of the search bar.
546
+ β”‚ β”œβ”€β”€ pagination.js # Functions to handle the navigation between previous and next page in the search page.
547
+ β”‚ β”œβ”€β”€ search_area_options.js # Changes the search options under the search bar in the search page according to the safe search level set using the url safesearch parameter.
548
+ β”‚ β”œβ”€β”€ settings.js # Handles the getting and saving of all the settings page options as a cookie.
549
+ β”‚ β”œβ”€β”€ colorschemes # A folder containing all the popular colorscheme files as CSS files.
550
+ β”‚ └── themes # A folder containing all the popular theme files as CSS files.
551
+ └── templates # Folder containing all the template files for the different pages on the website.
552
+ β”œβ”€β”€ 404.html # A 404 page template.
553
+ β”œβ”€β”€ about.html # An about page template.
554
+ β”œβ”€β”€ bar.html # A template for the search bar.
555
+ β”œβ”€β”€ cookies_tab.html # A template for the cookies tab for the settings page.
556
+ β”œβ”€β”€ engines_tab.html # A template for the engines tab for the settings page.
557
+ β”œβ”€β”€ footer.html # A footer template for all page.
558
+ β”œβ”€β”€ general_tab.html # A template for the general tab for the settings page.
559
+ β”œβ”€β”€ header.html # A header template for all page.
560
+ β”œβ”€β”€ index.html # A home page template.
561
+ β”œβ”€β”€ navbar.html # A navbar template for the header template.
562
+ β”œβ”€β”€ search.html # A search page template.
563
+ β”œβ”€β”€ search_bar.html # A search bar template specifically for the search page.
564
+ β”œβ”€β”€ settings.html # A settings page template.
565
+ └── user_interface_tab.html # A template for the user interface tab for the settings page.
566
+ ```
567
+
568
+ **Backend Source:** `./src/`
569
+
570
+ ```
571
+ ./src/
572
+ β”œβ”€β”€ lib.rs # A library file for the rust project.
573
+ β”œβ”€β”€ bin # A folder containing the source code that would produce the binary file when compiled.
574
+ β”‚ └── websurfx.rs # A file that would be compiled into binary file.
575
+ β”œβ”€β”€ cache # A folder that contains code to handle the caching functionality of the search engine.
576
+ β”‚ β”œβ”€β”€ cacher.rs # Handles the different caching features.
577
+ β”‚ β”œβ”€β”€ error.rs # Provides custom error messages for different types of caches and their related errors.
578
+ β”‚ β”œβ”€β”€ mod.rs # A module file for the rust project.
579
+ β”‚ └── redis_cacher.rs # Provides custom asynchronous pool implementation with auto background reconnection functionality.
580
+ β”œβ”€β”€ config # A folder that holds the code to help parse the lua config file that would be used in the app.
581
+ β”‚ β”œβ”€β”€ mod.rs # A module file for the rust project.
582
+ β”‚ └── parser.rs # Provides the code to parse the config file.
583
+ β”œβ”€β”€ engines # A folder that holds code to handle fetching data from different upstream engines.
584
+ β”‚ β”œβ”€β”€ brave.rs # Provides code to fetch and remove unnecessary or waste results from the fetched results from the brave search engine.
585
+ β”‚ β”œβ”€β”€ duckduckgo.rs # Provides code to fetch and remove unnecessary or waste results from the fetched results from the duckduckgo search engine.
586
+ β”‚ β”œβ”€β”€ mod.rs # A module file for the rust project.
587
+ β”‚ β”œβ”€β”€ search_result_parser.rs # Provides helper function to help ease the process of defining different result selection selectors.
588
+ β”‚ └── searx.rs # Provides code to fetch and remove unnecessary or waste results from the fetched results from the searx engine.
589
+ β”œβ”€β”€ handler # A folder that provides helper code to provide a proper path to the public (theme) folder, config file, blocklist file and allowlist file based on where they are located.
590
+ β”‚ β”œβ”€β”€ mod.rs # A module file for the rust project.
591
+ β”‚ └── paths.rs # Provides helper code to handle different paths.
592
+ β”œβ”€β”€ models # A folder that provides different models for the different modules in the backend code.
593
+ β”‚ β”œβ”€β”€ aggregation_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "results" module code.
594
+ β”‚ β”œβ”€β”€ engine_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "engines" module code.
595
+ β”‚ β”œβ”€β”€ mod.rs # A module file for the rust project.
596
+ β”‚ β”œβ”€β”€ parser_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "config" module code.
597
+ β”‚ └── server_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "server" module code.
598
+ β”œβ”€β”€ results # A folder that provides code to handle the feching and aggregating of results from the upstream search engines.
599
+ β”‚ β”œβ”€β”€ aggregator.rs # Provides code aggregate and fetch results from the upstream engines.
600
+ β”‚ β”œβ”€β”€ mod.rs # A module file for the rust project.
601
+ β”‚ └── user_agent.rs # Provides a helper function to provide random user-agents to pass in the server request code to improve user privacy and avoiding detected as a bot.
602
+ └── server # A folder that holds code to handle the routes for the search engine website.
603
+ β”œβ”€β”€ mod.rs # A module file for the rust project.
604
+ β”œβ”€β”€ router.rs # Provides functions to handle the different routes on the website.
605
+ └── routes # A folder that contains code to handle the bigger route for the website.
606
+ β”œβ”€β”€ mod.rs # A module file for the rust project.
607
+ └── search.rs # Provides the function to handle the search route.
608
+ ```
609
+
610
+ ## Development Tools
611
+
612
+ ### Performance - Lighthouse
613
+
614
+ The easiest method of checking performance is to use Chromium's build in auditing tool, Lighthouse. To run the test, open Developer Tools (usually F12) --> Lighthouse and click on the 'Generate Report' button at the bottom.
615
+
616
+ ## Notes
617
+
618
+ ### Known warnings
619
+
620
+ When running the build command, a warning appear. These is not an error, and do not affect the security or performance of the application. They will be addressed soon in a future update.
621
+
622
+ ```shell
623
+ warning: the following packages contain code that will be rejected by a future version of Rust: html5ever v0.23.0
624
+ note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`
625
+ ```
626
+
627
+ These warning just means that any dependencies or code using the `html5ever` code would be deprecated and rejected in the futures versions of the rust lanaguage. So right now these dependencies can be used as these has not happened yet.
628
+
629
+ [⬅️ Go back to Home](./README.md)