CognitUs is a real-time collaborative text editor built with the Phoenix Framework.
- Phoenix LiveView for real-time communication
- Phoenix Presence for user tracking
- CRDTs for conflict-free collaborative editing
- PostgreSQL for document persistence
- Docker for containerization
- 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
/lib- Main application code/config- Configuration files/assets- Frontend assets/priv- Database migrations and static files
If running with Docker, you will need:
- Docker (https://www.docker.com/get-started)
- Docker Compose (https://docs.docker.com/compose/install/) - Usually included with Docker Desktop
If running on your local machine, you will need to install:
- Erlang (https://www.erlang.org/downloads) - Required for Elixir
- Elixir (https://elixir-lang.org/install.html)
- PostgreSQL (https://www.postgresql.org/download/)
- Clone the repo
git clone https://github.com/mihcaoj/cognituscd cognitus- Start the application
docker-compose up --build- 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 -vNote: 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.
- Clone the repo
git clone https://github.com/mihcaoj/cognituscd cognitus- Make the setup script executable
chmod +x setup.sh- Run the setup script:
./setup.sh- 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.
If you prefer to set up manually or the script doesn't work for your environment:
- Clone the repo
git clone https://github.com/mihcaoj/cognituscd cognitus- Install necessary packages and get the dependencies:
mix local.hex --forcemix local.rebar --forcemix deps.get-
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"
-
Set PostgreSQL default password
4.1 For Unix-Like systems (Linux / MacOS)
sudo -u postgres psql
\password postgres4.2 For Windows Powershell:
psql -U postgres\password postgres
-
Create and migrate the database
mix ecto.createmix ecto.migrate- Start the Phoenix server
mix phx.server- 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.
- 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