Skip to content

akash85246/Scribly-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Contributors Forks Stargazers Issues LinkedIn


Logo

SCRIBLY

Effortless Sticky Notes with Smart Alerts & Customization!
Report Bug Β· Request Feature . Contribute . Pull Requests . Report Security Issue . Fork the Project

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Additional Notes
  5. Roadmap
  6. Contributing
  7. Contact
  8. Acknowledgments

About The Project

Scribly Screenshot

Scribly is a modern sticky note web app designed to enhance productivity and organization. With a sleek and intuitive interface, it allows users to effortlessly add, edit, delete, and organize notes.

Features

  • πŸ” Google Authentication – Secure authentication using OAuth2 with Passport.js
  • πŸ”” Push Notifications – Send real-time alerts using Web Push API
  • πŸ›‘οΈ Data Sanitization – Prevent XSS attacks with DOMPurify and JSDOM
  • πŸ”‘ JWT Authentication – Secure user sessions with JSON Web Tokens (JWT)
  • πŸ“… Automated Tasks – Schedule background jobs with Node-Cron
  • πŸ”„ Session Management – Handle user sessions efficiently with Express-Session
  • πŸ—„οΈ PostgreSQL Database – Store and manage data with pg (node-postgres)
  • 🌐 CORS Support – Secure cross-origin requests with CORS middleware
  • πŸ“ Markdown Parsing – Render and sanitize user-generated content with Marked.js

(back to top)

Built With

Powered by robust backend technologies for seamless performance and security.

  • Node.js
  • Express.js
  • PostgreSQL
  • Passport.js
  • JWT
  • Node-Cron
  • Web Push
  • CORS
  • Dotenv
  • Git
  • GitHub

(back to top)

Getting Started

Get started quickly with these easy setup instructions.

Prerequisites

Before setting up the project, ensure you have the following installed:

  • Node.js – Download Node.js (LTS version recommended)
  • PostgreSQL – Install and configure PostgreSQL for database management (Download PostgreSQL)
  • npm or Yarn – Comes with Node.js; used to install project dependencies
  • Git – Download Git to clone the repository
  • Railway Account – If deploying on Railway, create a free account at Railway
  • Google Cloud Project – Set up a Google Cloud project for Google Authentication (Guide)
  • Web Push API Keys – Generate keys for enabling push notifications (Web Push Guide)
  • Environment Variables – Create a .env file and configure the required variables (see .env.example)

Additionally, having a basic understanding of the following will be helpful:

  • Express.js – For handling API requests efficiently
  • JWT Authentication – Secure user authentication using JSON Web Tokens
  • Node-Cron – For scheduling background tasks

Installation

Follow these steps to set up the project locally:

  1. Clone the Repository
    git clone https://github.com/akash85246/Scribly-backend.git
    cd Scribly
    
  2. Install Dependencies
    npm install
  3. Set Up Environment Variables
    # Server Configuration
     PORT=5001
     BASE_URL=http://localhost:5001
     FRONTEND_URL=http://localhost:5174
    
     # Database Configuration
     DB_HOST=your_database_host
     DB_PORT=your_database_port
     DB_USER=your_database_user
     DB_PASSWORD=your_database_password
     DB_DATABASE=your_database_name
     DB_SSL=true  # Set to "true" if using SSL, otherwise "false"
    
     # Session Secret (for Express session)
     SESSION_SECRET=your_random_session_secret
    
     # Google OAuth Credentials
     GOOGLE_CLIENT_ID=your_google_client_id
     GOOGLE_CLIENT_SECRET=your_google_client_secret
    
     # JWT Secret (for authentication)
     JWT_SECRET=your_jwt_secret
    
     # Admin Configuration
     ADMIN_EMAIL=your_admin_email
    
     # Web Push Notifications (VAPID Keys)
     WEB_PUSH_PUBLIC_KEY=your_web_push_public_key
     WEB_PUSH_PRIVATE_KEY=your_web_push_private_key
    
  4. Change git remote url to avoid accidental pushes to base project
    git remote set-url origin github_username/repo_name
    git remote -v # confirm the changes
  5. Run the Project
    npm start

