Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mihcaoj/cognitus

Repository files navigation

CognitUs

CognitUs is a real-time collaborative text editor built with the Phoenix Framework.

App Screenshot

Architecture

  • Phoenix LiveView for real-time communication
  • Phoenix Presence for user tracking
  • CRDTs for conflict-free collaborative editing
  • PostgreSQL for document persistence
  • Docker for containerization

Features

  • Real-time collaborative text editing with CRDT to ensure consistency
  • Presence tracking and caret indicators to see the connected users and where they are on the document
  • Persistent document storage using PostgreSQL
  • Docker support for easy deployment

Project Structure

  • /lib - Main application code
  • /config - Configuration files
  • /assets - Frontend assets
  • /priv - Database migrations and static files

Prerequisites

If running with Docker, you will need:

If running on your local machine, you will need to install:

Running with Docker

  1. Clone the repo
git clone https://github.com/mihcaoj/cognitus
cd cognitus
  1. Start the application
docker-compose up --build
  1. Access the application at http://localhost:4000

That's it! The application will automatically:

  • Set up all necessary dependencies
  • Configure the database
  • Start the Phoenix server

When you are done testing, you can do the cleanup (remove all containers, networks and volumes):

docker-compose down -v

Note: To test out the functionalities, you can open up two or more browser windows side to side and try inputting text in one or the other.

Local development setup

  1. Clone the repo
git clone https://github.com/mihcaoj/cognitus
cd cognitus
  1. Make the setup script executable
chmod +x setup.sh
  1. Run the setup script:
./setup.sh
  1. Access the application at http://localhost:4000

Note: To test out the functionalities, you can open up two or more browser windows side to side and try inputting text in one or the other.

Manual Setup (if you prefer not to use the script)

If you prefer to set up manually or the script doesn't work for your environment:

  1. Clone the repo
git clone https://github.com/mihcaoj/cognitus
cd cognitus
  1. Install necessary packages and get the dependencies:
mix local.hex --force
mix local.rebar --force
mix deps.get
  1. Set up environment variables

    3.1 For Unix-Like systems (Linux / MacOS)

    cp .env.example .env && echo SECRET_KEY_BASE=$(mix phx.gen.secret) >> .env

    3.2 For Windows

    3.2.1 Command Prompt:

    copy .env.example .env
    for /f "delims=" %A in ('mix phx.gen.secret') do set SECRET_KEY_BASE=%A && echo SECRET_KEY_BASE=%A>>.env

    3.2.2 Powershell:

    Copy-Item .env.example .env
    $secret = mix phx.gen.secret
    Add-Content .env "SECRET_KEY_BASE=$secret"
  2. Set PostgreSQL default password

    4.1 For Unix-Like systems (Linux / MacOS)

    sudo -u postgres psql
    \password postgres

    4.2 For Windows Powershell:

    psql -U postgres
    \password postgres
  3. Create and migrate the database

mix ecto.create
mix ecto.migrate
  1. Start the Phoenix server
mix phx.server
  1. Access the application at http://localhost:4000

Note: To test out the functionalities, you can open up two or more browser windows side to side and try inputting text in one or the other.

Troubleshooting

  • If the database fails to start, ensure PostgreSQL is not running locally on port 5432
  • If mix commands fail in Docker, ensure you've completed the environment setup
  • For connection issues, verify you're using http://localhost:4000
  • While testing on a linux machine, if you run into a problem with the mint dependency, try: mix deps.get mint hpax

About

A real-time collaborative text editor built with Phoenix.

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •