Giter Club home page Giter Club logo

b1o.co's Introduction

A Full-Stack Rust application where users can vote for their favorite images. Inspired from the Elo rating system used in chess, each image is assigned a rating. A Multi-Layer Feed-Forward Network is then used to analyze voting patterns and image characteristics to predict accurate base rankings for new images.

Warning

At the moment, the API is deployed on render (https://api.b1o.co) which can lead to significant loading times when opening the web-app.

OVERVIEW

CONFIG

Start backend

cargo build

cargo install cargo-make

cargo run --bin backend

OR

cargo make start_back_prod

Start frontend

(npm install)

(npm install -g pnpm)

(npm install -g wasm-pack)

pnpm install --dir ./frontend

pnpm run --dir ./frontend build

pnpm run --dir ./frontend dev

OR

cargo make start_front_prod

OR

simple-http-server ./frontend/dist -i -p 8000 --nocache --try-file ./frontend/dist/index.html

[!NOTE] You might have to Set-ExecutionPolicy RemoteSigned to run pnpm commands on Windows.

RUNNING ON DOCKER

First install Docker and docker-compose. You can find instructions here and here.

In theory it would be sufficient to run docker-compose up and, once everything is up and running, visit http://localhost:3000 to view the app.

Note

docker-compose will start the app in production mode.

To push to your remote docker-repository run:

docker-compose up
docker tag b1o-backend:latest <docker-username>/<docker-repository>:backend
docker tag b1o-frontend:latest <docker-username>/<docker-repository>:frontend
docker push <docker-username>/<docker-repository>:backend
docker push <docker-username>/<docker-repository>:frontend

RUNNING OUTSIDE DOCKER

Database Setup

Make sure to have a Postgres database with all read and write priviledges running.

Example:

sudo -u postgres psql
create database b1o;
create user coreuser with encrypted password 'password';
grant all privileges on database b1o to coreuser;
exit

Note

If you get an error message saying "connection refused", your postgres server may have installed on port 5433 rather than the default 5432. To resolve this, try using the -p flag as follows:

sudo -u postgres psql -p 5433

ENV file

You'll need a .env file to hold necessary environment variables. If you're running docker, it should be named docker.env and contain the following:

FRONTEND_HOST=localhost
FRONTEND_PORT=3000
FRONTEND_PROTOCOL=http

DATABASE_PROTOCOL=postgres
DATABASE_PORT=5432
DATABASE_URL=<SECRET>
POSTGRES_USER=<SECRET>
POSTGRES_PASSWORD=<SECRET>
POSTGRES_DB=<SECRET>
POSTGRES_HOST=<SECRET>

BACKEND_HOST=localhost
BACKEND_HOST_INTERNAL=0.0.0.0
BACKEND_PORT=8080
BACKEND_PROTOCOL=http

MONGO_URL=<SECRET>
MONGO_COLLECTION=<SECRET>

Running the App

Cargo Make as a task running to simplify starting and stopping the application. To use cargo make, run cargo install cargo-make.

To start the application in development mode, run cargo make start_all.

To start the application in production mode, run cargo make start_all_prod.

Note

On Windows, you might see the following error:

<e> [webpack-dev-middleware] Error: spawn npm ENOENT
<e>     at ChildProcess._handle.onexit (node:internal/child_process:285:19)
<e>     at onErrorNT (node:internal/child_process:483:16)
<e>     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
<e>   errno: -4058,
<e>   code: 'ENOENT',
<e>   syscall: 'spawn npm',
<e>   path: 'npm',
<e>   spawnargs: [ 'install', '-g', 'wasm-pack' ]
<e> }

If you get this error, run the following command and then try again:

npm install -g wasm-pack

To view all the available tasks, open Makefile.toml.

CONTRIBUTING

If you find any bugs or have suggestions for improvement, please open a new issue or submit a pull request.

LICENSE

This project is licensed under the GPL-3.0 license. See the LICENSE file for details.

Note

The general concept has been inspired by this and this article.


© Carlo Bortolan

Carlo Bortolan  ·  GitHub carlobortolan  ·  contact via [email protected]

b1o.co's People

Contributors

carlobortolan avatar

Watchers

 avatar

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.