Skip to content

jacktkeys/demo_chat_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEMO CHAT APP

Data Storage

Data storage and retrieval is provided by Postgres. The data is structured in a relational pattern for easy access

  1. Users
    1. ID - GUID
      1. Automatically generated on insert
      2. Primary Key
    2. Username - VARCHAR(100)
      1. Unique constraint
  2. Chatrooms
    1. ID - GUID
      1. Automatically generated on insert
      2. Primary Key
    2. Name - VARCHAR(200)
      1. Unique constraint
    3. Created By - GUID
      1. Foreign Key to Users ID
      2. On delete behavior is set to null
  3. Messages
    1. ID - GUID
      1. Automatically generated on insert
      2. Primary Key
    2. Content - TEXT
      1. Actual text of the message
      2. TEXT data type used so there would be no limit on size of message
    3. Room ID - GUID
      1. Foreign Key to Chatroons ID
      2. On delete behavior is cascade
    4. Created By - GUID
      1. Foreign Key to Users ID
      2. On delete behavior is casecade
    5. Created Date - TIMESTAMP
      1. Datetime when the message was created
      2. Automatically set using now() function on insert
      3. An index is created on this column in descending order to speed up the ORDER BY query

API

API uses the Flask framework to server requests

  1. Flast-Restful
    1. Used to provide a restful interface into the API
    2. HTTP verbs are automatically mapped to functions of the same name
    3. Ability to easily pass parameters into functions
  2. Blueprint
    1. Used for the ability to break the application in modules
    2. Easily maps routes into application code

UI

UI is written using the ReactJS library

  1. Login data is stored in LocalStorage
  2. React state hook is used to trigger data loads and dynamic value changes

Running the app

  1. Each component is built and deployed in its own docker container
  2. Docker-Compose is used to start and orchestrate all three containers
  3. The Postgres container runs on the default port of 5432
  4. The API listens on port 4000
  5. The UI is served on port 3000

Learnings

  1. There was an issue when using docker compose and trying to connect the API to localhost. The following URL describes pretty well what is going on and how to fix it.
  1. It took me a while to find a reference to the hook to use when the Location changes (URL path)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published