Data storage and retrieval is provided by Postgres. The data is structured in a relational pattern for easy access
- Users
- ID - GUID
- Automatically generated on insert
- Primary Key
- Username - VARCHAR(100)
- Unique constraint
- ID - GUID
- Chatrooms
- ID - GUID
- Automatically generated on insert
- Primary Key
- Name - VARCHAR(200)
- Unique constraint
- Created By - GUID
- Foreign Key to Users ID
- On delete behavior is
set to null
- ID - GUID
- Messages
- ID - GUID
- Automatically generated on insert
- Primary Key
- Content - TEXT
- Actual text of the message
- TEXT data type used so there would be no limit on size of message
- Room ID - GUID
- Foreign Key to Chatroons ID
- On delete behavior is
cascade
- Created By - GUID
- Foreign Key to Users ID
- On delete behavior is
casecade
- Created Date - TIMESTAMP
- Datetime when the message was created
- Automatically set using
now()
function on insert - An index is created on this column in descending order to speed up the
ORDER BY
query
- ID - GUID
API uses the Flask framework to server requests
- Flast-Restful
- Used to provide a restful interface into the API
- HTTP verbs are automatically mapped to functions of the same name
- Ability to easily pass parameters into functions
- Blueprint
- Used for the ability to break the application in modules
- Easily maps routes into application code
UI is written using the ReactJS library
- Login data is stored in LocalStorage
- React state hook is used to trigger data loads and dynamic value changes
- Each component is built and deployed in its own docker container
- Docker-Compose is used to start and orchestrate all three containers
- The Postgres container runs on the default port of
5432
- The API listens on port
4000
- The UI is served on port
3000
- 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.
- It took me a while to find a reference to the hook to use when the
Location
changes (URL path)