Skip to content

billyndroid/barebones

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Barebones E-Commerce Platform

A modern, full-stack e-commerce application built with cutting-edge technologies for scalability and performance.

πŸš€ Tech Stack

Backend

  • Framework: Fastify (high-performance Node.js web framework)
  • Database: PostgreSQL with Prisma ORM
  • Language: TypeScript
  • Authentication: JWT-based auth system
  • Integration: Shopify webhooks and API

Frontend

  • Framework: Next.js 14 with React 18
  • Language: TypeScript
  • Styling: Modern CSS with responsive design
  • State Management: React Context API
  • HTTP Client: Axios

πŸ“ Project Structure

barebones/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                    # Backend API Server
β”‚   β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   β”‚   └── schema.prisma   # Database schema
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/         # API route handlers
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ auth.ts     # Authentication routes
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ products.ts # Product management
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ orders.ts   # Order processing
β”‚   β”‚   β”‚   β”‚   └── checkout.ts # Checkout flow
β”‚   β”‚   β”‚   β”œβ”€β”€ services/       # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ utils/          # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ prisma/         # Database client
β”‚   β”‚   β”‚   β”œβ”€β”€ seed.ts         # Database seeding
β”‚   β”‚   β”‚   └── index.ts        # Server entry point
β”‚   β”‚   └── package.json
β”‚   └── web/                    # Frontend Next.js App
β”‚       β”œβ”€β”€ components/         # React components
β”‚       β”‚   β”œβ”€β”€ AuthModal.tsx   # User authentication
β”‚       β”‚   β”œβ”€β”€ CartSidebar.tsx # Shopping cart
β”‚       β”‚   β”œβ”€β”€ ProductGrid.tsx # Product display
β”‚       β”‚   └── Header.tsx      # Navigation
β”‚       β”œβ”€β”€ contexts/           # React contexts
β”‚       β”‚   β”œβ”€β”€ AuthContext.tsx # Authentication state
β”‚       β”‚   β”œβ”€β”€ CartContext.tsx # Cart management
β”‚       β”‚   └── ToastContext.tsx# Notifications
β”‚       β”œβ”€β”€ pages/              # Next.js pages
β”‚       β”‚   β”œβ”€β”€ index.tsx       # Home page
β”‚       β”‚   β”œβ”€β”€ products.tsx    # Product catalog
β”‚       β”‚   β”œβ”€β”€ orders.tsx      # Order history
β”‚       β”‚   └── profile.tsx     # User profile
β”‚       └── package.json
β”œβ”€β”€ package.json                # Root package.json (workspace)
└── README.md

πŸ›  Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone https://github.com/billyndroid/barebones.git
    cd barebones
  2. Install dependencies

    npm install
  3. Set up environment variables

    # Copy environment template
    cp .env.example .env

    Configure your database connection and other settings in .env

  4. Initialize the database

    # Generate Prisma client
    npm run db:generate --workspace=apps/api
    
    # Push schema to database
    npm run db:push --workspace=apps/api
    
    # Seed with sample data (optional)
    npm run db:seed --workspace=apps/api
  5. Start development servers

    # Start both API and web servers
    npm run dev
    
    # Or start individually:
    npm run dev:api    # API server only
    npm run dev:web    # Web app only

🌐 Development Servers

πŸ“‘ API Endpoints

Products

  • GET /api/products - List all products
  • GET /api/products/:id - Get single product
  • POST /api/products - Create product (admin)
  • PUT /api/products/:id - Update product (admin)
  • DELETE /api/products/:id - Delete product (admin)

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout
  • GET /api/auth/profile - Get user profile

Orders

  • GET /api/orders - Get user orders
  • POST /api/orders - Create new order
  • GET /api/orders/:id - Get specific order

Checkout & Payments

  • POST /api/checkout/create-payment-intent - Create Stripe PaymentIntent
  • POST /api/checkout/confirm-payment/:orderId - Confirm payment completion
  • POST /api/checkout/complete/:orderId - Complete order (legacy/demo)
  • POST /api/checkout/webhook/stripe - Handle Stripe webhooks
  • GET /api/checkout/order-status/:orderId - Get order payment status

🎯 Features

Implemented

  • βœ… Product catalog with search and filtering
  • βœ… User authentication (register/login)
  • βœ… Shopping cart functionality
  • βœ… Order management
  • βœ… Responsive design
  • βœ… TypeScript throughout
  • βœ… Database with Prisma ORM
  • βœ… Error handling and validation
  • βœ… CORS configuration
  • βœ… Health monitoring

Recently Added

  • βœ… Payment integration foundation (Stripe-ready architecture)
  • βœ… Enhanced checkout flow with payment tracking
  • βœ… Order payment status management

Planned

  • πŸ”„ Full Stripe Elements integration (see STRIPE_SETUP.md)
  • πŸ”„ Admin dashboard
  • πŸ”„ Product reviews and ratings
  • πŸ”„ Email notifications
  • πŸ”„ Inventory management
  • πŸ”„ Shopify integration completion

πŸ—„οΈ Database Schema

The application uses PostgreSQL with the following main entities:

  • Users: Customer accounts and authentication
  • Products: Product catalog with pricing and descriptions
  • Orders: Purchase orders and transaction history
  • OrderItems: Individual items within orders

πŸ”§ Available Scripts

# Root level commands
npm run dev              # Start both API and web servers
npm run dev:api          # Start API server only
npm run dev:web          # Start web server only
npm run build            # Build both applications
npm run db:generate      # Generate Prisma client
npm run db:push          # Push schema to database
npm run db:seed          # Seed database with sample data

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ› Troubleshooting

Common Issues

Port conflicts: If ports 3000 or 3001 are in use:

# Kill existing processes
taskkill /F /IM node.exe
# Or change ports in the configuration

Database connection: Ensure PostgreSQL is running and connection string is correct in .env

CORS errors: The API is configured to allow requests from localhost:3000 and localhost:3002

Support

For issues and questions, please open an issue on GitHub or contact the development team.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors