Skip to content

Commit 34341e6

Browse files
authored
Merge branch 'dev' into SUMMA-16
2 parents 1021ad1 + cef4406 commit 34341e6

50 files changed

Lines changed: 1315 additions & 3487 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ typings/
109109
# Yarn Integrity file
110110
.yarn-integrity
111111

112-
# ignore log files and databases
112+
# ignore log files
113113
*.log
114-
*.sql
115-
*.sqlite
116114

117115
# ignore compiled files
118116
*.com
@@ -185,4 +183,7 @@ backend/node_modules
185183
**/node_modules
186184

187185

188-
package-lock.json
186+
package-lock.json
187+
188+
189+
local_uploads

backend/.env.sample

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ ALGOLIA_INDEX_NAME=...
3333
STRIPE_SECRET_KEY=...
3434
STRIPE_WEBHOOK_SECRET=...
3535
STRIPE_PRICE_ID=...
36-
STRIPE_TEST_MODE=true
36+
STRIPE_TEST_MODE=true
37+
38+
# Gemini configuration
39+
GEMINI_API_KEY=...

backend/jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ module.exports = {
1111
transformIgnorePatterns: [
1212
'/node_modules/'
1313
],
14+
testPathIgnorePatterns: [
15+
'/node_modules/',
16+
'/dist/'
17+
],
1418
verbose: true,
1519
testTimeout: 30000
1620
};

