Giter Site home page Giter Site logo

nice-web's Introduction

Description

This project includes a web server and a web client written in Rust. It created with work, time, and a little bit of rocket, diesel, yew frameworks. As a database for this used a PostgreSQL.

It has the following features:

  • creating an account
  • signing in account
  • creating posts
  • deleting them
  • bookmarking them [to see them first]
  • seeing own posts.

How to Use

Pre-requirements

  • Rust + Cargo
  • Postgres Server
  • trunk (it's needed to build a Rust WASM application)
  • Diesel CLI
  1. Do you have installed PostgreSQL? If not, follow this instructions https://www.postgresql.org/download/
  2. Do you have installed rust, cargo? If not, follow this instructions https://www.rust-lang.org/tools/install
  3. Do you have installed diesel? If not, execute command cargo install diesel_cli --no-default-features --features postgres
  4. Also follow to this install instruction to install trunk for web-client: https://yew.rs/docs/getting-started/introduction#install-webassembly-target

After all

  1. $ git clone https://github.com/DKotov29/nice-web.git
  2. $ cd nice-web/nice-web-backend
  3. Rename .env.template file to .env. In .env file change username, password to yours, and $ diesel_demo to yours database name
  4. $ diesel migration run
  5. $ cd ..
  6. $ cd web-client
  7. $ trunk build
  8. $ cd ..
  9. $ cd nice-web-backend
  10. $ cargo run
  11. profit

How it works

The project was created to provide the following functionality: user account creation and the ability to create and write posts. As stated in the technical specification, the frontend utilizes the Yew framework, while interaction with the database is handled using Diesel. For the backend, Rocket was chosen as the framework. To facilitate communication between the server and client, a decision was made to employ a RESTful API. User authentication is implemented using sessions. Upon logging in, a unique key is generated and added to the cache, which is then used to ensure minimal authorization when accessing protected API endpoints. Posts are delivered in accordance with the project requirements.

Project backend structure includes a "migrations" directory, which houses SQL files responsible for setting up the necessary tables.

In the "src" directory, you'll find the main file, which establishes a connection pool to the database and initiates request handling on mounted paths.

Additionally, there is a "schema" file generated by Diesel, which serves for compile-time correctness checking.

The "controller" directory contains all the files where the server handles incoming requests.

Lastly, the "model" directory is the sole place where the server interacts directly with the database, including session management.

Project client have such structure: The project is built using the Yew framework, which plays a central role in its structure.

The client communicates with the server through a RESTful API. The API module is responsible for handling all interactions with the API. This design choice simplifies the organization of related logic.

Within the project, you'll find a "components" folder housing everything related to the interaction between the user and the business logic.

Additionally, the client stores the session token received from the server in session storage for authentication and security purposes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.