Skip to content
mjay-kerberosPublic

About

A Vite + React Shop for Gray Team Competition

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHOP

A 'Star Wars' inspired Vite + React Shop for Gray Team Competition

last-commit repo-top-language repo-language-count

Built with the tools and technologies:

Express JSON Markdown npm .ENV JavaScript
React Vite ESLint Bootstrap PostgreSQL Ansible


Table of Contents


Overview

Shop is a powerful collaborative platform designed for gray teams participating in the CDT competition, enabling seamless management of a virtual shop.

Why Shop?

This project enhances teamwork and streamlines e-commerce operations. The core features include:

  • 🛠️ Collaborative Platform: Facilitates teamwork among members, ensuring coordinated efforts in a competitive environment.
  • 🔒 User Authentication: Secure login and registration processes enhance user experience and protect sensitive data.
  • ⚙️ Robust Backend Architecture: Utilizes Express and PostgreSQL for efficient server-side operations and data management.
  • 🎨 Dynamic Frontend: Built with React and Vite, ensuring a responsive and engaging user interface.
  • 🚀 Error Handling: Graceful error management improves application stability and keeps users informed.
  • 📦 Inventory Management: Streamlined processes for product retrieval and purchase transactions enhance the shopping experience.

Features

Component Details
⚙️ Architecture
  • Client-Server architecture
  • React for frontend
  • Express for backend
  • PostgreSQL for database
🔩 Code Quality
  • ESLint for linting
  • Prettier for code formatting
  • TypeScript types for React components
📄 Documentation
  • README.md for project overview
  • Inline comments in code
  • API documentation in code comments
🔌 Integrations
  • Ant Design for UI components
  • bcryptjs for password hashing
  • dotenv for environment variable management
  • cors for handling CORS issues
🧩 Modularity
  • Separation of frontend and backend
  • Reusable React components
  • Modular Express routes
🧪 Testing
  • Jest for unit testing
  • React Testing Library for component testing
  • Integration tests for API endpoints
⚡️ Performance
  • Vite for fast development server
  • Code splitting for optimized loading
  • Efficient state management with React hooks
🛡️ Security
  • Password hashing with bcryptjs
  • Environment variables for sensitive data
  • Input validation on server-side
📦 Dependencies
  • React, React-DOM, React-Router-DOM
  • Express, pg for PostgreSQL
  • Ant Design, Bootstrap for UI
  • ESLint, Prettier for code quality
🚀 Scalability
  • Microservices architecture potential
  • Database can be scaled with PostgreSQL
  • Frontend can be optimized for larger applications

Database & Automation (db_setup)

This project includes an automated PostgreSQL setup using Ansible in the db_setup/ directory.

What db_setup does

The Ansible playbook:

  • Installs required system dependencies (e.g., bash, openssl, libssl-dev) on Debian-based systems.
  • Installs PostgreSQL and tools:
    • postgresql
    • postgresql-contrib
    • libpq-dev
    • python3-psycopg2
  • Ensures the PostgreSQL service is running and enabled at boot.
  • Creates the application database using variables (e.g., db_name, db_user, db_password).
  • Grants the application user the appropriate privileges on that database.
  • Copies the SQL initialization script init_db.sql to the target host and runs it as the postgres user.

Database schema

The init_db.sql script creates and seeds the core tables used by the Shop application:

  • products

    • Stores available items in the Gray Team shop.
    • Columns: id, name, price, image, description.
    • Preloaded with Star Wars–themed products such as Fire Cannons!, Repair Droids, Mind Probe, Force Barrier, and A Darth Wager.
  • users

    • Stores team login credentials.
    • Columns: username, password.
    • Seeded users: blue_team_1, blue_team_2, red_team, gray_team.
  • purchases

    • Tracks what each team buys and when.
    • Columns: purchase_id, user_id, product_id, quantity, purchase_date.
  • inventory

    • Enforces limited stock per product (e.g., quantity <= 10).
    • Columns: product_id, quantity.
  • team_credits

    • Manages starting and current credits for each team.
    • Columns: username, starting_credit, current_credit.

Together, the Ansible role and SQL initialization script allow you to spin up a fully seeded PostgreSQL database for the Shop application in a repeatable, competition-ready way.


Getting Started

Prerequisites

This project requires the following dependencies:

  • Programming Language: JavaScript
  • Package Manager: Npm

Installation

Build Shop from the source and intsall dependencies:

  1. Clone the repository:

    ❯ git clone https://github.com/mjay-kerberos/Shop
  2. Navigate to the project directory:

    ❯ cd Shop
  3. Install the dependencies:

Using npm:

❯ npm install

Usage

Run the project with:

Using npm:

npm start

Testing

Shop uses the {test_framework} test framework. Run the test suite with:

Using npm:

npm test

License

This project is licensed under the MIT License.


About

A Vite + React Shop for Gray Team Competition

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages