Tetteh-Apotey/Electrical-Proposal-Generator
โก AS/NZS 3000 Electrical Compliance & Estimating Platform
 
Live Demo: https://tetteh-apotey-Electrical-Proposal-Generator.hf.space/
๐ Overview
An advanced full-stack platform designed for senior Australian electrical engineers and registered contractors to draft, manage, refine, and export professional compliance-checked electrical engineering proposals.
The application streamlines form-driven capture of site variables, models core workscopes (such as Switchboard Upgrades, EV Charger installations, and Lighting Retrofits), verifies compliance with Australian Wiring Rules (AS/NZS 3000:2018), orchestrates prompt templates via an AI backend, tracks full local document iteration through Revision History, and exports blueprints to PDF and MS Word formats.
๐๏ธ Architecture Diagrams
System Architecture Flow
Below is the request-response and data orchestration lifecycle within the application:
graph TD
A[Contractor / Engineer] -->|HTTPS Requests| B[Express Server: Port 3000]
B --> C[Full-Stack Node.js Server]
subgraph Frontend [React SPA Client]
D[App.tsx] --> E[Multi-Step Compliance Form]
D --> F[Dashboard & Document Editor]
D --> G[Theme & Config Controls]
end
subgraph Backend [Node.js / Express Server]
C -->|Serves Static UI Assets| Frontend
C -->|Proposals API /api/proposals| H[(proposals_db.json)]
C -->|Auth API /api/auth| H
C -->|Generate API /api/generate| I[Gemini API Client]
end
I -->|System Prompts & Workscopes| J[Google Gemini LLM]
J -->|Structured Markdown Proposal| C
C -->|PDF/Word Export| AData Flow: Proposal Generation
sequenceDiagram
participant U as User
participant F as React Frontend
participant E as Express Server
participant G as Gemini API
participant D as proposals_db.json
U->>F: Fill 5-step form
F->>E: POST /api/generate (form data)
E->>G: Send prompt + examples
G-->>E: Return Markdown proposal
E->>D: Save proposal to database
E-->>F: Return proposal + ID
F-->>U: Display proposal preview
U->>F: Click Export PDF/Word
F->>E: GET /api/export/:id
E->>D: Retrieve proposal
E-->>F: Return generated file
F-->>U: Download document๐ Project Directory Structure
The workspace is a single-command full-stack application. It uses a modular Vite + React client inside /src, and an orchestrating Node.js Express server at server.ts that serves as a secure API gateway for Gemini AI integration and local state management.
โโโ .env.example # Sample environment configuration
โโโ .gitignore # Untracked build artifacts
โโโ index.html # HTML shell for React
โโโ metadata.json # Platform configuration metadata
โโโ package.json # Dependency manifest & scripts
โโโ proposals_db.json # JSON database (users + proposals)
โโโ server.ts # Express backend & API gateway
โโโ tsconfig.json # TypeScript configuration
โโโ vite.config.ts # Vite bundler configuration
โ
โโโ config/
โ โโโ prompts.json # Editable AI prompt templates
โ
โโโ assets/ # Images and static resources
โ
โโโ src/
โโโ main.tsx # React bootstrap
โโโ index.css # Global Tailwind styles
โโโ index.tsx # React DOM render
โโโ types.ts # TypeScript interfaces
โโโ App.tsx # Main React application
โ
โโโ components/
โโโ Login.tsx # Authentication (register/sign-in)
โโโ ThemeToggle.tsx # 4-color theme switcher
โ
โโโ MultiStepForm/
โ โโโ Step1_JobDetails.tsx
โ โโโ Step2_Materials.tsx
โ โโโ Step3_Labour.tsx
โ โโโ Step4_SiteConditions.tsx
โ โโโ Step5_Review.tsx
โ
โโโ Dashboard/
โโโ ProposalList.tsx
โโโ ProposalEditor.tsx๐ File Responsibility Dictionary
Root Configuration
Frontend Application Layer
React Components
๐ ๏ธ Setup Guide
1. Prerequisites
- Node.js (v18.x or higher)
- npm (v9.x or higher)
2. Environment Setup
Create a .env file at the project root:
cp .env.example .envEdit .env with your Gemini API key (the app works without it using a mock fallback):
GEMINI_API_KEY=your_google_gemini_api_key_here
PORT=3000Get a free Gemini API key: Google AI Studio
3. Install Dependencies
npm install๐ Running the Platform
Development Mode (with Hot Reload)
npm run devOpen: http://localhost:3000
Production Mode
npm run build
npm run startThe app runs on port 3000 (or your PORT environment variable).
๐งโ๐ป How to Use the Platform
Step 1: Register & Login
- Open
http://localhost:3000 - Click "Register a new account"
- Enter email and password (e.g.,
contractor@firm.com.au/password123) - Click "Register Account"
- Log in with your new credentials
Step 2: Create a Proposal
- Go to the Compliance Form tab
- Complete all 5 steps:
- Step 1: Client name, site address, contact details
- Step 2: Job category, materials, compliance notes
- Step 3: Crew size, hours, hourly rate
- Step 4: Access requirements, power shutdown needs, safety notes
- Step 5: Review all inputs
- Click "Draft Proposal with Gemini"
- Wait 5โ10 seconds for AI generation
Step 3: Manage Proposals
- Go to the Dashboard tab
- Click "Inspect / Edit" on any proposal
- Toggle between Document Preview and Raw Edit modes
- Click Export PDF or Export Word to download
Step 4: Revision History
- In the Proposal Editor, click the Revision History button (clock icon)
- Click "Save Current Snapshot Checkpoint" to save a version
- Click any checkpoint to preview
- Click "Revert to This Version" to restore
Step 5: Change Theme
Click the Theme Toggle button in the header to cycle through:
๐ง Configuration (No Coding Required)
Edit these JSON files to customize the app without touching code:
After editing, restart the server or click "Reload Config" in the admin panel.
๐ Troubleshooting
๐ Deployment to Hugging Face Spaces
Option 1: One-Click Deploy (Coming Soon)
Option 2: Manual Deploy with Docker
Create a Dockerfile at the project root:
FROM node:18-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 7860
ENV PORT=7860
CMD ["npm", "run", "start"]Create space/README.md:
---
title: Electrical Proposal Generator
emoji: โก
colorFrom: blue
colorTo: yellow
sdk: docker
app_port: 7860
---Push to Hugging Face Spaces:
git remote add space https://huggingface.co/spaces/your-username/electrical-proposal-generator
git push space mainOption 3: GitHub Actions CI/CD
Create .github/workflows/deploy.yml:
name: Deploy to Hugging Face Spaces
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to HF Spaces
uses: huggingface/actions/space-deploy@v1
with:
space: your-username/electrical-proposal-generator
token: ${{ secrets.HF_ACCESS_TOKEN }}๐ License
MIT โ Free for use by Australian electrical contractors.
๐ Support
For questions or feature requests, contact the developer via GitHub Issues.
Built with โก for Australian electrical contractors. Compliant with AS/NZS 3000:2018.
