Skip to content

A simple nodejs app with postgres database that adds and deletes users

Notifications You must be signed in to change notification settings

bankolejohn/nodejs-app-test

Repository files navigation

Node.js App with PostgreSQL and Docker

This project is a simple Node.js application that demonstrates how to build a modern web application with a PostgreSQL database, Docker, and DevOps best practices. It includes features for adding and deleting users, making it a great example of a CRUD (Create, Read, Update, Delete) application.


Table of Contents

  1. Business Value
  2. Features
  3. Technologies Used
  4. Architecture
  5. Setup and Deployment
  6. DevOps Integration
  7. Contributing
  8. License

Business Value

In today’s fast-paced digital world, businesses rely on scalable, maintainable, and efficient web applications to deliver value to their customers. This project demonstrates how modern technologies like Node.js, PostgreSQL, and Docker can be combined to build robust applications that meet these demands.

Key Benefits:

  1. Scalability: The use of Docker allows the application to be easily scaled horizontally to handle increased traffic.
  2. Portability: Docker ensures that the application runs consistently across different environments, from development to production.
  3. Efficiency: Node.js provides a lightweight and fast runtime, while PostgreSQL offers a reliable and performant database solution.
  4. DevOps Integration: The project is designed with DevOps principles in mind, enabling continuous integration, delivery, and deployment (CI/CD).

This project is particularly useful for:

  • Startups: Quickly build and deploy scalable web applications.
  • DevOps Engineers: Demonstrate best practices for containerization and deployment.
  • Developers: Learn how to integrate modern technologies into a full-stack application.

Features

  • Add Users: A simple form to add users to the database.
  • List Users: Display all users in the database.
  • Delete Users: Remove users from the database with a single click.
  • Docker Support: The application and database are containerized using Docker.
  • Environment Variables: Secure configuration using .env files.

Technologies Used

  • Node.js: A JavaScript runtime for building scalable server-side applications.
  • Express.js: A web framework for Node.js to handle routing and middleware.
  • PostgreSQL: A powerful, open-source relational database.
  • Sequelize: An ORM (Object-Relational Mapping) tool for Node.js to interact with PostgreSQL.
  • Docker: A platform for containerizing applications and services.
  • Docker Compose: A tool for defining and running multi-container Docker applications.
  • dotenv: A module for loading environment variables from a .env file.

Architecture

The application follows a 3-tier architecture:

  1. Presentation Layer: The frontend (HTML/CSS/JavaScript) interacts with the user.
  2. Application Layer: The Node.js backend handles business logic and communicates with the database.
  3. Data Layer: PostgreSQL stores and manages the application data.

Docker Architecture

  • Node.js App: Runs in a Docker container.
  • PostgreSQL: Runs in a separate Docker container.
  • Docker Compose: Manages the multi-container setup.

Setup and Deployment

Prerequisites

  • Docker and Docker Compose installed on your machine.
  • Node.js (optional, for local development without Docker).

Steps to Run the Application

  1. Clone the Repository:
    git clone https://github.com/your-username/your-repo-name.git
    cd your-repo-name

Set Up Environment Variables:

  1. Create a .env file in the root directory:

    DATABASE_URL=postgres://your_db_user:your_db_password@db:5432/your_db_name
    PORT=3000
  2. Build and Run with Docker Compose:

    docker-compose up --build
  3. Access the Application:

Open your browser and go to http://localhost:3000.

DevOps Integration

As a DevOps engineer, you can extend this project to include CI/CD pipelines, monitoring, and infrastructure as code (IaC). Here are some suggestions:

CI/CD Pipeline

  • Use GitHub Actions or Jenkins to automate testing and deployment.
  • Build and push Docker images to a container registry (e.g., Docker Hub, AWS ECR).

Monitoring

  • Integrate Prometheus and Grafana for monitoring application performance.
  • Use ELK Stack (Elasticsearch, Logstash, Kibana) for centralized logging.

Infrastructure as Code (IaC)

  • Use Terraform or AWS CloudFormation to provision infrastructure (e.g., EC2 instances, RDS databases).

Container Orchestration

  • Deploy the application to Kubernetes for advanced container orchestration and scaling.

Troubleshooting

See Errors & Solutions for common issues and fixes.

Contributing

Contributions are welcome! If you’d like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Author

  • Bankole John
    DevOps Engineer | GitHub
    "Automation is the future, and DevOps is the key to unlocking it."

---



About

A simple nodejs app with postgres database that adds and deletes users

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published