Skip to content

SahilGothoskar/webapp

Repository files navigation

webapp 🌐

Webapp architecture diagram

This repository contains a Node.js + Express REST API backed by PostgreSQL and Sequelize. It supports user management, product management, product image handling, health checks, and telemetry/logging integration for cloud deployment.

Tech stack 🧰

  • Node.js
  • Express.js
  • PostgreSQL
  • Sequelize ORM
  • AWS SDK (for image storage integration)
  • Winston logging
  • StatsD metrics
  • Mocha/Chai/Supertest test tooling
  • Packer + Terraform assets for infrastructure workflows

API overview 🔌

The API is versioned under /v1 for user/product operations, plus /healthz for health checks.

Authentication model 🔐

  • Uses HTTP Basic Auth for protected endpoints.
  • Public endpoints: user registration and health check.

Endpoints 🛣️

User endpoints 👤

  • POST /v1/user - Create a new user (public)
  • GET /v1/user/:id - Get user details (Basic Auth)
  • PUT /v1/user/:id - Update user details (Basic Auth)

User payload:

{
	"first_name": "John",
	"last_name": "Doe",
	"username": "john@example.com",
	"password": "strong-password"
}

Product endpoints 📦

  • POST /v1/product - Create product (Basic Auth)
  • GET /v1/product - List products (public)
  • GET /v1/product/:id - Get one product (public)
  • PUT /v1/product/:id - Full update product (Basic Auth, owner)
  • PATCH /v1/product/:id - Partial update product (Basic Auth, owner)
  • DELETE /v1/product/:id - Delete product (Basic Auth, owner)

Product payload:

{
	"name": "Product Name",
	"description": "Product description",
	"sku": "UNIQUE-SKU-001",
	"manufacturer": "Acme",
	"quantity": 10,
	"owner_user_id": 1
}

Product image endpoints 🖼️

  • POST /v1/product/:product_id/image - Upload image (Basic Auth, owner)
  • GET /v1/product/:product_id/image/:image_id - Get one image metadata (Basic Auth)
  • GET /v1/product/:product_id/image - List image metadata for a product (Basic Auth)

Supported upload types are configured in the application. Commonly used types include jpeg, jpg, and svg.

Health endpoint ❤️

  • GET /healthz - Service health probe

Local setup ⚙️

Prerequisites ✅

  • Node.js 16+ (or newer LTS)
  • PostgreSQL
  • npm

Install dependencies 📥

npm install

Database configuration 🗄️

Update Sequelize DB settings as needed in config/config.json.

Run the API ▶️

The service file in this repo starts the app from seeders/app.js, so use:

node seeders/app.js

Note: npm start currently points to app.js. If you want to use npm start, align it with your chosen entry file.

Run tests 🧪

npm test

Deployment notes 🚀

  • Systemd unit file is available under service/node.service.
  • Shell helper scripts are available under shell/.
  • Packer and Terraform-related files are included for AMI and infrastructure workflows.

Repository 📚

About

CSYE6225

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors