Skip to main content

Overview

The PC Fix database is built on PostgreSQL and managed through Prisma 6, providing type-safe database access and automatic migrations. The schema supports a full e-commerce system with users, products, shopping carts, orders, and administrative features.
The database is hosted on Railway and includes 328 lines of carefully designed schema covering all business logic.

Database Technology

PostgreSQL

Production-grade relational database with ACID compliance

Prisma 6.18

Next-generation ORM with automatic client generation

Railway Hosting

Managed PostgreSQL with automatic backups

Prisma Studio

Visual database browser on port 5555

Schema Configuration

prisma/schema.prisma
The binaryTargets configuration ensures compatibility with both local development and containerized deployments.

Schema Overview

The database schema is organized into five main domains:
1

Users & Authentication

User accounts, roles, authentication tokens, and client profiles
2

Products & Catalog

Products, categories, brands, banners, and favorites
3

Shopping & Cart

Shopping cart, cart items, and stock alerts
4

Sales & Payments

Orders, order lines, payments, and payment methods
5

Technical Support

Support tickets, service items, and ticket responses

User Management

User Model

Users can authenticate via password or Google OAuth (googleId field). The role field enables role-based access control.

Client Profile

Location Data

Location data supports Argentina’s provincial and locality structure for shipping calculations.

Refresh Tokens

Product Catalog

Product Model

  • Soft Delete: deletedAt field allows marking products as deleted without removing data
  • Pricing: Support for original and discounted prices
  • Shipping: Physical dimensions and weight for shipping calculations
  • Featured Products: isFeatured flag for homepage highlights
Users can subscribe to stock alerts for out-of-stock products.

Categories

Categories support hierarchical relationships (parent/child) for organizing products into nested groups.

Brands

Favorites

Favorites use a composite primary key to prevent duplicate entries.

Shopping Cart

The abandonedEmailSent flag tracks whether the user has received an abandoned cart email reminder.

Sales & Orders

Sales Model

  1. PENDIENTE_PAGO - Order created, awaiting payment
  2. PENDIENTE_APROBACION - Payment submitted, awaiting admin approval
  3. APROBADO - Payment approved, ready to ship
  4. ENVIADO - Order shipped to customer
  5. ENTREGADO - Order delivered successfully
  6. RECHAZADO - Payment rejected
  7. CANCELADO - Order cancelled
  • ENVIO: Home delivery via shipping provider
  • RETIRO: In-store pickup
The system supports multiple shipping providers including Correo Argentino and Zipnova.
  • TRANSFERENCIA: Bank transfer
  • BINANCE: Cryptocurrency (USDT)
  • EFECTIVO: Cash (for in-store pickup)

Order Lines

Order lines support custom pricing and descriptions for special scenarios (bulk discounts, promotions, etc.).

Payments

System Configuration

The configuration table stores system-wide settings that can be updated by admins without code changes.

Technical Support

Database Indexes

The schema includes strategic indexes for performance:

Prisma Migrations

Creating Migrations

Database Seeding

prisma/seed.ts
Run seed with: npx prisma db seed

Prisma Studio

Access the visual database browser:
Open http://localhost:5555 to:
  • Browse all tables
  • Create, edit, delete records
  • View relationships
  • Run queries

Database Relationships

Best Practices

Use Transactions

For operations affecting multiple tables (orders, payments)

Soft Deletes

Use deletedAt timestamps instead of hard deletes for products

Indexes

Add indexes on foreign keys and frequently queried fields

Timestamps

Always use @db.Timestamptz(3) for timezone-aware timestamps

Next Steps

Backend API

Learn how to query this schema

Migrations

Manage schema changes

Deployment

Deploy to production