Skip to content

IMNJL/concrete_factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

(The file /Users/pro/Downloads/concrete_factory/README.md exists, but is empty)

Concrete Factory — Local demo

This repository contains a small static site (/site) for a demo concrete factory website and a minimal Node.js server (/server) that serves the site and accepts orders via POST /api/order.

This README explains how to run the project locally, how the server handles orders, and how to enable SMTP email sending.

Project layout

  • site/ — static frontend (HTML, CSS, JS). Open at / when server runs.
  • server/ — minimal Express server that serves site/ and accepts /api/order requests.
  • server/server.js — server entrypoint.
  • server/package.json — server dependencies and start script.
  • server/.env — optional (not checked into repo) SMTP and runtime settings.
  • prices.json — example prices (exported from admin panel)

Quick start (development)

  1. Install server dependencies:
cd /Users/pro/Downloads/concrete_factory/server
npm install
  1. Create and edit server/.env (copy from provided example if present). Example contents:
# server/.env
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your_smtp_user@example.com
SMTP_PASS=your_smtp_password
TO_EMAIL=sales@example.com
FROM_NAME="Бетонный завод"
PORT=3000

Notes:

  • SMTP_HOST is required to enable email sending. If missing, the server will still accept orders and save them to server/orders.json, but it will not attempt to send email.
  • For port 465 set SMTP_SECURE=true. For ports like 587 use SMTP_SECURE=false (STARTTLS).
  1. Run the server:
node server/server.js
  1. Open the site in your browser (do not open files with file://):
http://localhost:3000/

How the order flow works

  • The frontend makes a POST to /api/order with JSON: { markdown: string, order: { ... } }.
  • The server appends the order (with timestamp) to server/orders.json.
  • If SMTP is configured (SMTP_HOST + TO_EMAIL), the server attempts to send an email to TO_EMAIL with the order contents. The server logs success or failure to the console.

Troubleshooting: email not delivered

  1. Ensure server/.env is at server/.env (the server reads this exact path).
  2. Restart the server after changing .env.
  3. Check server logs when sending an order — logs show Order received: and either Order email sent to ... or Failed to send order ... with the underlying error.
  4. Verify SMTP credentials and port. Common combos:
    • Port 465 + SMTP_SECURE=true
    • Port 587 + SMTP_SECURE=false (STARTTLS)
  5. Check the recipient mailbox (Inbox + Spam). Some providers may reject or place messages into Spam if SPF/DKIM/DMARC aren't configured for the sending domain.
  6. If you use Gmail or Yandex, ensure your account allows SMTP sending for third-party apps (app password or less-secure-apps setting as applicable).

If you want the API to return explicit failures when email sending fails (instead of saving order and returning OK), open an issue or request and I can switch the endpoint to respond with an error status when mail sending fails.

Developer notes

  • The frontend code (site/js/main.js) originally used fetch('/api/order'), which fails when the page is opened via file://. Always serve the site over HTTP to avoid CORS and local resource restrictions.
  • Orders saved locally are stored in server/orders.json.

Useful commands

  • Install deps: cd server && npm install
  • Run server: node server/server.js
  • Send a test order from the command line:
curl -X POST http://localhost:3000/api/order \
	-H "Content-Type: application/json" \
	-d '{"markdown":"test order","order":{"buyerName":"Test","buyerPhone":"000","buyerEmail":"test@example.com","details":[],"materialTotal":0,"delivery":0,"total":0}}'

Want me to improve this repo?

  • I can add explicit SMTP verification at startup, return mail-sending errors to the frontend, or wire a simple admin page to view server/orders.json.

If you'd like any of the above, tell me which change to make and I'll apply it.


Generated by the project assistant to help run the demo locally.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published