OFF-GRID CONSTRUCTION PLATFORM
Welcome! This guide will help you get the project running on your computer.
---
📋 WHAT YOU NEED
Before starting, install these programs on your computer:
Node.js (version 16 or higher)
Download from: https://nodejs.org/
This includes npm (package manager)
---
Open Terminal/Command Prompt
Windows: Open folder, type `cmd` in address bar, press Enter
Mac: Open folder, right-click → "New Terminal at Folder"
Linux: Right-click folder → "Open in Terminal"
Install Dependencies
Type this command and press Enter:
```
npm install
```
```
Start the Server
Type this command:
```
npm start
```
You should see: `✅ Off-Grid Builder running at http://localhost:3001`
Step 6: Open in Browser
Open your web browser and go to:
```
http://localhost:3001
```
--- HOW TO USE
For Property Owners:
Go to homepage
Click "Start Planning Your Project"
Fill out the form with project details
Submit - you'll see confirmation
For Contractors:
Go to homepage
Click "Join Our Network"
Fill application form
Submit - application saved as "Pending"
For Admins:
Click "Admin Login" at bottom of page
Login: username `admin`, password `admin123`
View dashboard with statistics
Manage leads and contractors
Email projects to contractors
---
📁 PROJECT STRUCTURE
```
offgrid---/
├── server.js              # Main application 
├── package.json           # Dependencies list 
├── .env                   # Nodemailer settings
├── data/                  # Database files 
│   ├── leads.db          # Property owner data
│   └── contractors.db    # Contractor data
├── public/
│   └── css/
│       └── custom.css    # Custom styles
├── views/                # EJS templates 
│   ├── layout.ejs        # Page wrapper
│   ├── landing.ejs       # Homepage
│   ├── owners-start.ejs  # Owner form
│   ├── contractors-apply.ejs  # Contractor form
│   ├── thanks.ejs        # Thank you page
│   ├── admin-login.ejs   # Admin login
│   ├── admin-dashboard.ejs    # Admin home
│   ├── admin-leads.ejs   # Manage leads
│   └── admin-contractors.ejs  # Manage contractors
└── node_modules/         # Installed packages 
```
---

Start Development Server (auto-restarts on changes)
```
npm run dev
```
Start Production Server
```
npm start
```
Stop Server
Press `Ctrl + C` in the terminal
View Database Files
Files are in `data/` folder
JSON format, readable in any text editor
---
---
TECHNOLOGIES USED
Node.js - JavaScript runtime
Express - Web framework
NeDB - Embedded database (no SQL needed)
EJS - Template engine for HTML
Tailwind CSS - Styling framework
Nodemailer - Email sending

---

HOW THIS LAYOUT STRUCTUTRE  WORKS:
  
  1. Express uses express-ejs-layouts package
  2. Server sets layout file: app.set("layout", "layout")
  3. When rendering any page:
     - Server loads layout.ejs (this file)
     - Server loads requested page (e.g., landing.ejs)
     - Server inserts page content into <%- body %> tag
     - Server sends complete HTML to browser
  
  LAYOUT STRUCTURE:
  
  ┌─────────────────────────────
  │ Header (logo + navigation)           │
  ├─────────────────────────────
  │                                      │
  │  Main Content Area                   │
  │  (<%- body %> - page inserted here)  │
  │                                      │
  ├────────────────────────────
  │ Footer (copyright + admin link)      │
  └─────────────────────────────
  
  PAGES USING THIS LAYOUT:
  - landing.ejs (homepage)
  - owners-start.ejs (property owner form)
  - contractors-apply.ejs (contractor application)
  - thanks.ejs (thank you page)
  - admin-login.ejs (admin login form)
  - admin-dashboard.ejs (admin dashboard)
  - admin-leads.ejs (leads management)
  - admin-contractors.ejs (contractor management)