(back to top)

Usage

Once the backend is running, it provides the following functionalities:

1. User Authentication

  • Supports Google OAuth for secure sign-in.
  • Generates and manages user sessions using JWT tokens.
  • Uses Express sessions for handling persistent login states.

2. Sticky Note Management

  • Create Notes: Users can add new notes with a title, content, and optional alert.
  • Edit Notes: Allows users to update the content of existing notes.
  • Delete Notes: Users can remove notes they no longer need.

3. Push Notifications

  • Sends real-time push notifications for alerts using web-push.
  • Users receive notifications when a note's alert time is triggered.

4. User Session Management

  • Uses JWT-based authentication for secure API access.
  • Implements session handling with express-session to manage login states.
  • Users can log out securely, clearing their sessions.

5. Database Management

  • PostgreSQL is used as the primary database.
  • Data is securely stored with optional SSL support for remote connections.
  • Uses Knex.js for query building and database transactions.

6. Sorting & Filtering

  • Supports sorting and filtering of notes by:
    • Title
    • Content
    • Creation date
    • Alert date

7. Security Features

  • Implements CORS policies to prevent unauthorized cross-origin requests.
  • Uses DOMPurify & jsdom to sanitize user inputs, preventing XSS attacks.
  • Supports JWT token-based API authentication for secure access.

Additional Notes

  • Database Setup: Ensure that PostgreSQL is running and the .env file is correctly configured.
  • Environment Variables: Modify the .env file to set up API keys, database credentials, and authentication secrets.
  • Deployment: Can be deployed on Railway, Render, or any cloud-based Node.js server.
  • Frontend Integration: This backend is designed to work with the Scribly frontend application.

(back to top)

Roadmap

Here are the planned improvements and features for the backend:

  • User Authentication – Implement Google OAuth login.
  • JWT-based Authentication – Secure API access using JSON Web Tokens.
  • Session Management – Maintain user sessions with express-session.
  • Sticky Note API – Enable adding, editing, and deleting notes.
  • Push Notifications – Implement web-push for real-time alerts.
  • Database Integration – Store and manage data with PostgreSQL.
  • Security Enhancements – Implement CORS, input sanitization, and session protection.
  • Deployment Readiness – Prepare for cloud deployment on Railway or other platforms.

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project

    • Click the "Fork" button at the top-right corner of this page to create a copy of the repository in your GitHub account.
  2. Clone the Repository

    • Clone your forked repository to your local machine:
      git clone https://github.com/your-username/Scribly-backend.git
  3. Create Your Feature Branch

    • Navigate to your project folder and create a new branch for your feature:
      git checkout -b feature/AmazingFeature
  4. Commit Your Changes

    • After making the necessary changes, commit them:
      git commit -m 'Add some AmazingFeature'
  5. Push to the Branch

    • Push your changes to your forked repository:
      git push origin feature/AmazingFeature
  6. Open a Pull Request

    • Go to the original repository (akash85246/Scribly), and open a pull request to merge your feature branch into the main branch.
    • Provide a brief description of the changes you've made and submit the pull request for review.

Top contributors:

contrib.rocks image

(back to top)

Contact

Akash Rajput - @akash_rajp91025 - [email protected]

Project Link: https://github.com/akash85246/Scribly-backend

(back to top)

Acknowledgments

I would like to extend my gratitude to the following resources and technologies that made this project possible:

  • Google Authentication – For enabling secure OAuth-based user authentication.
  • PostgreSQL – For offering a reliable and scalable database solution.
  • Node.js & Express.js – For powering the backend and handling API requests efficiently.
  • Passport.js – For simplifying authentication and session management.
  • JSON Web Token (JWT) – For secure user authentication and API access control.
  • Web Push API – For enabling push notifications and real-time alerts.
  • Node-Cron – For scheduling background tasks and automated reminders.
  • Dompurify & JSDOM – For ensuring safe and sanitized HTML handling.
  • MDN & DevDocs – For providing excellent documentation and learning resources.
  • Open Source Community – For their contributions to the tools and libraries that made this backend possible.

(back to top)