backend/package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"description": "Summarizz backend server",
55
"main": "server.ts",
66
"scripts": {
7+
"build": "tsc",
78
"start": "tsc && node dist/src/server.js",
89
"dev": "nodemon --watch 'src/**/*.ts' --exec ts-node src/server.ts",
910
"lint": "eslint . --ext .ts",
10-
"test": "jest"
11+
"test": "jest",
12+
"test:verbose": "jest --verbose"
1113
},
1214
"author": "",
1315
"license": "ISC",
@@ -17,7 +19,7 @@
1719
"@types/compression": "^1.7.5",
1820
"@types/cookie-parser": "^1.4.3",
1921
"@types/cors": "^2.8.18",
20-
"@types/express": "^4.17.1",
22+
"@types/express": "^4.17.22",
2123
"@types/formidable": "^3.4.5",
2224
"@types/jest": "^29.5.14",
2325
"@types/ms": "^2.1.0",
@@ -32,9 +34,13 @@
3234
},
3335
"dependencies": {
3436
"@algolia/client-search": "^5.20.4",
37+
"@aws-sdk/client-s3": "^3.816.0",
38+
"@aws-sdk/s3-request-presigner": "^3.816.0",
39+
"@google/generative-ai": "^0.24.1",
40+
"@langchain/core": "^0.3.57",
3541
"@types/jsonwebtoken": "^9.0.7",
3642
"algoliasearch": "^4.24.0",
37-
"axios": "^1.7.7",
43+
"axios": "^1.9.0",
3844
"compression": "^1.8.0",
3945
"cookie-parser": "^1.4.7",
4046
"cors": "^2.8.5",
@@ -46,7 +52,7 @@
4652
"formidable": "^3.5.2",
4753
"helmet": "^8.1.0",
4854
"jsonwebtoken": "^9.0.2",
49-
"stripe": "^18.0.0",
55+
"stripe": "^18.1.1",
5056
"winston": "^3.17.0",
5157
"zod": "^3.24.4"
5258
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
echo "Setting up test PostgreSQL database for Summarizz..."
4+
5+
# Prompt for password only once
6+
read -s -p "Enter your PostgreSQL password: " PGPASSWORD
7+
echo
8+
export PGPASSWORD
9+
10+
# Create a temporary .pgpass file for this session
11+
PGPASS_FILE=$(mktemp)
12+
echo "*:*:*:$(whoami):$PGPASSWORD" > "$PGPASS_FILE"
13+
chmod 0600 "$PGPASS_FILE"
14+
export PGPASSFILE=$PGPASS_FILE
15+
16+
echo "Dropping existing database if it exists..."
17+
psql -h localhost -U "$(whoami)" -d postgres -c "DROP DATABASE IF EXISTS summarizz_test;"
18+
19+
echo "Creating new test database..."
20+
psql -h localhost -U "$(whoami)" -d postgres -c "CREATE DATABASE summarizz_test;"
21+
22+
echo "Applying database schema..."
23+
psql -h localhost -U "$(whoami)" -d summarizz_test -f "$(dirname "$0")/postgres_deployment_script.sql"
24+
25+
echo "Populating with test data..."
26+
psql -h localhost -U "$(whoami)" -d summarizz_test -f "$(dirname "$0")/test_data.sql"
27+
28+
# Clean up temporary pgpass file
29+
rm -f "$PGPASS_FILE"
30+
31+
echo "Test database setup complete!"
32+
echo "Database: summarizz_test"
33+
echo "Tables populated with test data for development purposes."
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
CREATE TABLE users (
2+
user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3+
first_name VARCHAR(100) NOT NULL,
4+
last_name VARCHAR(100) NOT NULL,
5+
email VARCHAR(255) NOT NULL UNIQUE,
6+
username VARCHAR(100) NOT NULL UNIQUE,
7+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
8+
profile_image VARCHAR(255),
9+
bio TEXT,
10+
phone VARCHAR(20),
11+
date_of_birth DATE,
12+
location VARCHAR(255),
13+
website VARCHAR(255),
14+
is_private BOOLEAN DEFAULT FALSE,
15+
16+
-- Subscription fields
17+
subscription_status VARCHAR(20) CHECK (subscription_status IN ('free', 'active', 'past_due', 'canceled', 'trialing', 'incomplete', 'incomplete_expired')) DEFAULT 'free',
18+
subscription_tier VARCHAR(10) CHECK (subscription_tier IN ('free', 'pro')) DEFAULT 'free',
19+
stripe_customer_id VARCHAR(100),
20+
stripe_subscription_id VARCHAR(100),
21+
subscription_period_start TIMESTAMP WITH TIME ZONE,
22+
subscription_period_end TIMESTAMP WITH TIME ZONE,
23+
subscription_canceled_at TIMESTAMP WITH TIME ZONE,
24+
grace_period_end TIMESTAMP WITH TIME ZONE
25+
);
26+
27+
CREATE INDEX idx_users_email ON users(email);
28+
CREATE INDEX idx_users_username ON users(username);
29+
CREATE INDEX idx_users_stripe_customer_id ON users(stripe_customer_id);
30+
CREATE INDEX idx_users_stripe_subscription_id ON users(stripe_subscription_id);
31+
32+
CREATE TABLE content (
33+
content_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
34+
creator_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
35+
title VARCHAR(255) NOT NULL,
36+
content TEXT NOT NULL,
37+
summary TEXT,
38+
thumbnail VARCHAR(255),
39+
date_created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
40+
date_updated TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
41+
read_time INTEGER,
42+
likes INTEGER DEFAULT 0,
43+
views INTEGER DEFAULT 0,
44+
shares INTEGER DEFAULT 0,
45+
score REAL
46+
);
47+
48+
CREATE INDEX idx_content_creator_id ON content(creator_id);
49+
CREATE INDEX idx_content_date_created ON content(date_created);
50+
51+
CREATE TABLE comments (
52+
comment_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
53+
content_id UUID NOT NULL REFERENCES content(content_id) ON DELETE CASCADE,
54+
owner_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
55+
text TEXT NOT NULL,
56+
timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
57+
last_edited_timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
58+
like_count INTEGER DEFAULT 0
59+
);
60+
61+
CREATE INDEX idx_comments_content_id ON comments(content_id);
62+
CREATE INDEX idx_comments_owner_id ON comments(owner_id);
63+
64+
65+
CREATE TABLE notifications (
66+
notification_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
67+
user_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
68+
sender_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
69+
type VARCHAR(20) NOT NULL CHECK (type IN ('comment', 'like', 'share', 'follow', 'followedContent', 'followedShare')),
70+
text_preview VARCHAR(255),
71+
content_id UUID REFERENCES content(content_id) ON DELETE SET NULL,
72+
comment_id UUID REFERENCES comments(comment_id) ON DELETE SET NULL,
73+
timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
74+
is_read BOOLEAN DEFAULT FALSE
75+
);
76+
77+
CREATE INDEX idx_notifications_user_id ON notifications(user_id);
78+
CREATE INDEX idx_notifications_timestamp ON notifications(timestamp);
79+
80+
81+
CREATE TABLE user_relationships (
82+
id SERIAL PRIMARY KEY,
83+
follower_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
84+
following_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
85+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
86+
UNIQUE (follower_id, following_id)
87+
);
88+
89+
CREATE INDEX idx_user_relationships_follower ON user_relationships(follower_id);
90+
CREATE INDEX idx_user_relationships_following ON user_relationships(following_id);
91+
92+
93+
CREATE TABLE follow_requests (
94+
id SERIAL PRIMARY KEY,
95+
requester_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
96+
target_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
97+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
98+
UNIQUE (requester_id, target_id)
99+
);
100+
101+
CREATE INDEX idx_follow_requests_requester ON follow_requests(requester_id);
102+
CREATE INDEX idx_follow_requests_target ON follow_requests(target_id);
103+
104+
105+
CREATE TABLE user_content_interactions (
106+
id SERIAL PRIMARY KEY,
107+
user_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
108+
content_id UUID NOT NULL REFERENCES content(content_id) ON DELETE CASCADE,
109+
interaction_type VARCHAR(10) NOT NULL CHECK (interaction_type IN ('like', 'bookmark', 'share')),
110+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
111+
UNIQUE (user_id, content_id, interaction_type)
112+
);
113+
114+
CREATE INDEX idx_user_content_interactions_combined ON user_content_interactions(user_id, content_id);
115+
CREATE INDEX idx_user_content_interactions_type ON user_content_interactions(interaction_type);
116+
117+
118+
CREATE TABLE pending_subscriptions (
119+
subscription_id VARCHAR(100) PRIMARY KEY,
120+
stripe_customer_id VARCHAR(100) NOT NULL,
121+
status VARCHAR(20) NOT NULL CHECK (status IN ('active', 'past_due', 'canceled', 'trialing', 'incomplete', 'incomplete_expired')),
122+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
123+
period_start TIMESTAMP WITH TIME ZONE,
124+
period_end TIMESTAMP WITH TIME ZONE,
125+
canceled_at TIMESTAMP WITH TIME ZONE,
126+
updated_at TIMESTAMP WITH TIME ZONE,
127+
processed BOOLEAN DEFAULT FALSE
128+
);
129+
130+
CREATE INDEX idx_pending_subscriptions_customer_id ON pending_subscriptions(stripe_customer_id);
131+
CREATE INDEX idx_pending_subscriptions_processed ON pending_subscriptions(processed);
132+
133+
134+
CREATE TABLE oauth_connections (
135+
id SERIAL PRIMARY KEY,
136+
user_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
137+
provider VARCHAR(20) NOT NULL CHECK (provider IN ('google', 'github')),
138+
provider_user_id VARCHAR(255) NOT NULL,
139+
access_token VARCHAR(255),
140+
refresh_token VARCHAR(255),
141+
token_expires_at TIMESTAMP WITH TIME ZONE,
142+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
143+
UNIQUE (user_id, provider),
144+
UNIQUE (provider, provider_user_id)
145+
);
146+
147+
CREATE INDEX idx_oauth_connections_user_id ON oauth_connections(user_id);
148+
149+
150+
CREATE TABLE password_reset_tokens (
151+
id SERIAL PRIMARY KEY,
152+
user_id UUID NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
153+
token VARCHAR(255) NOT NULL UNIQUE,
154+
expires_at TIMESTAMP WITH TIME ZONE NOT NULL,
155+
used BOOLEAN DEFAULT FALSE
156+
);
157+
158+
CREATE INDEX idx_password_reset_tokens_user_id ON password_reset_tokens(user_id);
159+
CREATE INDEX idx_password_reset_tokens_expires_at ON password_reset_tokens(expires_at);

0 commit comments

Comments
 (0)