Skip to main content

Welcome to Mis Compras

Mis Compras is an e-commerce marketplace platform designed to democratize digital commerce, connecting local entrepreneurs with their community. This guide will walk you through creating an account, making your first purchase, and listing your first product.
Mis Compras was created to strengthen local economic and social networks, allowing anyone to start and grow their business from home.

Getting Started

1

Create Your Account

Register for a new Mis Compras account to start buying or selling products.

Registration API

The platform uses a PHP backend for user registration. Here’s how the registration works:
// POST to php/registro.php
{
  "nombre": "Your Name",
  "email": "your.email@example.com",
  "contrasena": "your-secure-password"
}
The system will:
  • Validate all required fields
  • Check for duplicate email addresses
  • Hash your password using password_hash() with PASSWORD_DEFAULT
  • Create your user account in the database
Success Response:
{
  "success": true,
  "message": "🎉 ¡Registro exitoso!"
}
Error Response:
{
  "success": false,
  "message": "⚠️ Este correo ya está registrado."
}
Make sure to use a unique email address. The platform checks for duplicates and will reject registration attempts with existing emails.
2

Log In to Your Account

Once registered, log in to access all platform features.

Login API

// POST to php/login.php
{
  "email": "your.email@example.com",
  "contrasena": "your-password"
}
Success Response:
{
  "éxito": true,
  "mensaje": "Inicio de sesión exitoso",
  "usuario": {
    "id": 17,
    "nombre": "Your Name"
  }
}
The login system:
  • Verifies credentials using password_verify()
  • Creates a PHP session with $_SESSION["id_usuario"]
  • Returns user details for client-side storage
Your user ID is essential for all authenticated operations like listing products or making purchases.
3

Browse Products by Category

Explore available products organized by category.

Get Products by Category

// GET php/obtener_productos_por_categoria.php
Response Structure:
{
  "exito": true,
  "categorias": [
    {
      "categoria": "Laptops",
      "productos": [
        {
          "id_producto": 2,
          "nombre": "MacBook Pro M3",
          "descripcion": "Chip M3, pantalla Retina, 16GB RAM, SSD 512GB",
          "precio": "1599.99",
          "imagen": "macbook.jpg",
          "id_vendedor": 17,
          "vendedor": "frank"
        }
      ]
    },
    {
      "categoria": "Smartphones",
      "productos": [
        {
          "id_producto": 1,
          "nombre": "iPhone 15 Pro",
          "descripcion": "Chip A17 Pro, cámara de 48MP, titanio",
          "precio": "999.99",
          "imagen": "iphone15.jpg",
          "id_vendedor": null,
          "vendedor": "Anónimo"
        }
      ]
    }
  ]
}
4

Make Your First Purchase

Add products to your cart and complete the checkout process.

Checkout Process

The checkout system processes your cart items and creates an order:
// POST to php/checkout.php
{
  "usuario_id": 17,
  "total": 1599.99,
  "items": [
    {
      "id": 2,
      "nombre": "MacBook Pro M3",
      "cantidad": 1,
      "precio": 1599.99
    }
  ]
}
What happens during checkout:
  1. Order Creation: A new entry is created in the pedidos table
  2. Order Details: Each item is stored in detalle_pedido with quantity and price
  3. Cart Cleanup: Your shopping cart is cleared after successful purchase
Success Response:
{
  "success": true,
  "message": "Compra registrada correctamente.",
  "redirect": "gracias.html"
}
All prices are stored as DECIMAL(10,2) in the database to ensure accurate financial calculations.
5

List Your First Product

Start selling by creating your first product listing.

Create a Product Listing

// POST to php/vender.php (multipart/form-data)
{
  "nombre": "iPhone 15 Pro",
  "descripcion": "Excellent condition, includes charger",
  "precio": 999.99,
  "categoria": 3,  // Smartphones category
  "imagen": [File upload],
  "id_vendedor": 17  // From your session
}
Product Creation Process:
  1. Session Validation: Ensures you’re logged in
  2. Field Validation: Checks all required fields are present
  3. Image Upload: Generates unique filename with timestamp and random hash
  4. Database Insert: Creates product record with your user ID as vendor
Success Response:
{
  "success": true,
  "message": "✅ Producto publicado correctamente."
}
Image Naming:
// Images are stored with unique names
$uniqueName = time() . '_' . bin2hex(random_bytes(6)) . '.' . $ext;
// Example: 1735012345_a3b5c7d9e1f2.jpg
You must be logged in to create product listings. The system checks for $_SESSION['id_usuario'] or $_POST['id_vendedor'].

Database Schema Overview

Understanding the core tables will help you work with the platform:

usuarios

User Accounts
  • id_usuario (Primary Key)
  • nombre (Name)
  • email (Unique)
  • contrasena (Hashed password)
  • fecha_registro (Timestamp)

productos

Product Listings
  • id_producto (Primary Key)
  • nombre (Product name)
  • descripcion (Description)
  • precio (DECIMAL)
  • imagen (Image filename)
  • id_vendedor (Foreign Key to usuarios)
  • id_categoria (Foreign Key to categorias)

pedidos

Orders
  • id_pedido (Primary Key)
  • id_usuario (Foreign Key to usuarios)
  • total (DECIMAL)
  • direccion (Delivery address)
  • fecha_pedido (Timestamp)

categorias

Product Categories
  • id_categoria (Primary Key)
  • nombre (Category name)
  • descripcion (Description)
Examples: Laptops, Smartphones

API Endpoints Quick Reference

EndpointMethodDescription
/php/registro.phpPOSTRegister new user
/php/login.phpPOSTUser authentication
/php/obtener_productos_por_categoria.phpGETGet all products grouped by category
/php/vender.phpPOSTCreate new product listing
/php/checkout.phpPOSTProcess purchase order
/php/obtener_producto.phpGETGet single product details
/php/mis_productos.phpGETGet products by current user

Next Steps

Installation

Set up your local development environment

API Reference

Explore all available API endpoints

Database Schema

Deep dive into the database structure

User Authentication

Learn about authentication and security

Need Help?

If you encounter any issues during setup or have questions:
  • Check the Installation Guide for detailed setup instructions
  • Review the database schema in the included SQL file
  • Ensure your PHP environment has bcrypt support for password hashing
  • Verify MySQL/MariaDB is running and accessible

Next Steps

For Sellers

Learn how to start selling on Mis Compras

For Buyers

Discover how to browse and purchase products

Configuration

Set up your local development environment

API Documentation

Explore the complete API reference

Build docs developers (and LLMs) love