Giter Site home page Giter Site logo

vimalmahi / chat-room Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paoyong/chat-room

0.0 2.0 0.0 580 KB

Chat room built with Reactjs, backend with nodejs, socket.io, and postgresql.

Home Page: http://chatter.keithy.me/

JavaScript 98.92% CSS 0.67% HTML 0.41%

chat-room's Introduction

Chatter

A minimal real-time chat application using socket.io and React.js.

Try opening two windows at the same time, and chat away!

Stack

Frontend: React.js for databinding, socket.io for POST stuff

Backend: PostgresQL, Node, socket.io for GET stuff

In this case, socket.io replaces the classical ajax POST get for a new chat message. This allows for real time chatting.

Socket.io talks between frontend and backend. Whenever someone sends a chat message, React.js handles that message, and emits a socket message which the server recieves. The server then adds the socket message into the database.

File Structure

public/
..js/
....joinroom.js     <-- React code that renders available rooms to join
....chatroom.js     <-- React code that renders the chat application
....react.js
....JSXTransformer.js
..css/
....style.css       <-- CSS code applied to every view page
views/
..about.jade
..error.jade
..index.jade
..layout.jade
..room.jade
routes/
..chatrooms.js      <-- GET list of chat rooms available to join
..index.js          <-- GET index.jade
..messages.js       <-- GET list of messages from DB for a chat room
..r.js              <-- GET /r/:chatroom
app.js              <-- Node server
db.js               <-- Functions to query postgresql
config.js           <-- Config variables
dbcommands.ql       <-- PostgresQL data definition code

Server-Side Installation

Chatter relies heavily on postgresql, so correct setup for postgres is mandatory. For this application, I used postgres with username postgres and password postgres. You can choose to roll with a diffent username, but I find that doing postgres for both makes it simple.

  1. git clone http://github.com/keithyong/chat-room && npm update

  2. Set up postgresql connection string at config.js

  3. Run dbcommands.sql with the bash command

psql -U postgres -a -f dbcommands.sql
  1. If using a different postgresql username and/or password, update config.js accordingly.

  2. Run node app.js, or use pm2/forever to run it in the background on a server.

chat-room's People

Contributors

paoyong avatar

Watchers

James Cloos avatar Vimal Maheedharan 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.