[!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.
- ๐ฎ 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
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
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
- Node.js v18+
- Docker and Docker Compose
- npm or yarn
-
Clone the repository
git clone <repo-url> cd crm
-
Install dependencies
cd server && npm install cd ../client && npm install
-
Set up environment variables Create
.envfiles: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-secretclient/.env.local:
VITE_API_URL=http://localhost:5000 -
Start PostgreSQL
docker-compose up -d
-
Initialize database
cd server npx prisma migrate deploy npx prisma db seed -
Start development servers
Terminal 1 (Backend):
cd server npm run devTerminal 2 (Frontend):
cd client npm run dev -
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000/api
- Default login: admin@example.com / password
Authentication
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout user
Customers
GET /api/customers- List customers (paginated)POST /api/customers- Create customerGET /api/customers/:id- Get customer detailsPATCH /api/customers/:id- Update customerDELETE /api/customers/:id- Delete customer
Inventory
GET /api/inventory- List games (paginated, filterable)POST /api/inventory- Add game manuallyGET /api/inventory/search?q=<query>- Search MobyGames APIPOST /api/inventory/add-from-search- Add game from search resultsGET /api/inventory/:id- Get game details with sales historyPATCH /api/inventory/:id- Update gameDELETE /api/inventory/:id- Delete game
Sales
GET /api/sales- List sales (paginated)POST /api/sales- Create sale with line itemsGET /api/sales/:id- Get sale detailsPATCH /api/sales/:id- Update saleDELETE /api/sales/:id- Delete sale
Reports
GET /api/reports/sales-summary- Sales metricsGET /api/reports/revenue-by-customer- Revenue breakdown by customerGET /api/reports/top-selling-games- Top games by quantity and revenueGET /api/reports/user-performance- Staff performance metrics
See SPECIFICATIONS.md for complete API documentation.
- 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.
- 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
- 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
- Loyalty tier system: Standard, Gold, Platinum
- Total spend tracking per customer
- Sales history per customer
- Email and phone contact management
- 4 comprehensive report views
- Sales summary metrics
- Revenue analysis by customer
- Top selling games ranking
- Staff performance metrics
cd client
npm run buildcd server
npm test# Start both with npm run dev in each directory# Create migration
cd server
npx prisma migrate dev --name <migration-name>
# Reset database
npx prisma migrate reset
# View database GUI
npx prisma studioBackend tests are located in server/tests/:
accounts.test.ts- Customer management testsapp.test.ts- Application and auth tests- Additional tests for routes and business logic
Run tests with:
cd server
npm test- Login with test user: admin@example.com
- Navigate to Customers page and test add/edit/delete
- Navigate to Inventory page and test:
- Browsing games
- Searching MobyGames API
- Adding/editing games
- Filtering by platform
- Navigate to Sales page and test:
- Creating sales with multiple line items
- Updating sale status
- Deleting sales
- Check Reports for metrics accuracy
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# Backend
cd server
npm run build
# Frontend
cd client
npm run buildUpdate .env files with production database and API URLs.
Configure through render.yaml for automatic deployments.