From f4340a5b8c3dc927b3747189fdc7e664f0eef340 Mon Sep 17 00:00:00 2001 From: Dave Lane Date: Mon, 27 Nov 2023 22:25:36 +1300 Subject: [PATCH] initial commit of some ideas, with original tutorial data, to be replaced --- .env | 6 ++++ .gitignore | 1 + RoadMap | 41 +++++++++++++++++++++++ docker-compose.override.yml | 15 +++++++++ docker-compose.yml | 66 +++++++++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+) create mode 100644 .env create mode 100644 .gitignore create mode 100644 RoadMap create mode 100644 docker-compose.override.yml create mode 100644 docker-compose.yml diff --git a/.env b/.env new file mode 100644 index 0000000..a47b5da --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +POSTGRES_DB=postgres + +DB_ANON_ROLE=anon +DB_SCHEMA=public diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c190512 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.backup diff --git a/RoadMap b/RoadMap new file mode 100644 index 0000000..7c7d3b9 --- /dev/null +++ b/RoadMap @@ -0,0 +1,41 @@ +# Roadmap + +## Functionality + +For a given Mastodon user, periodically request the list of followed and +followers including number of each and the user + + +## Authentication + +A Mastodon user uses the app to specify a Mastodon handle and server. On +request, the user authorises the app, returning the user to app which then +starts to process data, creating the starting point. + +## Data Objects for a user + +* Followers: a record of each follower including address (@handle@server), full name, and date of follow +(addition?) and unfollow (if any). +* Posts: a record of each post including id, timestamp, and (sanitised?) content +* Boosts: a record of each boost, user, post id, number users followers +* Likes: a record of each like, user, post id +* Mentions: a record of each mention including post ID + + +### Derived Data + +* current number of followers +* servers with followers +* new followers in past period (hour, day, week) +* lost followers in past period (hour, day, week) +* most boosted post +* most liked post +* post seen by most people (boosts * number of followers of each booster) + +## Development Technologies + +My goal with this app is to exercise some technologies I've long wanted to get +experience with: +- Svelte +- SvelteKit +- PostgREST (PostgreSQL + a REST framework) diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..2667cbf --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,15 @@ +version: '3' + +services: + + ############## + # swagger-ui # + ############## + swagger-ui: + container_name: swagger-ui + image: swaggerapi/swagger-ui:latest + ports: + - "127.0.0.1:8085:8080" + environment: + - API_URL=http://localhost:3000/ + restart: unless-stopped diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..26bd96c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,66 @@ +version: '3' + +services: + + ################ + # postgrest-db # + ################ + postgrest-db: + container_name: postgrest-db + image: postgres:alpine + ports: + - "127.0.0.1:5432:5432" + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + - DB_ANON_ROLE=${DB_ANON_ROLE} + - DB_SCHEMA=${DB_SCHEMA} + volumes: + # anything in initdb directory is created in the database + # see "How to extend this image" section at https://hub.docker.com/r/_/postgres/ + - ".config/initdb:/docker-entrypoint-initdb.d" + networks: + - postgrest-backend + restart: unless-stopped + + ################## + # postgrest-demo # + ################## + postgrest-demo: + container_name: postgrest-demo + image: nginx:mainline-alpine + ports: + - "127.0.0.1:8084:80" + volumes: + # anything in html directory is hosted via nginx + - ".demo/html:/usr/share/nginx/html" + restart: unless-stopped + + ############# + # postgrest # + ############# + postgrest: + container_name: postgrest + image: postgrest/postgrest:latest + ports: + - "127.0.0.1:3000:3000" + # Available environment variables documented here: + # https://postgrest.org/en/latest/configuration.html#environment-variables + environment: + # The standard connection URI format, documented at + # https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING + - PGRST_DB_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgrest-db:5432/${POSTGRES_DB} + # The name of which database schema to expose to REST clients + - PGRST_DB_SCHEMA=${DB_SCHEMA} + # The database role to use when no client authentication is provided + - PGRST_DB_ANON_ROLE=${DB_ANON_ROLE} + # Overrides the base URL used within the OpenAPI self-documentation hosted at the API root path + - PGRST_OPENAPI_SERVER_PROXY_URI=http://localhost:3000 + networks: + - postgrest-backend + restart: unless-stopped + +networks: + postgrest-backend: + driver: bridge