Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

krizten/Memoire-API

Repository files navigation

Memoire Logo

Memoire is an online journal where users can pen down their thoughts and feelings. The Memoire WebAPI is powered by NestJS.

NPM Version NestJS Package License Travis

Technologies Used 👨‍💻

  • Server Application
    • Node.js®, a JavaScript runtime built on Chrome's V8 JavaScript engine.
    • NestJS, a progressive Node.js framework for building efficient and scalable server-side applications.
    • JSON Web Token (JWT) for token-based authenication.
    • PostgreSQL, an open source object-relational database system.
    • TypeORM, an ORM that can run in NodeJS, Browser, Cordova, PhoneGap and Ionic platforms and can be used with TypeScript and JavaScript.
    • Amazon S3, a scalable, high-speed, low cost, web-based service designed for backup and archiving of data.
  • Project Management
    • Pivotal Tracker, agile project management tool of choice for developers, was used in managing this project.
    • Docker & Docker-Compose, a container technology, was applied to serve up the server application and database in separate but connected containers.
  • Testing
    • Postman, a complete API development environment, and flexibly integrates with the software development cycle for API testing.

Installation 🏗️

  • Basic Installation
    • Install Node.js® and PostgreSQL on your host environment (or PC).
    • Create a Postgres database with the name: memoiredb or any appropriate name. Note the host, port, username and password of the database.
    • Ensure Git is installed, then clone this repository by running git clone https://github.com/krizten/Memoire-API.git in the terminal.
    • Install the project dependencies by running npm install
    • Create a .ENV file, using the .env.example as a sample fill all the fields with correct data.
    • Ensure the database service is running, then start the server application in development mode by running npm run start:dev
    • Use the API documentation to see available endpoints.
  • Installing With Docker 🐳
    • Install Docker and Docker-Compose on your host environment (or PC).
    • Clone this repository by running git clone https://github.com/krizten/Memoire-API.git in the terminal.
    • Open the docker-compose.yml, then note the database name, host, port, username and password.
    • Create a .ENV file, using the .env.example as a sample fill all the fields with correct data.
    • Start the application in development mode by running docker-compose up

API Endpoints Documentation 📚

Some of the available endpoints are listed below.

  • POST /api/v1/auth/signup :--> Sign up a new user
  • POST /api/v1/auth/login :--> Log in an existing user
  • GET /api/v1/entries :--> Get all diary entries made by the user
  • POST /api/v1/entries :--> Create a new diary entry
  • PUT /api/v1/entries/{id} :--> Update an existing diary entry
  • DELETE /api/v1/entries/{id} :--> Delete a diary entry
  • GET /api/v1/account :--> Retrieve user's account details
  • POST /api/v1/uploads/avatar :--> Upload a new avatar for the user

See complete documentation here.

Testing 🚨

  • Testing with Postman
    • Install Postman or any preferred REST API Client such as Insomnia, Rest Client, etc.
    • Get the application up and running by following the instructions in the Installation Guide of this README.
    • Use the API documentation as a guide to access available endpoints.

Deployment (Production) 🚀

For demonstration purposes, the Memoire WebAPI was deployed to Heroku using the free cloud hosting plan bundled with free dyno hours and several options for data storage.

Hosting with Heroku
  • Create an account with Heroku or log in if you already have an account.
  • Download and install the Heroku CLI matching your operating system.
  • Clone this repository using git clone https://github.com/krizten/Memoire-API.git
  • In your project root directory, run the command heroku login and supply the right credentials.
  • With a working Docker installation, log in to Container Registry using heroku container:login
  • Create a Heroku app by running heroku create <app-name>.
  • Visit Heroku Addons to add PostgreSQL addon to the app. The connection string added to the app is usually of the format postgres://YourUserName:YourPassword@YourHost:5432/YourDatabase.
  • Navigate to the settings area of the newly created app and use the Config Vars to add necessary environment variables (see .env.example).
  • Build the image from the Dockerfile and push to Container Registry using heroku container:push web.
  • Release the image to the app using heroku container:release web.
  • To access the deployed app, run heroku open which opens the app in your default browser.

Improvements ✨

  • Technologies
    • Integrate CI/CD for a better workflow management.
    • Automated testing for faster bug discovery and debugging.
    • Integrate WebSockets on server and clients to reduce HTTP requests and improve on server availability.
    • Implement database caching using Redis for faster data serving.
    • Layering GraphQL on existing REST API to enjoy the benefits of GraphQL.
    • Replace Winston FileLogger with a dedicated logging service such as Sentry to improve performance.
    • Perform scaling in production environment by taking advantage of Nginx, PM2 or easy-to-use AWS Elastic Beanstalk.
  • Features
    • Verify user's account/email to prevent bots from registering.
    • Tracking usage history (last seen and time spent on the app).

Licence 🔐

MIT licensed © Christian Effiong

Credits 🙏

About

REST API for Memoire app. Memoire is an online journal where users can pen down their thoughts and feelings.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published