Skip to content
glitterfartzPublic

About

Full stack Customer Relationship Management (CRM) application built with a React frontend and a Node.js backend using Express and Prisma ORM.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

118 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Game Store Management System

[!TIP] Design Documents

[!IMPORTANT] Documentation

[!CAUTION] Testing

A full stack game retail management application for managing inventory, sales, and customer loyalty. Built with React 19, Express, PostgreSQL, and Prisma ORM.

Features

  • ๐ŸŽฎ Game Inventory Management: Add, edit, delete games with platforms (PC, PlayStation, Xbox, Nintendo, Mobile), pricing, and stock tracking
  • ๐Ÿ” IGDB Integration: Search for games from IGDB API and auto-populate inventory with game details
  • ๐Ÿ‘ฅ Customer Management: Manage customers with loyalty tier tracking (Standard, Gold, Platinum) and purchase history
  • ๐Ÿ’ฐ Sales Management: Create sales transactions with multi-item line items and real-time inventory tracking
  • ๐Ÿ“Š Analytics & Reports: View sales summaries, revenue by customer, top selling games, and staff performance metrics
  • ๐Ÿ” Role-Based Access: Support for User, Manager, and Admin roles with appropriate permissions
  • ๐ŸŽฏ Stock Alerts: Track low-stock inventory with dedicated low-stock view

Tech Stack

Frontend:

  • React 19 with TypeScript
  • Vite for fast development and production builds
  • Tailwind CSS v4 for styling
  • React Router v7 for navigation
  • Axios for API requests

Backend:

  • Node.js with Express
  • PostgreSQL 15 database
  • Prisma 6 ORM for database management
  • JWT authentication
  • TypeScript for type safety

DevOps:

  • Docker and Docker Compose for PostgreSQL
  • GitHub for version control

Project Structure

crm/
โ”œโ”€โ”€ client/                 # React frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/    # Reusable UI components and forms
โ”‚   โ”‚   โ”œโ”€โ”€ pages/         # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ lib/           # API client functions
โ”‚   โ”‚   โ”œโ”€โ”€ types/         # TypeScript type definitions
โ”‚   โ”‚   โ””โ”€โ”€ router/        # Route configuration
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ server/                # Express backend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ routes/        # API route handlers
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/    # Auth and other middleware
โ”‚   โ”‚   โ”œโ”€โ”€ prisma/        # Database schema and migrations
โ”‚   โ”‚   โ”œโ”€โ”€ services/      # Business logic (MobyGames API)
โ”‚   โ”‚   โ””โ”€โ”€ utils/         # Utility functions
โ”‚   โ”œโ”€โ”€ tests/             # Jest test files
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ docs/                  # Documentation and screenshots
โ”œโ”€โ”€ docker-compose.yml     # PostgreSQL setup
โ””โ”€โ”€ SPECIFICATIONS.md      # API documentation

Getting Started

Prerequisites

  • Node.js v18+
  • Docker and Docker Compose
  • npm or yarn

Installation

  1. Clone the repository

    git clone <repo-url>
    cd crm
  2. Install dependencies

    cd server && npm install
    cd ../client && npm install
  3. Set up environment variables Create .env files:

    server/.env:

    DATABASE_URL=postgresql://user:password@localhost:5432/game_store
    JWT_SECRET=your-secret-key
    PORT=5000
    NODE_ENV=development
    IGDB_CLIENT_ID=your-client-id
    IGDB_CLIENT_SECRET=your-client-secret
    

    client/.env.local:

    VITE_API_URL=http://localhost:5000
    
  4. Start PostgreSQL

    docker-compose up -d
  5. Initialize database

    cd server
    npx prisma migrate deploy
    npx prisma db seed
  6. Start development servers

    Terminal 1 (Backend):

    cd server
    npm run dev

    Terminal 2 (Frontend):

    cd client
    npm run dev
  7. Access the application

API Overview

Key Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • POST /api/auth/logout - Logout user

