Skip to content

dpytaylo/simple-messenger

Repository files navigation

Simple Messenger

// TODO preview

This is my small pet project aimed at testing my skills in the following areas:

  1. Rust development
  2. Backend development (Axum)
  3. Relation databases (PostgreSQL using SeaORM)
  4. NonSQL databases (Redis)
  5. Frontend (Leptos)

Description

A simple messenger fullstack application fully written in Rust.

User Account:

  1. Account Creation and Login:
  • Users can create accounts and log in using email or Google OAuth2 authentication.
  • User authentication through email and Google OAuth2.
  1. Profile Visibility:
  • All users can view the profiles of other users within the application.
  1. Profile Management:
  • Users have the ability to edit their profiles, updating personal information.
  • Users can delete their accounts.

Channels:

  1. Channel Creation:
  • Users can open or create new channels within the application.
  1. Messaging:
  • Users can send messages to channels.
  • Users receive notifications for messages in channels they are part of.

Dependencies

  1. Rust Nightly (1.77.0-nightly) with necessary tools:
  2. Node JS:
    • npm install -D tailwindcss

Environment

Place your .env file in the current directory before launch.

Note

If a variable has a *_FILE version, either can be used for password storage. If both are used, the version with *_FILE will take priority.

.env

# Optional. Defaults to "127.0.0.1:3000"
LEPTOS_SITE_ADDR = "127.0.0.1:3000"

# Optional. Defaults to "localhost:6379"
REDIS_HOST = "localhost:6379"

REDIS_PASSWORD = "password"
REDIS_PASSWORD_FILE = "./config/secrets/redis_password.txt"

# Optional. Defaults to "localhost:5432"
POSTGRES_HOST = "localhost:5432" 

POSTGRES_PASSWORD = "password"
POSTGRES_PASSWORD_FILE = "./config/secrets/postgres_password.txt"

# This uses Google OAuth2 for redirection to your website
# If you're using different values, don't forget to add them in
# the Authorized Redirect URIs within your Google Console app settings.
REDIRECT_URL = "http://localhost:3000"

# Google API OAuth2
# https://support.google.com/googleapi/answer/6158849
#
# And we need only the "userinfo.email" scope:
# https://developers.google.com/identity/protocols/oauth2/scopes#oauth2
#
# A good visual example of the creation steps in Google Console:
# https://clerk.com/blog/oauth2-react-user-authorization
GOOGLE_CLIENT_ID = "your_code.apps.googleusercontent.com"
GOOGLE_CLIENT_ID_FILE = "./config/secrets/google_client_id_file.txt"
GOOGLE_CLIENT_SECRET = "client_secret"
GOOGLE_CLIENT_SECRET_FILE = "./config/secrets/google_client_secret.txt"

Leptos has its own environment variables that you can modify. You can find more information here.

Execution

Prepare your .env file and place it in the project root directory. Afterward, run this command:

cargo leptos watch

Deployment

To deploy using Docker Compose, you should load your secret tokens. Create the ./config/secrets directory , and create a separate file for each token (for example, ./config/secrets/postgres_password.txt). Place your sensitive data there (e.g., password123). The specific secrets you need to include can be found at the end of the compose.yml file.

Also, create the redis_password.acl file (./config/secrets/redis_password.acl) with following content:

user default on >password ~* &* +@all

Replace password with the value from your redis_password.txt file.

Afterward, simply run the following command:

docker compose up -d

Deployment without Docker Compose

  1. Prepare your .env file and place it in the project's root directory

  2. Run cargo leptos build --release

  3. The minimum files needed for running are:

    • The server binary located in target/server/release
    • The site directory and all files within located in target/site

    Copy these files to your remote server. The directory structure should be:

    simple-messenger
    site/
    

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published