Skip to content

ConsciousClouds/Campana-Ranch-Wines

Repository files navigation

Campana Ranch Wines - Modular Monolith Architecture

A modern, scalable e-commerce platform for Campana Ranch Wines, built with Next.js 14+, TypeScript, and a modular monolith architecture. Integrates with Commerce7 for wine commerce and supports free CMS options like Strapi.

πŸ—οΈ Architecture Overview

This project implements a modular monolith architecture, providing:

  • Clear module boundaries with defined interfaces
  • Shared kernel for common functionality
  • Event-driven inter-module communication
  • Ready for microservices migration if needed

Key Modules

  • Catalog: Wine product management and display
  • Commerce: Commerce7 integration, cart, and checkout
  • Content: CMS integration for pages and blog
  • Club: Wine club management
  • Customer: Authentication and user profiles
  • Events: Event management and bookings
  • Analytics: Tracking and reporting

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Commerce7 account (for e-commerce functionality)
  • Strapi instance (optional, for CMS)

Installation

  1. Clone the repository:
git clone https://github.com/your-org/campana-ranch-wines.git
cd campana-ranch-wines
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env.local
  1. Configure your .env.local with:

    • Commerce7 API credentials
    • CMS API URL and token (if using Strapi)
    • Other optional services
  2. Run the development server:

npm run dev

Open http://localhost:3000 to see the application.

πŸ“ Project Structure

campana-ranch-wines/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ modules/           # Business modules
β”‚   β”‚   β”œβ”€β”€ catalog/       # Wine catalog
β”‚   β”‚   β”œβ”€β”€ commerce/      # E-commerce & checkout
β”‚   β”‚   β”œβ”€β”€ content/       # CMS content
β”‚   β”‚   β”œβ”€β”€ club/          # Wine club
β”‚   β”‚   β”œβ”€β”€ customer/      # User management
β”‚   β”‚   β”œβ”€β”€ events/        # Events & tastings
β”‚   β”‚   └── analytics/     # Analytics tracking
β”‚   β”‚
β”‚   β”œβ”€β”€ shared/            # Shared kernel
β”‚   β”‚   β”œβ”€β”€ components/    # Common UI components
β”‚   β”‚   β”œβ”€β”€ hooks/         # Shared React hooks
β”‚   β”‚   β”œβ”€β”€ utils/         # Utility functions
β”‚   β”‚   β”œβ”€β”€ types/         # Shared TypeScript types
β”‚   β”‚   └── config/        # Configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ infrastructure/    # Technical infrastructure
β”‚   β”‚   β”œβ”€β”€ database/      # Database utilities
β”‚   β”‚   β”œβ”€β”€ cache/         # Caching layer
β”‚   β”‚   └── monitoring/    # Logging & monitoring
β”‚   β”‚
β”‚   └── app/               # Next.js App Router
β”‚       β”œβ”€β”€ (public)/      # Public routes
β”‚       β”œβ”€β”€ (authenticated)/ # Protected routes
β”‚       └── api/           # API routes
β”‚
β”œβ”€β”€ tests/                 # Test suites
β”œβ”€β”€ docs/                  # Documentation
└── public/                # Static assets

πŸ› οΈ Available Scripts

npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint
npm run type-check   # TypeScript type checking
npm run format       # Format code with Prettier
npm run test         # Run tests
npm run analyze      # Analyze bundle size

πŸ”§ Module Development

Creating a New Module

  1. Create module directory structure:
mkdir -p src/modules/your-module/{api,components,data,domain,types}
  1. Define the module's public API in index.ts
  2. Keep all internal logic private to the module
  3. Use the event bus for cross-module communication

Module Communication

Modules communicate via the event bus:

import { eventBus, ModuleEvents } from '@shared/utils/event-bus'

// Emit an event
eventBus.emit(ModuleEvents.WINE_ADDED_TO_CART, { wineId, quantity })

// Subscribe to events
eventBus.on(ModuleEvents.ORDER_PLACED, handleOrderPlaced)

πŸ”Œ External Integrations

Commerce7

The Commerce module integrates with Commerce7 for:

  • Product catalog sync
  • Cart and checkout
  • Customer management
  • Wine club operations
  • Order processing

Configure in .env.local:

NEXT_PUBLIC_COMMERCE7_API_URL=https://api.commerce7.com/v1
NEXT_PUBLIC_COMMERCE7_TENANT_ID=your-tenant-id
COMMERCE7_API_KEY=your-api-key

Strapi CMS (Free Option)

The Content module can integrate with Strapi for:

  • Page content management
  • Blog posts
  • Event listings
  • Media management

Configure in .env.local:

NEXT_PUBLIC_CMS_API_URL=http://localhost:1337
CMS_API_TOKEN=your-strapi-token

🎨 Styling

The project uses Tailwind CSS with custom wine-themed configuration:

  • Custom color palette (wine, cream, gold)
  • Typography presets
  • Animation utilities
  • Responsive design system

🚒 Deployment

Vercel (Recommended)

  1. Push to GitHub
  2. Import project in Vercel
  3. Configure environment variables
  4. Deploy

Docker

docker build -t campana-ranch-wines .
docker run -p 3000:3000 campana-ranch-wines

πŸ“ˆ Performance

  • Modular architecture for code splitting
  • Image optimization with Next.js Image
  • API response caching
  • Static page generation where possible
  • Progressive Web App capabilities

πŸ”’ Security

  • Environment variables for sensitive data
  • API route protection
  • Input validation
  • CORS configuration
  • Rate limiting on API routes

πŸ§ͺ Testing

npm run test:unit        # Unit tests
npm run test:integration # Integration tests
npm run test:e2e        # End-to-end tests

πŸ“š Documentation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Write/update tests
  5. Submit a pull request

πŸ“„ License

Copyright Β© 2024 Campana Ranch Wines. All rights reserved.

πŸ†˜ Support

For issues and questions:


Built with ❀️ using Next.js, TypeScript, and modular architecture principles.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages