๐Ÿ“ฆ obafemitayor / newsletter-subscription-application

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching
๐Ÿ“ฅ Clone https://github.com/obafemitayor/newsletter-subscription-application.git
HTTPS git clone https://github.com/obafemitayor/newsletter-subscription-application.git
SSH git clone git@github.com:obafemitayor/newsletter-subscription-application.git
CLI gh repo clone obafemitayor/newsletter-subscription-application
Omotayo Obafemi Omotayo Obafemi Added meaningful and descriptive text to the read me file 220fbb2 9 months ago ๐Ÿ“ History
๐Ÿ“‚ 220fbb29c0c74640661f5379fd9feebe2d3d5297 View all commits โ†’
๐Ÿ“ api
๐Ÿ“ frontend
๐Ÿ“„ README.md
๐Ÿ“„ README.md

๐Ÿ“ฌ Newsletter Subscription App โ€” Storyblok

This is a web application that allows users to subscribe to newsletters that are focussed on different topics. The web app has two pages which are:
  • Subscription Page which allows users to fill a subscription form with basic personal details and select newsletter categories
  • Subscription List Page which allows users to view all submitted subscriptions and filter subscriptions by category

๐Ÿ—‚๏ธ Basic Repository Folder Structure

story-blok-newsletter-subscription-application/
โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ v1/
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ categories_controller.rb
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ subscriptions_controller.rb
โ”‚   โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ category.rb
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ customer.rb
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ subscription.rb
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ category_service.rb
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ subscription_service.rb
โ”‚   โ”œโ”€โ”€ spec/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ””โ”€โ”€ factories/
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ”œโ”€โ”€ docker-compose.yml
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ main.ts
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ subscription/
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ Subscription.vue
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ SubscriptionList.vue
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ service/
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ category.ts
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ subscription.ts
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ helpers/
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ constants.ts
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ validation.ts
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ types/
โ”‚   โ””โ”€โ”€ __tests__/
โ”‚       โ”œโ”€โ”€ Subscription.test.ts
โ”‚       โ”œโ”€โ”€ SubscriptionList.test.ts
โ”‚       โ””โ”€โ”€ utils/
โ”‚           โ”œโ”€โ”€ categories-mock-data.ts
โ”‚           โ”œโ”€โ”€ subscription-list-mock-data.ts
โ”‚           โ””โ”€โ”€ utils.ts
โ”‚
โ””โ”€โ”€ README.md


๐Ÿš€ Getting Started

Prerequisites

  • Docker. You must have either docker desktop or orb stack (recommended) installed. Note that orb stack only works on mac and linux.
  • Node.js greater than or equal to v20.10.0

โš™๏ธ Setup

  • Navigate to the root directory of the api folder.
  • Run docker compose build --no-cache to build the containers.
  • Run docker compose run --rm api bundle install to install the gem packages.
  • Run docker compose run --rm api rails db:migrate to migrate the database.
  • Run docker compose up -d to start the containers.
  • Launch http://localhost:3000 on your browser to confirm that the API server is running.
  • Navigate to the root directory of the frontend folder.
  • Run npm install to install dependencies.
  • Run npm run dev to start the development server.
  • Launch http://localhost:5173/subscription on your browser to confirm that the frontend server is running.
  • The create subscription page url is http://localhost:5173/subscription, while the subscription list page url is http://localhost:5173/subscription/list

๐Ÿงช Running Tests

Backend Tests

  • Navigate to the root directory of the api folder.
  • Run docker compose up test to run the tests.

Frontend Tests

  • Navigate to the root directory of the frontend folder.
  • Run npm run test to run the tests.

๐Ÿ”ง Things to Improve

Here is a list of things that I would like to improve but couldn't due to time constraints:
  • Add end to end tests with Cypress
  • Use a proper localization tool that can automatically manage translations
  • Add visual feedback for loading and success/failure states
  • Use toasts or a proper notification library instead of using alert()