A full-stack web application to manage contacts — create, store and list contacts with name, email and phone number. Built with Node.js, Express and MySQL.
- Backend: Node.js, Express 5
- Database: MySQL
- Frontend: HTML5, CSS3, Vanilla JavaScript (Fetch API)
- Dev tools: Nodemon
- Add new contacts through a clean, validated form
- View all saved contacts in a responsive table
- Server-side input validation (name and email required)
- Parameterized SQL queries (SQL injection safe)
- Responsive design for mobile and desktop
- Clone the repository:
git clone https://github.com/your-username/contact-manager-nodejs.git
cd contact-manager-nodejs- Install dependencies:
npm install- Create the database — open MySQL and run:
mysql -u root < database.sqlOr copy the content of database.sql and run it in MySQL Workbench.
- Configure environment variables:
cp .env.example .envEdit .env with your MySQL credentials if needed (defaults work for a standard local setup).
- Start the development server:
npm run dev- Open http://localhost:3000 in your browser.
contact-manager-nodejs/
├── config/
│ └── db.js # MySQL connection pool
├── routes/
│ └── contacts.routes.js # API and page routes
├── public/
│ ├── css/
│ │ └── style.css # Application styles
│ └── js/
│ ├── form.js # Form submission handler
│ └── list.js # Contact list loader
├── views/
│ ├── form.html # New contact form
│ └── list.html # Contact list page
├── .env.example # Environment variables template
├── database.sql # Database schema
├── server.js # Express server entry point
└── package.json
| Method | Route | Description |
|---|---|---|
| GET | / |
New contact form |
| POST | /form |
Save a contact |
| GET | /list |
Contact list page |
| GET | /api/contactos |
JSON — returns all contacts |
This app can be deployed to platforms like Railway, Render or any VPS with Node.js and MySQL.
The config/db.js file already reads from environment variables, so just set DB_HOST, DB_USER, DB_PASSWORD, DB_NAME and DB_PORT in your hosting provider's dashboard.
Alexandre Rocha
MIT