Skip to content

YounusMZ/poetry-backend

Repository files navigation

Poetry

Backend for poetry-frontend. Built for poets and poem enthusiasts, Poetry allows you to view random poems for the serendipity, search for poems and bookmark your favourites. Poetry provides a minimalist UI and allows migrating poems from a local JSON or CSV file.

Demo

  • Live Site: https://poetry-backend-wv7w.onrender.com (Note: Render free-tier does not have persistent disk, so no changes are stored on sleep. It takes about a min to start up as well.)
  • Run docker pull ghcr.io/younusmz/poetry-backend:latest to pull the docker image. Make a container and run. That's a quick way to spin it up.

Description

Features

  • Migrate poems from CSV and JSON to local SQLITE database
  • View random poems to find the ones you may have missed
  • Search for poems by title
  • Boomark your favourite poems
  • Responsive UI - Use it on your phone!

Tech Stack

Frontend

  • React
  • TypeScript
  • React Bootstrap

Backend

  • Node.js
  • Express

Database

  • SQLITE

Deployment

  • Render

How It Works

This is a full-stack web application with a React frontend that communicates with a REST API built with Express.

  • The frontend handles UI and routing
  • The backend exposes RESTful API endpoints
  • Data is stored in the local SQLITE database

Database Schema

  • poems
    • id
    • title
    • poem
    • poet
    • tags
    • isBookmarked

Getting Started

Prerequisites

Installation

To set up:

  • clone the repository: git clone https://github.com/YounusMZ/poetry-backend.git
  • move to the project directory: cd poetry-backend
  • Install the dependencies: run npm install

Executing program

To run:

  • Run npx tsc to transpile ts to js.
  • Run node server ".\fileName.json" to start the server.
  • "fileName.json" will be used as a source to migrate data to the database.
  • If env.PORT is not set, default port 3000 will be used.
  • The build files for poetry-frontend are provided with this repo. You do not need to clone the frontend unless you wish to work on it or run it separately.

Or alternatively,

  • run npm start
  • looks for "PoetryData.csv" file in the root directory of the project.

Import JSON\CSV Schema

{
 "id" : string,
 "Title" : string,
 "Poem" : string,
 "Poet" : string,
 "Tags" : string | null,
 isBookmarked : boolean
}

API Endpoints

  • Poem
    • GET api/poem/:id
    • GET api/bookmark/:id
    • PUT api/bookmark/:id
    • GET api/search?poem=poemName&page=pageNumber
    • GET api/random
    • GET api/favourites?page=pageNumber
    • GET api/poems?ids=poemids

What I've learned

  • Worked with react bootstrap and gained more confidence in working with bootstrap. Learned to employ responsive design with bootstrap.
  • Released the docker image of the app on GHCR.

Screenshots

  • Screenshots:
Screenshot (36) Screenshot (37) Screenshot (38)

License

MIT

Author

The dataset used for the project can be found here.

About

Backend for Poetry - Import and Search Poems

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors