Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "initial commit (#62)" #63

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,23 @@
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Development
/docker/*
!/docker/.gitkeep
!/docker/postgre
.env
access_token.txt
dump.sql

# System Specific
.DS_Store
114 changes: 114 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Contributing to Rust Commune

There are many ways to contribute to Commune Rust, including writing code,
openning issues, helping people, reproduce, or fix bugs that people have filed
and improving documentation.

## Development Environment

Commune Rust is written in The Rust Programming Language, you will have to
setup Rust in your machine to run the project locally.

Tools like [**Justfile**][justfile] are recommended to improve DX and reduce
learning curve by running commands easily.

[docker]: https://www.docker.com/get-started/
[justfile]: https://github.com/casey/just
[rust]: https://rustup.rs


### Getting Started

1. Create a copy of `.env.example` on `.env`

```bash
cp .env.example .env
```

2. Generate `Synapse` server configuration

```bash
just gen_synapse_conf
```

3. Run Synapse Server (and other containerized services) using Docker Compose
via:

```bash
just backend
```

**When you are ready**

Teardown services using `just stop`.
If you want to perform a complete cleanup use `just clear`.

> **Warning** `just clear` will remove all containers and images.

### Testing

This application has 2 layers for tests:

- `Unit`: Are usually inlined inside crates, and dont depend on any integration
- `E2E`: Lives in `test` crate and counts with the services that run the application

#### Unit

Unit tests can be executed via `cargo test -p <crate name>`, this will run
every unit test.

#### E2E

You must run Docker services as for development. In order to avoid messing up
the development environment, its recommended to use the synapse setup from
`crates/test/fixtures/synapse` replacing it with `docker/synapse`.

> Make sure the `.env` file is created from the contents on `.env.example`

### Application Layout

<div align="center">
<img src="./docs/diagrams/diagram.png" />
<small>Application Layout Overview</small>
</div>

The client, any HTTP Client, comunicates with the Commune Server which may or
may not communicate with Matrix's server _Synapse_ which runs along with its
database in a Docker container.

#### Email Development

Use [MJML Editor][mjml] and then render into HTML. Make sure variables use
Handlebars syntax (e.g. `{{name}}`).

For local testing you can use something like:

```bash
curl -s http://localhost:1080/email | grep -o -E "This is your verification code.{0,7}" | tail -1 | sed 's/^.*://' | awk '{$1=$1;print}
```

To get the very last email's verification code.

> **Warning** Note that changes on email content will break this script

[mjml]: https://mjml.io/try-it-live/99k8regCo_

#### Redis

A Redis instance is used to keep in-memory short-lived data used certain server
operations such as storing verification codes.

For this purpose Redis is served as part of the development stack on Docker.

The `redis/redis-stack` image contains both Redis Stack server and RedisInsight,
you can use RedisInsight by pointing your browser to `localhost:8001`.

#### Synapse

There is an official [Synapse][1] image available at https://hub.docker.com/r/matrixdotorg/synapse
or at `ghcr.io/matrix-org/synapse` which can be used with the `docker-compose`
file available at [contrib/docker][2]. Further information on this including
configuration options is available in the README on hub.docker.com.

[1]: https://matrix-org.github.io/synapse/latest/setup/installation.html#docker-images-and-ansible-playbooks
[2]: https://github.com/matrix-org/synapse/tree/develop/contrib/docker
Loading
Loading