Giter Site home page Giter Site logo

angarsk8 / realtime-todo-app Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 5.0 3.51 MB

Realtime Todo application developed with Kemal, React, ES2015 and PostgreSQL

Home Page: https://kemal-ws-react-pg-todo.herokuapp.com/

License: MIT License

Crystal 24.56% CSS 12.21% JavaScript 59.37% HTML 3.85%
kemal ecmascript2015 react realtime docker postgresql crystal

realtime-todo-app's Introduction

Todo Basic App (Crystal - Kemal - WebSockets - React - PostgreSQL - Docker)

Requirements

  • Crystal 0.18.7
  • PostgreSQL (v9.5.2)
  • Node (v5.11.1)
  • NPM (v3.8.6)
  • Docker (v1.12.1) && Docker-Compose (v1.8.0)

*Node and NPM are both optional if you are just going to run the app, but necessary for development since they are needed to run webpack

Manual Installation

Before you can run this program you have to install the packages that it uses. You do that with $ shards install . You also need to configure the path to the PostgreSQL database in the files src/db/init_db.cr and src/app.cr

# src/db/init_db.cr
require "pg"

# Configure these two variables
DB_NAME = "db_name"
PG_PATH = "postgres://user:password@localhost:5432"

...
# src/app.cr
require "kemal"
require "pg"

require "./app/models/*"

public_folder "src/public"

# Configure the path of the database based on what you did in the src/db/init_db.cr file
DB_PATH = "postgres://user:password@localhost:5432"
...

Once you have installed the dependencies and configured the database path, you need to create the actual database and table for the application. You do that by running $ crystal src/db/init_db.cr.

Run Project

You can run this program in two ways:

  1. Compile/build the project using the command line with $ crystal build src/notes.cr --release and run the executable $ ./notes
  2. Run the program with $ crystal src/notes.cr (no compilation required)

Once you have run the program, you can open a browser window at localthost:3000 and see the actual app. You can open the app in several browser windows and see how they change in real time via websockets. In the first option you can also pass the port number as an argument to the program, like this ./notes --port <port-number> and the program will show at http://<server-ip-number>:<port-number>.

Installation With Docker

You nee to run one single command: docker-compose up or docker-compose up -d.

Live Demo

You can see and use a live demo of the app here: kemal-ws-react-pg-todo.herokuapp.com.

*Take in mind that this is just a dummy app written in few hours as a proof of concept.

Development

  • $ npm install
  • $ npm run dev && crystal src/notes.cr

realtime-todo-app's People

Contributors

angarsk8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

realtime-todo-app's Issues

error Note.all, self.transform_notes(conn.exec{%{ ), undefined method 'to_hash'

hey as i try to compile i got those errors ,can you please help me to solve them ?

andre@DESKTOP-VH5PTMF:/mnt/c/Users/andre/cr/space$ crystal run src/index.cr --error-trace
Error in src/index.cr:16: instantiating 'Note:Class#all(DB::Database)'

socket.send Note.all(conn).to_json
^~~

in src/models/note.cr:12: instantiating 'Note:Class#transform_notes(DB::ExecResult)'

    self.transform_notes(conn.exec(%{
         ^~~~~~~~~~~~~~~

in src/models/note.cr:52: undefined method 'to_hash' for DB::ExecResult

    notes.to_hash.map do |note|
          ^~~~~~~

================================================================================

DB::ExecResult trace:

src/models/note.cr:51

      def self.transform_notes(notes)

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.