Customers

  • GET /api/customers - List customers (paginated)
  • POST /api/customers - Create customer
  • GET /api/customers/:id - Get customer details
  • PATCH /api/customers/:id - Update customer
  • DELETE /api/customers/:id - Delete customer

Inventory

  • GET /api/inventory - List games (paginated, filterable)
  • POST /api/inventory - Add game manually
  • GET /api/inventory/search?q=<query> - Search MobyGames API
  • POST /api/inventory/add-from-search - Add game from search results
  • GET /api/inventory/:id - Get game details with sales history
  • PATCH /api/inventory/:id - Update game
  • DELETE /api/inventory/:id - Delete game

Sales

  • GET /api/sales - List sales (paginated)
  • POST /api/sales - Create sale with line items
  • GET /api/sales/:id - Get sale details
  • PATCH /api/sales/:id - Update sale
  • DELETE /api/sales/:id - Delete sale

Reports

  • GET /api/reports/sales-summary - Sales metrics
  • GET /api/reports/revenue-by-customer - Revenue breakdown by customer
  • GET /api/reports/top-selling-games - Top games by quantity and revenue
  • GET /api/reports/user-performance - Staff performance metrics

See SPECIFICATIONS.md for complete API documentation.

Database Schema

Core Tables

  • User: System users with roles (USER, MANAGER, ADMIN)
  • Customer: Retail customers with loyalty tier tracking
  • Game: Game inventory with platforms, pricing, and stock
  • Sale: Sales transactions with status tracking
  • SaleLineItem: Individual items within sales (normalized from sales)
  • Activity: Audit trail for notes, tasks, calls, meetings

See server/src/prisma/schema.prisma for detailed schema.

Key Features

Inventory Management

  • Support for 6 platforms: PC, PlayStation, Xbox, Nintendo, Mobile, Other
  • MobyGames API integration for quick game addition
  • Stock level tracking with low-stock alerts
  • Genre and platform filtering

Sales Processing

  • Multi-item sales with automatic line item calculation
  • Real-time inventory deduction (can be configured)
  • Sales status tracking: Pending, Completed, Cancelled
  • Automatic subtotal calculation based on game prices

Customer Management

  • Loyalty tier system: Standard, Gold, Platinum
  • Total spend tracking per customer
  • Sales history per customer
  • Email and phone contact management

Analytics & Reporting

  • 4 comprehensive report views
  • Sales summary metrics
  • Revenue analysis by customer
  • Top selling games ranking
  • Staff performance metrics

Development

Build Frontend

cd client
npm run build

Run Backend Tests

cd server
npm test

Run Development Server

# Start both with npm run dev in each directory

Database Management

# Create migration
cd server
npx prisma migrate dev --name <migration-name>

# Reset database
npx prisma migrate reset

# View database GUI
npx prisma studio

Testing

Unit Tests

Backend tests are located in server/tests/:

  • accounts.test.ts - Customer management tests
  • app.test.ts - Application and auth tests
  • Additional tests for routes and business logic

Run tests with:

cd server
npm test

Manual Testing

  1. Login with test user: admin@example.com
  2. Navigate to Customers page and test add/edit/delete
  3. Navigate to Inventory page and test:
    • Browsing games
    • Searching MobyGames API
    • Adding/editing games
    • Filtering by platform
  4. Navigate to Sales page and test:
    • Creating sales with multiple line items
    • Updating sale status
    • Deleting sales
  5. Check Reports for metrics accuracy

Database Seeding

The seed script (server/src/prisma/seed.ts) creates:

  • 3 test users with different roles
  • 15 sample customers with loyalty tiers
  • 23 games across various platforms and genres
  • 8 sample sales transactions

Re-seed with:

npx prisma db seed

Deployment

Build for Production

# Backend
cd server
npm run build

# Frontend
cd client
npm run build

Environment Variables (Production)

Update .env files with production database and API URLs.

Deploy to Render

Configure through render.yaml for automatic deployments.

About

Full stack Customer Relationship Management (CRM) application built with a React frontend and a Node.js backend using Express and Prisma ORM.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages