(The file /Users/pro/Downloads/concrete_factory/README.md exists, but is empty)
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 servessite/and accepts/api/orderrequests.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)
- Install server dependencies:
cd /Users/pro/Downloads/concrete_factory/server
npm install- 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_HOSTis required to enable email sending. If missing, the server will still accept orders and save them toserver/orders.json, but it will not attempt to send email.- For port 465 set
SMTP_SECURE=true. For ports like 587 useSMTP_SECURE=false(STARTTLS).
- Run the server:
node server/server.js- 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/orderwith 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 toTO_EMAILwith the order contents. The server logs success or failure to the console.
Troubleshooting: email not delivered
- Ensure
server/.envis atserver/.env(the server reads this exact path). - Restart the server after changing
.env. - Check server logs when sending an order — logs show
Order received:and eitherOrder email sent to ...orFailed to send order ...with the underlying error. - Verify SMTP credentials and port. Common combos:
- Port
465+SMTP_SECURE=true - Port
587+SMTP_SECURE=false(STARTTLS)
- Port
- 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.
- 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 usedfetch('/api/order'), which fails when the page is opened viafile://. 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.