A high-performance, full-stack fashion web application built with Node.js, Express, EJS, Microsoft SQL Server, Socket.IO, and Resend email service, featuring high-end neo-brutalist typography and editorial streetwear aesthetics.
- Live URL: https://modashop.store
- Key Features
- Technology Stack
- Project Directory Structure
- Environment Configuration
- Email System (Resend Integration)
- Database System (MSSQL on Azure)
- Deployment Guide
- Custom Domain Setup
- Security Architecture
- Known Limitations & Future Roadmap
- License
- User Authentication & Session Management: Secure user accounts with hashed passwords (bcrypt), express-session state storage, and dynamic role determination.
- Email Verification Flow: Signups require a verified email address via transactional verification tokens.
- Dynamic Search & Filtering: Complex search page equipped with responsive categories, tag filters, sorting (price, reviews, rating), and desktop-sticky filter columns.
- Interactive Shopping Cart & Wishlist: Pure AJAX-based product interactions avoiding page refreshes, and syncs instantly with database records.
- Interactive Reviews & Rating System: Post, edit, or delete star ratings and text reviews for purchased items, automatically recalculating product averages.
- Real-Time Web Notification Portal: Dynamic Socket.IO alert overlay for order updates, transactional confirmations, and custom notifications.
- Multi-Step Checkout: Client-side form validations and automated calculations for tax and shipping rates.
- CLS-Optimized Visual Loading: Progressive image loading via custom fade-in transitions, lazy loading (
loading="lazy"), and base64 SVG shims to resolve Cumulative Layout Shift (CLS). - Responsive Layouts: Premium neo-brutalist theme components optimized for desktop, tablet, and mobile device viewport widths.
| Component | Technology | Description |
|---|---|---|
| Backend Framework | Node.js / Express | Server-side routing, controllers, and APIs |
| Database | Microsoft SQL Server (MSSQL) | Primary data layer hosted on Azure SQL |
| View Engine | EJS (Embedded JavaScript) | Server-rendered pages with custom partial components |
| Session Manager | Connect MSSQL v2 | Server-side sessions persisted inside MSSQL database |
| WebSockets | Socket.IO | Real-time live notifications and update broadcasts |
| Emails | Resend Node.js SDK | Dedicated transactional email gateway |
| Media Delivery | Multer + Cloudinary SDK | File uploads and optimized image CDN delivery |
| Styling | Bootstrap 5 + Tailwind CSS | Hybrid utility layout framework and design tokens |
.
├── cloudinary/ # Cloudinary storage engine and API configuration
├── database/ # SQL database pool configuration and migrate/seed routines
├── email-templates/ # Local HTML email templates (verification, reset, orders)
├── helper-functions/ # Shared utility helpers (emails, rating engines, logging, validators)
├── middleware/ # Route guards (auth checking, CSRF validation, helmet security headers)
├── partials/ # Reusable UI EJS components (headers, navbars, footers, scripts)
├── public/ # Static styling files (custom CSS, fonts, assets, client scripts)
│ ├── css/ # Page CSS overrides (global, search, product details, auth)
│ └── js/ # Client side AJAX handlers and layout interactivity
├── routes/ # Express route controllers divided by feature areas
├── seeds/ # Seed database contents (mock catalog files and reviews JSON)
├── views/ # Primary EJS page layout views
│ └── auth/ # Access forms (login, signup, forgot password, reset)
├── config.js # Centralized configurations and environment variable parser
├── main.js # Unified application entry point
├── package.json # Scripts, dependency locks, and metadata
└── tailwind.config.js # Layout grid presets for custom styles
Create a .env file in your project's root folder using the parameters below:
| Variable | Description | Example Value |
|---|---|---|
PORT |
Local server port | 3000 |
NODE_ENV |
Mode of operation | production / development |
BASE_URL |
Base host domain | https://modashop.store |
DB_USER |
SQL Database username | moda_admin |
DB_PASSWORD |
SQL Database password | SecureSQLPass123! |
DB_SERVER |
Server URI / Azure Address | moda-server.database.windows.net |
DB_PORT |
MSSQL connection port | 1433 |
DB_NAME |
MSSQL database schema name | modadb |
SESSION_SECRET |
Secret key used to encrypt cookies | 8e3a2b7f8c92a7281f9b33a01 |
RESEND_API_KEY |
Resend API Authorization Token | re_123456789g |
CLOUDINARY_CLOUD_NAME |
Cloudinary unique name ID | modacloud |
CLOUDINARY_API_KEY |
Cloudinary public api key | 928138291029 |
CLOUDINARY_API_SECRET |
Cloudinary private secret key | xX_SecretApiToken_Xx |
The application uses the high-deliverability Resend API SDK to dispatch transactional emails. To keep email setups version-controlled under Git, the system bypasses Resend's online template editor portal entirely, instead loading local HTML templates from the email-templates/ directory and substituting placeholders dynamically.
- Verification Email (
verification.html)- Purpose: Welcome new users and request activation.
- Placeholders:
{{{firstname}}},{{{verifyUrl}}}
- Password Reset Email (
password-reset.html)- Purpose: Provide link to recover accounts.
- Placeholders:
{{{firstname}}},{{{resetUrl}}}
- Password Updated Email (
password-updated.html)- Purpose: Send security confirmation when account password changes.
- Placeholders:
{{{firstname}}}
- Order Status Confirmation (
order-status.html)- Purpose: Updates customers on changes in order status.
- Placeholders:
{{{title}}},{{{headerTitle}}},{{{message}}},{{{ctaText}}},{{{ctaUrl}}}
- Contact Support Email (
contact-support.html)- Purpose: Sends a structured ticket outline to customer support.
- Placeholders:
{{{senderName}}},{{{senderEmail}}},{{{subject}}},{{{message}}}
All system communications use dedicated, domain-authenticated mail headers to prevent spam flag filters:
- Transactional updates (verifications, passwords):
Moda <noreply@modashop.store> - Order status alerts (receipts, delivery):
Moda Orders <orders@modashop.store> - Customer service / contact requests:
Moda Support <support@modashop.store>
- Verification Email Throttling: Users are restricted to 1 email verification resend request every 24 hours. The verification token expires in 24 hours.
- Password Reset Throttling: Users are restricted to 1 password reset request every 12 hours. The generated reset link expires in 12 hours.
- Safe Database State Order: To prevent race conditions or orphaned/unused tokens accumulating in the database when the email provider fails, the system uses a strict "Email Success before Database Write" flow. The verification or reset token is generated in memory and the email is attempted first. Only after the email provider returns a success code are the changes written to the database (and any old tokens invalidated). If the send fails, the token is discarded in memory, keeping the database clean and allowing the user to retry immediately.
The application uses Azure SQL Database as its primary storage engine.
- When the application starts, it connects to Azure SQL and executes
database/migrate.jsto automatically verify schema columns. - It checks for
reset_token,reset_expires, andis_seedcolumns on theuserstable, and automatically patches them into your schema structure. - Is_Seed User Flag: All seed reviewer accounts are flagged with
is_seed = 1. This isolates seed profiles and their testing activity from your live analytics metrics, administrative lists, or real customer operations.
Follow these steps to deploy the application on Render:
git clone https://github.com/your-username/moda-ecommerce.git
cd moda-ecommercenpm install- Create a
.envfile in the root folder. - Fill out the environment variables according to the table in Environment Configuration.
- Start the local server:
npm run dev
- Register/Login on Render.
- Click New + and select Web Service.
- Connect your GitHub repository.
- Set the following settings:
- Runtime:
Node - Build Command:
npm install - Start Command:
npm start
- Runtime:
- Go to the Environment tab and add all the environment variables from your
.envfile (excludingPORTas Render assigns it automatically). - Click Deploy Web Service.
To configure a custom domain like modashop.store using Namecheap or other domain registrars:
Log in to your Namecheap account, navigate to Advanced DNS, and add the following records:
| Type | Host | Value | TTL |
|---|---|---|---|
| A Record / ALIAS | @ |
Render Web Service IP Address (e.g., 216.24.57.1) |
Automatic |
| CNAME Record | www |
Your Render domain (e.g., moda-app.onrender.com) |
Automatic |
- Open your Render Web Service dashboard.
- Navigate to Settings and scroll down to the Custom Domains section.
- Click Add Custom Domain and enter
modashop.store(and optionallywww.modashop.store). - Click Save. Render will automatically verify the DNS records and issue a free Let's Encrypt SSL certificate.
The application implements a production-grade defense stack to protect client data:
- Helmet Middleware: Enforces secure HTTP headers including strict Content Security Policy (CSP), HTTP Strict Transport Security (HSTS), Frame Options, and X-Content-Type-Options.
- CSRF Token Validation: Employs double-submit cookie validations for state-changing endpoints (POST/PUT/DELETE) to shield user routes from Cross-Site Request Forgery.
- Express Rate Limiters: Protects routes from brute-force authentication attempts (signups, logins, and password resets capped at 15 requests per 15 minutes) and standard requests (capped at 200 per 15 minutes).
- Token Rate Limiting & Lifecycle Controls: Employs a 12-hour expiration on password reset links and 24-hour expiration on verification resends, coupled with an "Email success before Database Write" transactional policy to block brute forcing and prevent orphaned state leaks.
- Secure Cookie Directives: Cookies are configured with
HttpOnly,SameSite=Lax, andSecure(in production) to prevent cookie sniffing and hijacking. - Azure SQL Firewall Rules: Only whitelisted IP addresses (such as Render's server IPs) are permitted to open connections to the MSSQL database.
- Data Input Sanitization: Form fields use parameterized SQL queries inside the
mssqlpool, eliminating SQL injection vectors.
- Startup Schema Check: Schema checks run synchronously during server start; in large enterprise scenarios, schema migrations should be managed via dedicated migrations tools (like Knex or Sequelize CLI).
- Payment Gateway: Current checkout processes are mock transactions. Integration with Stripe or PayPal is planned.
- Cache Layer: Product query results are served directly from MSSQL. Implementing Redis cache queries for product listings would optimize retrieval times.
This project is licensed under the MIT License. See the license file for details.