← Back to Projects

Media Library

Node.js · Express.js · PostgreSQL · React.js

Overview

As part of my coursework at Lake Washington Institute of Technology, I designed and implemented a Media Library web application that integrates a PostgreSQL database with a Node.js/Express server. This project strengthened my backend development skills by focusing on relational database setup, server-side logic, and defensive programming practices.

Problem & Objectives

  • Build a backend web application with PostgreSQL integration.
  • Implement RESTful APIs for CRUD operations.
  • Ensure secure credential handling and error management.
  • Demonstrate proficiency in backend development and scalability.

Technical Implementation

The application uses Node.js with Express.js for the server, PostgreSQL as the relational database, and Sequelize as the ORM for database modeling. Key components include:

  • RESTful API endpoints for Create, Read, Update, and Delete operations.
  • Sequelize ORM for defining models and handling database interactions.
  • Environment variable management for secure database credentials.
  • Step-by-step verification of database connectivity and error handling.

A React.js frontend was integrated to provide a user interface for interacting with the APIs, demonstrating full-stack capabilities.

Sample Express.js Route


const express = require('express');
const router = express.Router();
const { Item } = require('../models');

// GET all items
router.get('/', async (req, res) => {
  try {
    const items = await Item.findAll();
    res.json(items);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

// POST new item
router.post('/', async (req, res) => {
  try {
    const item = await Item.create(req.body);
    res.json(item);
  } catch (error) {
    res.status(400).json({ error: error.message });
  }
});

module.exports = router;
        

Sequelize Model Example


const { Sequelize, DataTypes } = require('sequelize');
const sequelize = new Sequelize(process.env.DATABASE_URL);

const Item = sequelize.define('Item', {
  name: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  description: {
    type: DataTypes.TEXT,
  },
});

module.exports = { Item, sequelize };
        

Challenges & Solutions

Database connectivity issues were addressed through thorough testing and environment configuration. Error handling was implemented using try-catch blocks and middleware to ensure reliability. Reproducibility was achieved by documenting setup steps and using version control for code and database schemas.

Results & Impact

  • Successfully integrated PostgreSQL with Node.js/Express for robust backend functionality.
  • Demonstrated proficiency in RESTful API development and ORM usage.
  • Applied defensive programming practices for secure and scalable applications.
  • Strengthened skills in full-stack development with React.js integration.

Future Enhancements

  • Add authentication and authorization for user management.
  • Implement data validation and sanitization for enhanced security.
  • Deploy to a cloud platform with automated CI/CD pipelines.
  • Expand frontend features with advanced UI components.