Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
_build/
priv/attachments/*
_checkouts/
priv/attachments/*
CLAUDE.md
.claude/
*.crashdump
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 27.0.1
rebar 3.23.0
erlang 28.3.1
rebar 3.26.0
23 changes: 10 additions & 13 deletions config/sys.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@
{kernel, [
{logger_level, debug}
]},
{pgo, [
{pools, [
{default, #{
pool_size => 2,
{kura, [
{repos, #{
chatli_repo => #{
backend => kura_backend_postgres,
host => "db",
port => 5432,
database => "chatli",
user => "postgres",
password => "root",
idle_interval => 500,
decode_opts => [return_rows_as_maps, column_name_as_atom]
}}
]}
]},
{pg_types, [
{uuid_format, string},
{json_config, {chatli_json, #{}, #{}}}
pool_size => 2
}
}}
]},
{nova, [
{cowboy_configuration, #{
Expand All @@ -41,6 +36,8 @@
}}
]}
]},
{chatli, [{download_path, "./priv/attachments/"}]}
{chatli, [
{download_path, "./priv/attachments/"}
]}
%% Please change your app.src-file instead if you intend to add app-specific configurations
].
23 changes: 10 additions & 13 deletions config/sys.config.local
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@
{kernel, [
{logger_level, debug}
]},
{pgo, [
{pools, [
{default, #{
pool_size => 2,
{kura, [
{repos, #{
chatli_repo => #{
backend => kura_backend_postgres,
host => "localhost",
port => 5555,
database => "chatli",
user => "postgres",
password => "root",
idle_interval => 500,
decode_opts => [return_rows_as_maps, column_name_as_atom]
}}
]}
]},
{pg_types, [
{uuid_format, string},
{json_config, {chatli_json, #{}, #{}}}
pool_size => 2
}
}}
]},
{nova, [
{cowboy_configuration, #{
Expand All @@ -42,6 +37,8 @@
}}
]}
]},
{chatli, [{download_path, "./priv/attachments/"}]}
{chatli, [
{download_path, "./priv/attachments/"}
]}
%% Please change your app.src-file instead if you intend to add app-specific configurations
].
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Use postgres/example user/password credentials
services:
db:
image: postgres:17-alpine
command: -c 'max_connections=2000'
environment:
POSTGRES_PASSWORD: root
ports:
- 5555:5432
volumes:
- ./sql:/docker-entrypoint-initdb.d
adminer:
image: adminer
ports:
- 8082:8080
6 changes: 4 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

{deps, [
nova,
pgo,
mimerl,
{kura, {git, "https://github.com/Taure/kura.git", {tag, "v2.0.8"}}},
{kura_postgres, {git, "https://github.com/Taure/kura_postgres.git", {tag, "v0.4.2"}}},
{jwerl, ".*",
{git, "https://github.com/Taure/jwerl.git",
{ref, "5f856e7987bb65ceec1593c21a01fd9aef87abda"}}}
Expand Down Expand Up @@ -49,7 +50,8 @@
%% Plugins for rebar3
{project_plugins, [
erlfmt,
rebar3_lint,
rebar3_kura,
{rebar3_lint, "4.2.2"},
{rebar3_erlydtl_plugin, ".*",
{git, "https://github.com/tsloughter/rebar3_erlydtl_plugin.git", {branch, "master"}}}
]}.
Expand Down
25 changes: 18 additions & 7 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"1.2.0",
[{<<"backoff">>,{pkg,<<"backoff">>,<<"1.1.6">>},1},
[{<<"backoff">>,{pkg,<<"backoff">>,<<"1.1.6">>},2},
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.12.0">>},1},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.13.0">>},2},
{<<"erlydtl">>,{pkg,<<"erlydtl">>,<<"0.14.0">>},1},
Expand All @@ -9,18 +9,27 @@
{git,"https://github.com/Taure/jwerl.git",
{ref,"5f856e7987bb65ceec1593c21a01fd9aef87abda"}},
0},
{<<"kura">>,
{git,"https://github.com/Taure/kura.git",
{ref,"fdb1abc5fdc0cc48c34b7d33fd8e0d6748c4a7d1"}},
0},
{<<"kura_postgres">>,
{git,"https://github.com/Taure/kura_postgres.git",
{ref,"30651b35986bda5fc84d89fc141936cb70b636ab"}},
0},
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.3.0">>},0},
{<<"nova">>,{pkg,<<"nova">>,<<"0.10.2">>},0},
{<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.3.1">>},1},
{<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.3.1">>},2},
{<<"opentelemetry_semantic_conventions">>,
{pkg,<<"opentelemetry_semantic_conventions">>,<<"0.2.0">>},
2},
{<<"pg_types">>,{pkg,<<"pg_types">>,<<"0.4.0">>},1},
{<<"pgo">>,{pkg,<<"pgo">>,<<"0.14.0">>},0},
3},
{<<"pg_types">>,{pkg,<<"pg_types">>,<<"0.4.0">>},2},
{<<"pgo">>,{pkg,<<"pgo">>,<<"0.20.0">>},1},
{<<"pmod_transform">>,{pkg,<<"pmod_transform">>,<<"1.1.0">>},1},
{<<"quickrand">>,{pkg,<<"quickrand">>,<<"2.0.7">>},2},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2},
{<<"routing_tree">>,{pkg,<<"routing_tree">>,<<"1.0.9">>},1},
{<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.4.2">>},1},
{<<"thoas">>,{pkg,<<"thoas">>,<<"1.2.0">>},1},
{<<"uuid">>,{pkg,<<"uuid_erl">>,<<"2.0.7">>},1}]}.
[
Expand All @@ -36,11 +45,12 @@
{<<"opentelemetry_api">>, <<"83B4713593F80562D9643C4AB0B6F80F3C5FA4C6D0632C43E11B2CCB6B04DFA7">>},
{<<"opentelemetry_semantic_conventions">>, <<"B67FE459C2938FCAB341CB0951C44860C62347C005ACE1B50F8402576F241435">>},
{<<"pg_types">>, <<"3CE365C92903C5BB59C0D56382D842C8C610C1B6F165E20C4B652C96FA7E9C14">>},
{<<"pgo">>, <<"F53711D103D7565DB6FC6061FCF4FF1007AB39892439BE1BB02D9F686D7E6663">>},
{<<"pgo">>, <<"4F4A1FCB0A4894311BE238195BDAD4DF80312AB091DB87FE5348FAFA4DA75F87">>},
{<<"pmod_transform">>, <<"A3A4FA607B947C90410BC459DCA27F6B60D25D1588D568280F7276AC8767E106">>},
{<<"quickrand">>, <<"D2BD76676A446E6A058D678444B7FDA1387B813710D1AF6D6E29BB92186C8820">>},
{<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>},
{<<"routing_tree">>, <<"F7B95CF21CAEF1F184948C547780BAB4EC2B2CB0CD75B8CB2BE49F86F0DFD523">>},
{<<"telemetry">>, <<"A0CB522801DFFB1C49FE6E30561BADFFC7B6D0E180DB1300DF759FAA22062855">>},
{<<"thoas">>, <<"73B0546BAFF5008E6ED209558FD7B0606B035D96F9F3DE24EF42879100E094D4">>},
{<<"uuid">>, <<"B2078D2CC814F53AFA52D36C91E08962C7E7373585C623F4C0EA6DFB04B2AF94">>}]},
{pkg_hash_ext,[
Expand All @@ -55,11 +65,12 @@
{<<"opentelemetry_api">>, <<"9E8A5CC38671E3AC61BE48ABE5F6B3AFDBBB50A1DC08B7950C56F169611505C1">>},
{<<"opentelemetry_semantic_conventions">>, <<"D61FA1F5639EE8668D74B527E6806E0503EFC55A42DB7B5F39939D84C07D6895">>},
{<<"pg_types">>, <<"B02EFA785CAECECF9702C681C80A9CA12A39F9161A846CE17B01FB20AEEED7EB">>},
{<<"pgo">>, <<"71016C22599936E042DC0012EE4589D24C71427D266292F775EBF201D97DF9C9">>},
{<<"pgo">>, <<"2F11E6649CEB38E569EF56B16BE1D04874AE5B11A02867080A2817CE423C683B">>},
{<<"pmod_transform">>, <<"68C7FF7354C0D837681990D093D367FCC617C32570A1009B8E7ACFF6445499AA">>},
{<<"quickrand">>, <<"B8ACBF89A224BC217C3070CA8BEBC6EB236DBE7F9767993B274084EA044D35F0">>},
{<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>},
{<<"routing_tree">>, <<"FB9A05EA0F3A8B77CC39CED3952B98391C617BA448AF63DDD5908F8557D8C029">>},
{<<"telemetry">>, <<"928F6495066506077862C0D1646609EED891A4326BEE3126BA54B60AF61FEBB1">>},
{<<"thoas">>, <<"540C8CB7D9257F2AD0A14145DC23560F91ACDCA995F0CCBA779EB33AF5D859D1">>},
{<<"uuid">>, <<"4E4C5CA3461DC47C5E157ED42AA3981A053B7A186792AF972A27B14A9489324E">>}]}
].
23 changes: 23 additions & 0 deletions sql/10_ldf.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE DATABASE ldf;

\c ldf;

CREATE TABLE li
(
id SERIAL PRIMARY KEY,
type VARCHAR NOT NULL,
value VARCHAR NOT NULL,
callback_id uuid NOT NULL,
user_id uuid NOT NULL,
username VARCHAR,
phone_number VARCHAR,
email VARCHAR
);

CREATE TABLE ldf_message
(
id SERIAL PRIMARY KEY,
message_id UUID NOT NULL,
payload VARCHAR,
content_length VARCHAR
);
70 changes: 70 additions & 0 deletions sql/20_chatli.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
CREATE DATABASE chatli;

\c chatli;

CREATE EXTENSION pgcrypto;

CREATE TABLE chatli_user
(
id uuid PRIMARY KEY,
username varchar NOT NULL UNIQUE,
phone_number varchar UNIQUE,
email varchar UNIQUE,
avatar varchar,
password varchar NOT NULL
);

CREATE TABLE message
(
id uuid PRIMARY KEY,
chat_id uuid NOT NULL,
payload jsonb,
sender uuid NOT NULL,
type varchar,
action varchar,
timestamp bigint,
sender_info jsonb
);

CREATE TABLE chat
(
id uuid PRIMARY KEY,
name varchar NOT NULL,
description varchar,
type varchar
);

CREATE TABLE participant
(
id SERIAL PRIMARY KEY,
chat_id uuid,
user_id uuid,
UNIQUE(chat_id, user_id)
);

CREATE TABLE callback
(
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
url VARCHAR NOT NULL
);


CREATE TABLE device
(
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
name VARCHAR
);

CREATE TABLE attachment
(
id UUID PRIMARY KEY,
chat_id UUID NOT NULL,
mime VARCHAR NOT NULL,
length INTEGER
);

INSERT INTO chatli_user (id, username, phone_number, email, password) VALUES (gen_random_uuid(), 'alice', '461234', 'alice@example.com', 'alice');
INSERT INTO chatli_user (id, username, phone_number, email, password) VALUES (gen_random_uuid(), 'bob', '462345', 'bob@example.com', 'bob');
INSERT INTO chatli_user (id, username, phone_number, email, password) VALUES (gen_random_uuid(), 'ceasar', '463456', 'ceasar@example.com', 'ceasar');
2 changes: 2 additions & 0 deletions src/chatli.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
stdlib,
nova,
pgo,
kura,
kura_postgres,
jwerl,
runtime_tools,
mimerl
Expand Down
Loading
Loading