Mini-project

πŸ“Œ Step-by-Step Setup & Documentation

This guide includes installation steps, setup, and file explanations to make it easy for anyone to understand and explain.


πŸ“‚ Project Setup: Step-by-Step Guide

1️⃣ Install Node.js & SQLite

  1. Check if Node.js is installed:

    • Open Terminal / Command Prompt and type:
      Β 
      node -v
    • If it shows a version (like v18.x.x), you’re good!
    • If not, download & install Node.js from nodejs.org.
  2. Install SQLite3:

    • Install SQLite globally by running:
      Β 
      npm install -g sqlite3
      Β 
    • Check if it’s installed:
      sqlite3 --version

Β 


2️⃣ Setup the Project

πŸ“Œ Create a new folder and navigate into it:

mkdir node-sqlite-project cd node-sqlite-project

πŸ“Œ Initialize the project (creates package.json)

Β 
npm init -y

πŸ“Œ Install dependencies

npm install express sqlite3 cors

Create Required Files

Inside sqlite-node-form/, create the following files:

πŸ“‚ sqlite-node-form/
β”œβ”€β”€ server.js (Backend API)
β”œβ”€β”€ database.js (Database connection & queries)
β”œβ”€β”€ database.db (SQLite database)
β”œβ”€β”€ public/ (Frontend files)
β”‚ β”œβ”€β”€ index.html (Main UI)
β”‚ β”œβ”€β”€ style.css (Styling)
β”‚ β”œβ”€β”€ script.js (Handles form submissions)


πŸ“œ File Explanations

πŸ“Œ server.js

Backend Server

  • Uses Express.js for handling routes
  • Connects to SQLite database
  • Manages form submissions & fetching users
  • Stores user details
  • Fetches city dropdowns based on selected state

πŸ“Œ index.html – Frontend Form

  • Contains two forms:
    βœ… User Registration Form
    βœ… Search User by Email Form
  • Calls backend APIs (/submit, /getUser, /cities/:state)

πŸ“Œ style.css – Styling

  • Beautifies the form, buttons, input fields
  • Proper spacing and layout for good UX
  • Ensures both forms are visually separate & readable

πŸ“Œ script.js – Frontend Logic

  • Handles form submission (sends data to server)
  • Fetches cities based on selected state
  • Displays user data in a neat format

πŸ“Œ database.js – Manages the database

Scroll to Top