Piattaforma web completa per la gestione delle certificazioni di cybersecurity con backend Node.js, database PostgreSQL e sistema di notifiche email.
- Frontend Vanilla JS/CSS/HTML - Nessun framework pesante, solo tecnologie web native
- Backend Node.js + Express - API RESTful robusta e scalabile
- Database PostgreSQL (Neon) - Archiviazione dati serverless e sicura
- Sistema Email Automatico - Notifiche via SMTP con Nodemailer
- Deployment Ready - Configurato per Render.com
- Security First - Helmet, CORS, Rate Limiting, Validazione Input
- Node.js >= 18.0.0
- npm o yarn
- Account Neon (database PostgreSQL serverless)
- Server SMTP per email (Gmail, SendGrid, Mailgun, ecc.)
git clone https://github.com/xbeat/certicredia.git
cd certicredianpm installCrea un file .env nella root del progetto (copia da .env.example):
cp .env.example .envModifica il file .env con i tuoi parametri:
# Server
NODE_ENV=development
PORT=3000
# Database (Neon PostgreSQL)
DATABASE_URL=postgresql://username:password@your-neon-host.neon.tech/certicredia?sslmode=require
# Email SMTP
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=request@certicredia.org
SMTP_PASS=your-app-password
# Notification
NOTIFICATION_EMAIL=request@certicredia.org
CORS_ORIGIN=*# Modalità produzione
npm start
# Modalità sviluppo (con auto-reload)
npm run devIl server sarà disponibile su http://localhost:3000
- Vai su neon.tech
- Crea un nuovo progetto
- Copia la connection string che ti viene fornita
La connection string ha questo formato:
postgresql://username:password@hostname.neon.tech/dbname?sslmode=require
Incollala nel file .env come valore di DATABASE_URL.
Il database viene inizializzato automaticamente all'avvio del server. Lo schema include:
- Tabella
contacts: Memorizza tutti i form di registrazioneid(SERIAL PRIMARY KEY)user_type(COMPANY | SPECIALIST)name,email,company,linkedin,messagecreated_at,ip_address,user_agentstatus(new, contacted, closed)notes(per uso interno)
- Abilita la 2-Step Verification sul tuo account Google
- Genera una App Password:
- Vai su myaccount.google.com/apppasswords
- Genera una password per "Mail"
- Usa queste credenziali:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=request@certicredia.org
SMTP_PASS=your-16-char-app-passwordSMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=apikey
SMTP_PASS=your-sendgrid-api-keyContatta il tuo provider email e richiedi:
- SMTP Host
- SMTP Port
- Username
- Password
-
Crea un account su Render.com
-
Connetti il repository GitHub:
- New → Web Service
- Collega il tuo repository GitHub
-
Render rileverà automaticamente il file
render.yaml -
Configura le Environment Variables:
- Dashboard → Environment
- Aggiungi tutte le variabili da
.env.example:DATABASE_URLSMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASS- Altre variabili necessarie
-
Deploy!
- Render installerà le dipendenze e avvierà il server automaticamente
- Vai su Render Dashboard
- New → Web Service
- Configurazioni:
- Build Command:
npm install - Start Command:
npm start - Environment: Node
- Branch:
main(o il tuo branch)
- Build Command:
certicredia/
├── server/
│ ├── config/
│ │ ├── database.js # Connessione PostgreSQL
│ │ └── email.js # Configurazione Nodemailer
│ ├── controllers/
│ │ └── contactController.js # Logica business form
│ ├── middleware/
│ │ └── validation.js # Validazione input
│ ├── routes/
│ │ └── contact.js # API routes
│ ├── utils/
│ │ └── logger.js # Utility logging
│ └── index.js # Entry point server
├── index.html # Frontend
├── app.js # JavaScript frontend
├── styles.css # Stili CSS
├── package.json # Dipendenze
├── .env.example # Template variabili ambiente
├── render.yaml # Configurazione Render
└── README.md # Questa guida
Invia un form di contatto.
Body (JSON):
{
"userType": "COMPANY",
"name": "Mario Rossi",
"email": "mario@example.com",
"company": "Acme Inc. - P.IVA 12345678901",
"message": "Vorrei maggiori informazioni sulla certificazione CPF3"
}Response:
{
"success": true,
"message": "Richiesta ricevuta con successo. Ti contatteremo entro 24 ore.",
"data": {
"id": 123,
"userType": "COMPANY",
"name": "Mario Rossi",
"email": "mario@example.com",
"createdAt": "2025-11-29T10:30:00.000Z"
}
}Health check del server e database.
Response:
{
"status": "ok",
"timestamp": "2025-11-29T10:30:00.000Z",
"database": "connected"
}Recupera tutti i contatti (da proteggere con autenticazione).
Query params:
status- Filtra per stato (new, contacted, closed)userType- Filtra per tipo (COMPANY, SPECIALIST)limit- Numero massimo risultati (default: 50)offset- Offset per paginazione (default: 0)
- Helmet.js - Security headers HTTP
- CORS - Cross-Origin Resource Sharing configurabile
- Rate Limiting - 100 richieste per IP ogni 15 minuti
- Input Validation - express-validator per sanitizzazione
- SQL Injection Protection - Query parametrizzate con pg
- XSS Protection - Sanitizzazione input
-
Avvia il server:
npm start
-
Apri il browser su
http://localhost:3000 -
Compila il form di contatto e invia
-
Verifica:
- Email ricevuta su
NOTIFICATION_EMAIL - Auto-risposta ricevuta sull'email inserita nel form
- Dato salvato nel database
- Email ricevuta su
curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"userType": "COMPANY",
"name": "Test User",
"email": "test@example.com",
"company": "Test Company",
"message": "Test message"
}'-- Tutti i contatti
SELECT * FROM contacts ORDER BY created_at DESC;
-- Solo aziende
SELECT * FROM contacts WHERE user_type = 'COMPANY';
-- Nuovi contatti non gestiti
SELECT * FROM contacts WHERE status = 'new';UPDATE contacts
SET status = 'contacted', notes = 'Email inviata il 29/11/2025'
WHERE id = 123;- Verifica che
DATABASE_URLsia corretto - Controlla che Neon sia attivo e raggiungibile
- Verifica SSL mode:
?sslmode=require
- Verifica tutte le variabili SMTP in
.env - Controlla username/password SMTP
- Per Gmail, usa App Password, non la password normale
# Trova il processo che usa la porta 3000
lsof -ti:3000
# Uccidi il processo
kill -9 $(lsof -ti:3000)- Area riservata utenti - Autenticazione JWT
- E-commerce - Sistema di pagamento per certificazioni
- Admin Dashboard - Gestione contatti e ordini
- CRM Integration - Webhook per HubSpot/Salesforce
- Analytics - Dashboard metriche e statistiche
- Multi-lingua - Supporto EN/IT
Copyright © 2025 CertiCredia Italia S.r.l.
Per assistenza tecnica:
- Email: request@certicredia.org
- GitHub: github.com/xbeat/certicredia
Fatto con ❤️ per la sicurezza del futuro digitale
Il progetto include 8 prodotti certificazioni pre-configurati:
npm run seedQuesto creerà:
- Certificazione CPF3 Base (€2999)
- Certificazione CPF3 Professional (€7999)
- Certificazione CPF3 Enterprise (€19999)
- Corso Auditor CertiCredia (€1999)
- Audit NIS2 Compliance (€4999)
- Penetration Test Base (€3499)
- Formazione GDPR Aziendale (€999)
Il progetto include 5 pagine complete:
- Grid responsivo prodotti
- Filtri per categoria
- Aggiunta rapida al carrello
- Badge carrello real-time
- Gestione quantità
- Rimozione articoli
- Calcolo totale con IVA
- Riepilogo ordine
- Tab Login/Registrazione
- Validazione form
- JWT token management
- Redirect automatico
- Form dati fatturazione
- Pre-compilazione da profilo
- Selezione metodo pagamento
- Riepilogo ordine finale
- Lista ordini utente
- Stato ordini in tempo reale
- Gestione profilo
- Statistiche certificazioni
Tutte le pagine sono:
- ✅ Mobile responsive
- ✅ Styled con Tailwind CSS
- ✅ Integrate con API backend
- ✅ Error handling completo
- ✅ Loading states
- Guest Cart: Carrello persistente per utenti non loggati (session-based)
- User Cart: Carrello associato all'utente autenticato
- Cart Merge: Unione automatica carrello guest → user al login
- Quantità: Gestione quantità con + / - buttons
- Real-time Updates: Badge aggiornato automaticamente
- Form validato lato client e server
- Pre-compilazione dati da profilo utente
- Supporto pagamento bonifico (default)
- Stripe integration ready (commentato)
- Generazione order number unico
- Tracking completo stati (pending, confirmed, processing, completed)
- Storico ordini per utente
- Dettaglio items per ordine
- Email automatiche (conferma + notifica admin)
Inviata automaticamente alla creazione ordine:
- Numero ordine e data
- Lista prodotti acquistati
- Totale e metodo pagamento
- Istruzioni prossimi passi
Notifica al team CertiCredia:
- Dati cliente completi
- Dettaglio prodotti
- Indirizzo fatturazione
- Informazioni contatto
Template HTML professionali con:
- Design responsive
- Branding CertiCredia
- Colori aziendali
- Call-to-action chiare
- Access Token: Valido 7 giorni
- Refresh Token: Valido 30 giorni
- Storage: localStorage + httpOnly cookies
- Auto-refresh su richieste API
- Hash con bcrypt (12 rounds)
- Validazione: min 8 caratteri, maiuscola, minuscola, numero
- Change password con verifica password attuale
- user: Accesso shop, ordini, profilo
- admin: Accesso pannello admin, gestione prodotti/ordini
Registrazione nuovo utente
{
"email": "mario@example.com",
"password": "Password123",
"name": "Mario Rossi",
"company": "Acme Inc",
"phone": "+39 333 1234567"
}Login utente
{
"email": "mario@example.com",
"password": "Password123"
}Logout utente (cancella cookie)
Ottieni profilo utente corrente (richiede auth)
Aggiorna profilo utente (richiede auth)
Cambia password (richiede auth)
Lista tutti i prodotti attivi
- Query params:
?category=Certificazioni
Dettaglio prodotto per slug
Crea nuovo prodotto
Aggiorna prodotto
Elimina prodotto (soft delete)
Tutti i prodotti (inclusi inattivi)
Ottieni carrello (guest o user)
Aggiungi al carrello
{
"product_id": 1,
"quantity": 1
}Aggiorna quantità item
{
"quantity": 2
}Rimuovi item dal carrello
Svuota carrello
Unisci carrello guest con user (auto al login)
Crea nuovo ordine da carrello
{
"billing_name": "Mario Rossi",
"billing_email": "mario@example.com",
"billing_phone": "+39 333 1234567",
"billing_address": "Via Roma 1",
"billing_city": "Milano",
"billing_postal_code": "20100",
"billing_country": "Italia",
"payment_method": "bank_transfer",
"notes": "Note opzionali"
}Lista ordini utente corrente
Dettaglio ordine (con items)
Tutti gli ordini (con filtri)
- Query params:
?status=pending&limit=50&offset=0
Aggiorna stato ordine
{
"status": "confirmed",
"payment_status": "paid",
"notes": "Pagamento ricevuto"
}Crea Stripe payment intent (per pagamenti carta)
Form contatto homepage (esistente)
Lista contatti
Verifica stato server e database
{
"status": "ok",
"timestamp": "2025-11-29T...",
"database": "connected"
}Gestisce tutte le funzionalità client-side:
// State Management
- state.user
- state.cart
- state.products
- state.orders
// API Calls
- Auth: register(), login(), logout(), getProfile()
- Products: getProducts(), getProduct(slug)
- Cart: getCart(), addToCart(), updateCartItem(), removeFromCart()
- Orders: createOrder(), getOrders(), getOrder()
// Page Initializers
- initShopPage(): Product catalog
- initCartPage(): Shopping cart
- initAuthPage(): Login/Register
- initCheckoutPage(): Checkout form
- initDashboardPage(): User dashboard
// UI Helpers
- notify(message, type): Toast notifications
- updateCartBadge(count): Real-time badge
- updateAuthUI(): Login/Logout buttons- Vanilla JavaScript (no frameworks)
- Tailwind CSS (via CDN)
- Fetch API (async/await)
- localStorage (JWT tokens)
- Cookies (session management)
- Crea Web Service da dashboard Render
- Connetti GitHub repo
- Auto-rileva
render.yaml - Aggiungi Environment Variables:
NODE_ENV=production
PORT=3000
DATABASE_URL=<neon-postgres-url>
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=request@certicredia.org
SMTP_PASS=<your-smtp-password>
NOTIFICATION_EMAIL=request@certicredia.org
JWT_SECRET=<generate-random-32-chars>
STRIPE_SECRET_KEY=<optional-stripe-key>- Deploy - Render compilerà e avvierà automaticamente
# Popola prodotti (esegui una volta)
# Connettiti via Render Shell e esegui:
npm run seedcerticredia/
├── server/
│ ├── config/
│ │ ├── auth.js # JWT configuration
│ │ ├── database.js # PostgreSQL + schema
│ │ └── email.js # Nodemailer + templates
│ ├── controllers/
│ │ ├── authController.js
│ │ ├── cartController.js
│ │ ├── contactController.js
│ │ ├── orderController.js
│ │ └── productController.js
│ ├── middleware/
│ │ ├── auth.js # JWT verification
│ │ ├── authValidation.js
│ │ └── validation.js
│ ├── routes/
│ │ ├── auth.js
│ │ ├── cart.js
│ │ ├── contact.js
│ │ ├── orders.js
│ │ └── products.js
│ ├── utils/
│ │ ├── logger.js
│ │ └── seedProducts.js
│ └── index.js # Main server
├── public/
│ └── assets/ # Images, files
├── index.html # Homepage
├── shop.html # Product catalog
├── cart.html # Shopping cart
├── auth.html # Login/Register
├── checkout.html # Checkout page
├── dashboard.html # User dashboard
├── shop.js # Frontend JS
├── app.js # Homepage JS
├── styles.css # Custom CSS
├── package.json
├── .env.example
├── render.yaml
└── README.md
npm start # Avvia server produzione
npm run dev # Avvia server development (auto-reload)
npm run seed # Popola database con prodotti
npm test # Run tests (da implementare)- contacts - Form registrazioni homepage
- users - Utenti registrati (auth)
- products - Catalogo certificazioni
- cart - Carrelli (guest + user)
- orders - Ordini effettuati
- order_items - Righe ordine
- user_certifications - Certificati emessi (future)
Tutte le tabelle hanno:
- ✅ Indici ottimizzati
- ✅ Foreign keys con cascade
- ✅ Timestamps (created_at, updated_at)
- ✅ Check constraints
- Autenticazione JWT completa
- CRUD prodotti
- Gestione carrello (guest + user)
- Sistema ordini
- Email notifications
- Admin endpoints
- Validazione input
- Error handling
- Rate limiting
- Security headers (Helmet)
- Shop con catalogo
- Carrello funzionante
- Login/Register
- Checkout completo
- Dashboard utente
- Mobile responsive
- Loading states
- Toast notifications
- Real-time cart badge
- Schema completo
- Indici performance
- Seed prodotti
- Migrations ready
- Admin Panel UI
- Stripe live integration
- Email verification
- Password reset flow
- Invoice generation
- Advanced analytics
- Avvia server:
npm run dev - Popola DB:
npm run seed - Apri browser:
http://localhost:3000 - Vai su
/shop.html - Registrati un account
- Aggiungi prodotti al carrello
- Completa checkout
- Controlla email (se SMTP configurato)
Per assistenza:
- Email: request@certicredia.org
- GitHub Issues: Apri ticket
Copyright © 2025 CertiCredia Italia S.r.l.
Sistema E-commerce Completo - Ready for Production! 🚀
Oltre 6000 righe di codice professional-grade.