|
| 1 | +# Contributing Guide |
| 2 | + |
| 3 | +Hi! We're really excited that you are interested in contributing to ADAMANT. Before submitting your contribution, please make sure to take a moment and read through the following guidelines: |
| 4 | + |
| 5 | +- [Pull Request Guidelines](#pull-request-guidelines) |
| 6 | +- [Development Setup](#development-setup) |
| 7 | +- [Scripts](#scripts) |
| 8 | +- [Project Structure](#project-structure) |
| 9 | +- [Financial Contribution](#financial-contribution) |
| 10 | + |
| 11 | +## Pull Request Guidelines |
| 12 | + |
| 13 | +- The `master` branch is just a snapshot of the latest stable release. All development should be done in dedicated branches. Do not submit PRs against the `master` branch. |
| 14 | + |
| 15 | +- Checkout a topic branch from the relevant branch, e.g. `dev`, and merge back against that branch. |
| 16 | + |
| 17 | +- [Make sure to tick the "Allow edits from maintainers" box](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork). This allows us to directly make minor edits / refactors and saves a lot of time. |
| 18 | + |
| 19 | +- If adding a new feature, provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it. |
| 20 | + |
| 21 | +- If fixing a bug: |
| 22 | + |
| 23 | + - If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `update entities encoding/decoding (fix #3899)`. |
| 24 | + - Provide a detailed description of the bug in the PR. |
| 25 | + |
| 26 | +- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging. |
| 27 | + |
| 28 | +- Commit messages must follow the [commit message convention](https://www.conventionalcommits.org/). Commit messages are automatically validated before commit (by invoking Git Hooks). |
| 29 | + |
| 30 | +### Advanced Pull Request Tips |
| 31 | + |
| 32 | +- The PR should fix the intended bug **only** and not introduce unrelated changes. This includes unnecessary refactors - a PR should focus on the fix and not code style, this makes it easier to trace changes in the future. |
| 33 | + |
| 34 | +## Development Setup |
| 35 | + |
| 36 | +You will need [Node.js](https://nodejs.org) **version 20.11+**, [PNPM](https://pnpm.io) **version 9+** and [MongoDB](https://www.mongodb.com/) **version 6+** or Docker Compose. |
| 37 | + |
| 38 | +A high level overview of tools used: |
| 39 | + |
| 40 | +- [TypeScript](https://www.typescriptlang.org/) as the development language |
| 41 | +- [Nest.js](https://nestjs.com/) as the server-side framework |
| 42 | +- [MongoDB](https://www.mongodb.com/) for database |
| 43 | +- [Zod](https://zod.dev/) for validation |
| 44 | +- [Docker](https://www.docker.com/) for production |
| 45 | +- [ESLint](https://eslint.org/) for static error prevention (outside of types) |
| 46 | + |
| 47 | +### Using Docker |
| 48 | + |
| 49 | +Install dependencies: |
| 50 | + |
| 51 | +``` |
| 52 | +pnpm install |
| 53 | +``` |
| 54 | + |
| 55 | +Copy the default config file: |
| 56 | + |
| 57 | +``` |
| 58 | +cp config.default.jsonc config.jsonc |
| 59 | +``` |
| 60 | + |
| 61 | +Run MongoDB with Docker: |
| 62 | + |
| 63 | +``` |
| 64 | +docker compose up |
| 65 | +``` |
| 66 | + |
| 67 | +### Without Docker |
| 68 | + |
| 69 | +Install dependencies: |
| 70 | + |
| 71 | +``` |
| 72 | +pnpm install |
| 73 | +``` |
| 74 | + |
| 75 | +Copy the default config file: |
| 76 | + |
| 77 | +``` |
| 78 | +cp config.default.jsonc config.jsonc |
| 79 | +``` |
| 80 | + |
| 81 | +Install MongoDB and update `server.mongodb` value in `config.jsonc`. For example: |
| 82 | + |
| 83 | +```json |
| 84 | +{ |
| 85 | + "server": { |
| 86 | + "port": 36661, |
| 87 | + "mongodb": { |
| 88 | + "port": 27017, |
| 89 | + "host": "127.0.0.1" |
| 90 | + } |
| 91 | + } |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +## Scripts |
| 96 | + |
| 97 | +- [`npm run start:dev`](#npm-run-start-dev) |
| 98 | + |
| 99 | +### `npm run start:dev` |
| 100 | + |
| 101 | +The `dev` script builds the app in dev mode. This is useful when you want to start the app for quick debugging: |
| 102 | + |
| 103 | +```bash |
| 104 | +$ npm run start:dev |
| 105 | + |
| 106 | +Successfully compiled: 33 files with swc (96.83ms) |
| 107 | +... |
| 108 | +``` |
| 109 | + |
| 110 | +## Project Structure |
| 111 | + |
| 112 | +The source code is located under the `src` directory: |
| 113 | + |
| 114 | +- `main.ts`: Entry point for the app. |
| 115 | + |
| 116 | +- `app.module.ts`: Database connection and modules initialization. |
| 117 | + |
| 118 | +- `shared`: The utilities used across the app. |
| 119 | + |
| 120 | +- `global`: Global modules available that can be used in any part of the app, e.g. logger, config or notifier. |
| 121 | + |
| 122 | +- `rates`: |
| 123 | + |
| 124 | + - `api`: Contains all the API for each of the sources. |
| 125 | + |
| 126 | + - `merger` |
| 127 | + |
| 128 | + - `index`: Module responsible for merging rates from multiple sources and storing them. |
| 129 | + - `strategy`: Exports all implementations of `strategy` configuration. |
| 130 | + |
| 131 | + - `rates.service.ts`: Service for fetching rates from all the available sources. |
| 132 | + |
| 133 | + - `rates.interceptor.ts`: Formats the response of the endpoints. |
| 134 | + |
| 135 | + - `rates.controller.ts`: Links the endpoints with the methods. |
| 136 | + |
| 137 | +## Financial Contribution |
| 138 | + |
| 139 | +We also welcome financial contributions via cryptocurrency. See https://adamant.im/donate. |
0 commit comments