Skip to content

Hogwai/reddit-trends-analyzer

Repository files navigation

Reddit Analytics with Micronaut & DynamoDB

A lightweight analytics tool to fetch posts from a subreddit, extract keywords, and identify trends. It enriches posts (sentiment/summary) with the help of gemma3 1b through ollama

Built with Micronaut and a local DynamoDB database.

Tech Stack

  • Framework: Micronaut
  • Language: Java 21
  • Database: AWS DynamoDB (Local)
  • Build Tool: Gradle

Prerequisites

  • Java 21
  • Docker & Docker Compose
  • AWS CLI

Quick Start

Start DynamoDB

docker-compose up -d

Configure a local profile

aws configure --profile local

Create credentials

AWS Access Key ID : DUMMYKEY
AWS Secret Access Key : DUMMYSECRET
Default region name: eu-west-3
Default output format: json

Create the table

aws dynamodb create-table \
    --table-name reddit-posts \
    --attribute-definitions AttributeName=id,AttributeType=S \
    --key-schema AttributeName=id,KeyType=HASH \
    --billing-mode PAY_PER_REQUEST \
    --endpoint-url http://localhost:8000 \
	--region eu-west-3 \
	--profile local

Or run the shell:

create-table.sh

Run docker compose

ollama is BEEFY (>5GB). Make sure you have enough room for it

docker compose up -d

DynamoDB admin

The admin GUI will be available here: dynamodb-admin

Run the application:

./gradlew run

API Endpoints

  • Fetch Posts

Fetches and saves posts from Reddit.

curl -X POST "http://localhost:8082/reddit/fetch?subreddit=socialmedia&limit=50"
  • Get Top Keywords

Returns the most frequent keywords for a given subreddit.

curl "http://localhost:8082/analytics/top-keywords?subreddit=socialmedia&days=30"
  • Compare Keywords

Compares the frequency of specific keywords.

curl "http://localhost:8082/analytics/compare-keywords?subreddit=socialmedia&terms=tiktok,instagram"
  • Get top flairs

Returns the most frequent flairs used for a given subreddit.

curl "http://localhost:8082/analytics/top-flairs?subreddit=socialmedia"
  • Get the frequency evolution of a keyword over time

Get the frequency evolution of a keyword over time (by hour, day, week, month)

curl "http://localhost:8082/analytics/keyword-trends?subreddit=socialmedia&keyword=tiktok"