Git Product home page Git Product logo

nodepsd-base's Introduction

Node.js, Postgres, Sequelize, and HTMX Project with Docker

This project demonstrates a web application built with Node.js, Express, Sequelize, and HTMX, containerized using Docker. It includes a user registration form that stores user data in a PostgreSQL database.

Technologies Used

  • Node.js: A JavaScript runtime for server-side development.
  • Express: A web application framework for Node.js.
  • Sequelize: An Object-Relational Mapping (ORM) library for Node.js, supporting various databases including PostgreSQL.
  • HTMX: A library that allows you to add interactivity to your web pages using HTML attributes.
  • PostgreSQL: A powerful, open-source relational database system.
  • Docker: A platform for developing, shipping, and running applications using containers.
  • Passport: Authentication middleware for Node.js.

Prerequisites

Before running this project, ensure that you have the following installed on your system:

Getting Started

Follow these steps to set up and run the project:

  1. Clone the repository:

    https://github.com/Gords/NodePSD-Base.git
    
  2. Navigate to the project directory:

    cd NodePSD-Base
    
  3. Build and start the Docker containers:

    docker-compose up --build
    

    This command will build the Docker images and start the containers defined in the docker-compose.yml file.

  4. Access the application in your web browser at http://localhost:3000.

    You should see the user registration form rendered by the HTMX page.

  5. Fill in the form with an email, password, and name, and click the "Register" button.

    The form data will be submitted to the server using HTMX, and the server will process the request, insert the user data into the database, and send a response back to the client.

  6. To stop the containers, press Ctrl + C in the terminal where the containers are running.

    Alternatively, you can run the following command in a separate terminal window:

    docker-compose down
    

    This command will stop and remove the containers.

    To additionally remove the volumes you can run:

    docker-compose down -v
    

Project Structure

The project structure is as follows:

NodePSD-Base/
├── public/
│   └── index.html
├── migrations/
│   └── ...
├── models/
│   └── ...
├── config/
│   └── config.js
├── .env
├── .gitignore
├── .sequelizerc
├── Dockerfile
├── app.js
├── docker-compose.yml
├── package.json
└── package-lock.json
  • public/: Contains the static files served by the application, including the index.html file with the user registration form.
  • migrations/: Contains the database migration files generated by Sequelize.
  • models/: Contains the Sequelize model definitions, including the User model.
  • config/: Contains the configuration files, including the database configuration in config.js.
  • .env: The environment file that stores sensitive configuration variables.
  • .gitignore: Specifies the files and directories that should be ignored by Git.
  • .sequelizerc: The configuration file for Sequelize CLI.
  • Dockerfile: The Dockerfile that defines the application's container environment.
  • app.js: The main application file that sets up the Express server and defines the routes.
  • docker-compose.yml: The Docker Compose file that defines the services and their configurations.
  • package.json and package-lock.json: The files that manage the project's dependencies.

Database Migrations

The project uses Sequelize migrations to manage database schema changes. To create a new migration, run the following command:

npx sequelize-cli migration:generate --name migration-name

Replace migration-name with a descriptive name for your migration

To run the pending migrations and update the database schema, use the following command:

npm run db:migrate

nodepsd-base's People

Contributors

gords avatar marwerk avatar dependabot[bot] avatar

Watchers

 avatar

nodepsd-base's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.