Back to all projects

Fullstack E-Commerce Platform - Class Final Project

Next.jsGolangFullstack DevelopmentE-commerceAPI DesignShopping CartOrder Management
Fullstack E-Commerce Platform - Class Final Project

Timeline

Nov 2024 - Dec 2024

My Role

Fullstack Developer

Type

E-commerce Web Application

Project Overview

This fullstack e-commerce platform was developed as a final project for a framework programming class, leveraging Next.js for the frontend and Golang for the backend. The platform allows users to register, log in, browse products, manage their shopping carts, and place orders. The backend supports complex operations such as user authentication, product management, and order processing with secure API endpoints.

Key Features

  • User Authentication: Users can register, log in, and manage their accounts, with secure password hashing and role-based access control (user/admin).
  • Product Management: Users and admins can view, add, edit, and delete products. Products are displayed with details such as price, stock quantity, and category.
  • Shopping Cart: Users can add products to their cart, update item quantities, and proceed to checkout. The cart state is preserved for users during their session.
  • Order Management: Users can place orders, view order statuses, and admins can update order status (e.g., pending, shipped).
  • RESTful API: A clean API designed in Golang to handle CRUD operations for users, products, carts, and orders.

Technical Approach

  • Frontend: The frontend is built using Next.js, providing a dynamic, SEO-friendly single-page application (SPA) experience with server-side rendering (SSR) for optimal performance. The frontend communicates with the backend through RESTful API calls to perform actions such as logging in, adding products to the cart, and placing orders.

  • Backend: The backend is developed in Golang, utilizing GORM for ORM-based interaction with the PostgreSQL database. The backend handles user authentication (with hashed passwords), product CRUD operations, cart management, and order processing.

  • Database Design: The platform uses PostgreSQL to manage entities like User, Product, Cart, Order, and OrderItem, with relationships defined for efficient data handling. The data models include:

    • User: Stores user information, including name, email, password, and role (user/admin).
    • Product: Stores product details like name, price, stock quantity, and category.
    • Cart: Each user can have one cart, and products can be added to the cart.
    • Order: After checkout, an order is created, containing products with associated quantities.

API Endpoints

  • Auth:

    • POST /register: Register a new user.
    • POST /login: Login and obtain a token for authentication.
    • GET /me: Retrieve current user data.
    • DELETE /user/:id: Delete a user by ID.
  • Product:

    • GET /products: Get all products.
    • GET /product/:id: Get a specific product by ID.
    • POST /product: Add a new product.
    • PUT /product/:id: Edit product details.
    • DELETE /product/:id: Delete a product by ID.
  • Cart:

    • POST /cart: Add a product to the cart.
    • GET /cart: Get all products in the user's cart.
    • PUT /cart/:id: Update the quantity of an item in the cart.
  • Order:

    • POST /order: Create a new order from the cart.
    • GET /orders: Get all orders for the current user.
    • PUT /order/:id: Update order status (e.g., from 'pending' to 'shipped').

Development Process

The project was developed in an agile manner, starting with the backend models and APIs. Once the core API was ready, the frontend was developed using Next.js, focusing on providing a dynamic and interactive user experience. Afterward, both the frontend and backend were thoroughly tested to ensure seamless integration and smooth functionality.

Challenges

Integrating a smooth frontend experience with a robust Golang backend while managing complex relationships between users, products, carts, and orders.

Solutions

Developed a clean and intuitive frontend with Next.js, integrated with a Golang backend that efficiently handles user authentication, product management, and order processing. Implemented secure data storage and API endpoints for seamless communication.

Links