Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Birthmark

Birthmark is a web automation tool designed to automatically send birthday wishes to your loved ones. This tool leverages background jobs to identify active birthdays for the upcoming day and send personalized messages accordingly, ensuring you never miss a chance to celebrate the special moments of those who matter most to you.

## Installation

- Clone the repository: `git clone https://github.com/deedee-code/Birthmark.git`
- Navigate to the project directory: `cd Birthmark`
- Install Dependencies: `npm install`
- Configure the environment variables: Create a .env file in the root directory and add the necessary environment variables. Example:

```
PORT=your_port_number
SESSION_SECRET=your_session_secret
POSTGRES_USER=your_postgres_username
POSTGRES_PASSWORD=your_postgres_password
POSTGRES_HOST=your_postgres_host
POSTGRES_DATABASE=your_postgres_database
```

- Run the server: `npm run dev`

## Usage

- User Signup/Signin: Users registers or login with their generated API key.
- Create Celebrant: Users can create celebrants with their birthday details and their preferred mode of communication (Email, SMS, Automated_Call).
- Create Wishes: Users create and save birthday wishes for different celebrants.
- Create Background Job: A background job runs daily to check to check for birthdays happening he next day.
- Send Wishes: The system automatically sends the birthday wishes through the specified communication method.

## API Documentation

https://documenter.getpostman.com/view/26786258/2sA3JT1xKi

### Support

For any feedback or collaboration, please contact me on [LinkedIn](https://www.linkedin.com/in/doris-oladotun-owoeye-84a38014b/)
26 changes: 11 additions & 15 deletions db_script/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CREATE SCHEMA IF NOT EXISTS celebration AUTHORIZATION devdeedee;
CREATE TABLE IF NOT EXISTS celebration.user(
id SERIAL PRIMARY KEY,
phone_number varchar(32) NOT NULL UNIQUE,
password varchar(32) NOT NULL,
password varchar(128) NOT NULL,
api_key varchar(255) NOT NULL,
is_admin BOOLEAN DEFAULT FALSE,
created_at DATE DEFAULT CURRENT_DATE,
Expand All @@ -26,32 +26,25 @@ CREATE TABLE IF NOT EXISTS celebration.celebrants (
email VARCHAR(255),
phone_number VARCHAR(32),
birthdate DATE NOT NULL,
channel_id INTEGER NOT NULL,
channel VARCHAR(50) NOT NULL CHECK (channel IN ('SMS', 'AUTOMATED_CALL', 'EMAIL'));,
channel_id INTEGER NOT NULL REFERENCES celebration.channels(id),
is_active BOOLEAN DEFAULT FALSE,
created_at DATE DEFAULT CURRENT_DATE,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Create a table called channels for storing the channels through which birthday wishes are sent to the celebrants
CREATE TABLE IF NOT EXISTS celebration.channels (
id SERIAL PRIMARY KEY,
mode_name INTEGER NOT NULL,
is_disabled Boolean DEFAULT FALSE,
descriiption TEXT DEFAULT NULL
);

-- Create a table called birthday_wishes for storing scheduled birthday wishes
CREATE TABLE IF NOT EXISTS celebration.birthday_wishes (
id SERIAL PRIMARY KEY,
celebrant_id INTEGER NOT NULL,
celebrant_id INTEGER NOT NULL REFERENCES celebration.celebrants(id),
message Varchar(3000) NOT NULL,
scheduled_time TIMESTAMP NOT NULL
);

-- Create a table called birthday_wish_logs for storing logs of sent birthday wishes
CREATE TABLE IF NOT EXISTS celebration.birthday_wish_logs (
id SERIAL PRIMARY KEY,
birthday_wishes_id INTEGER NOT NULL,
birthday_wishes_id INTEGER NOT NULL REFERENCES celebration.birthday_wishes(id),
time_sent TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
status VARCHAR(32) CHECK (status IN ('Successful', 'Pending', 'Failed'))
);
Expand All @@ -72,7 +65,6 @@ SELECT table_name FROM information_schema.tables WHERE table_schema = 'celebrati

-- Add Foreign Key Constraints to Celebrant Table
ALTER TABLE celebration.celebrants
ADD FOREIGN KEY (birthdate_id) REFERENCES celebration.birthdates(id),
ADD FOREIGN KEY (channel_id) REFERENCES celebration.channels(id);

-- Add Foreign Key Constraints to Birthday_wishes Table
Expand Down Expand Up @@ -110,6 +102,10 @@ ALTER TABLE celebration.celebrants
ALTER TABLE celebration.celebrants
DROP COLUMN birthdate_old;

-- Set the birthdate column as not null
-- Set the birthdate column as not null in celebrants table
ALTER TABLE celebration.celebrants
ALTER COLUMN birthdate SET NOT NULL;

-- Add channel column to celebrants table
ALTER TABLE celebration.celebrants
ALTER COLUMN birthdate SET NOT NULL;
ADD COLUMN channel VARCHAR(50) NOT NULL CHECK (channel IN ('SMS', 'AUTOMATED_CALL', 'EMAIL'));
Loading
Loading