Add Reddit monitoring bot — backend, frontend, and Docker config

Python/FastAPI backend with PostgreSQL for collecting Reddit data via
public .json endpoints. React/Vite dashboard for analytics. Docker Compose
setup with API and worker services connecting to shared PostgreSQL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 19:29:58 -05:00
parent aaa240dbf0
commit bc2203524f
76 changed files with 7570 additions and 0 deletions

View File

View File

@@ -0,0 +1,54 @@
from datetime import datetime, date
from pydantic import BaseModel
class EngagementPoint(BaseModel):
period: str
posts: int
comments: int
avg_score: float
class TopPost(BaseModel):
id: int
title: str
score: int
num_comments: int
author_name: str | None
subreddit_name: str
created_utc: datetime
permalink: str | None
class TopAuthor(BaseModel):
id: int
username: str
post_count: int
comment_count: int
total_activity: int
class SubredditSummary(BaseModel):
subreddit_id: int
subreddit_name: str
total_posts: int
total_comments: int
avg_score: float
top_flair: str | None
class FlairCount(BaseModel):
flair: str | None
count: int
class DigestResponse(BaseModel):
id: int
subreddit_id: int
subreddit_name: str | None = None
digest_date: date
content: str
metadata_: dict | None = None
generated_at: datetime
model_config = {"from_attributes": True}

13
backend/schemas/author.py Normal file
View File

@@ -0,0 +1,13 @@
from datetime import datetime
from pydantic import BaseModel
class AuthorResponse(BaseModel):
id: int
username: str
first_seen_at: datetime
last_seen_at: datetime
total_posts: int
total_comments: int
model_config = {"from_attributes": True}

19
backend/schemas/common.py Normal file
View File

@@ -0,0 +1,19 @@
from datetime import datetime
from pydantic import BaseModel
class PaginationParams(BaseModel):
page: int = 1
per_page: int = 25
class PaginatedResponse(BaseModel):
total: int
page: int
per_page: int
pages: int
class TimeRangeParams(BaseModel):
since: datetime | None = None
until: datetime | None = None

45
backend/schemas/post.py Normal file
View File

@@ -0,0 +1,45 @@
from datetime import datetime
from pydantic import BaseModel
class PostResponse(BaseModel):
id: int
reddit_id: str
subreddit_id: int
subreddit_name: str | None = None
author_id: int | None
author_name: str | None = None
title: str
selftext: str | None
url: str | None
permalink: str | None
flair: str | None
score: int
upvote_ratio: float | None
num_comments: int
is_self: bool | None
over_18: bool
hot_rank: int | None
created_utc: datetime
collected_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}
class PostDetailResponse(PostResponse):
comments: list["CommentResponse"] = []
class CommentResponse(BaseModel):
id: int
reddit_id: str
post_id: int
parent_comment_id: int | None
author_id: int | None
author_name: str | None = None
body: str
score: int
created_utc: datetime
model_config = {"from_attributes": True}

View File

@@ -0,0 +1,24 @@
from datetime import datetime
from pydantic import BaseModel
class SubredditCreate(BaseModel):
name: str
class SubredditUpdate(BaseModel):
is_active: bool | None = None
class SubredditResponse(BaseModel):
id: int
name: str
display_name: str | None
description: str | None
subscribers: int | None
is_active: bool
created_at: datetime
updated_at: datetime
post_count: int = 0
model_config = {"from_attributes": True}