Skip to content

Node.js + PostgreSQL project simulating game store backend. Understanding API design, transaction handling, and idempotency concepts commonly seen in the industry.

License

Notifications You must be signed in to change notification settings

hchia93/mock-store-payment-backend

Repository files navigation

mock-store-payment-backend

WIP WIP

A learning-oriented backend service inspired by game store platforms. It explores common backend patterns including authentication, product catalog, cart and order management, and integration with a mock payment service.

This project serves as a showcase and practice ground for backend development concepts, not intended for production use.

Frontend is not within the scope of this project.

✨ Features

Feature Scope
User Management
  • Create a new account
  • Log in
  • Delete own account
Product Query
  • Query individual products via API endpoint
  • Retrieve product prices
Shopping Cart
  • View cart contents
  • Add items to the cart
  • Delete items in the card
Checkout & Payment
  • Checkout selected items from the cart
  • Process payment through a mock payment API
Transactions & Invoices
  • Record user payments
  • Generate invoices (e.g., as PDF)

pending-demo

WIP

Project Structure

mock-store-payment-backend/
├── prisma/                 # Prisma schema & migrations
├── scripts/                # Windows batch scripts (reset-db, reset-data, etc.)
├── src/
│   └── api/                # Express API endpoints
├── .env                    # Example environment variables. Disensitized version config is pushed in this repo.
├── .pgpass                 # Local PostgreSQL password config
├── package.json
└── README.md

Tech Stack

  • Database: PostgreSQL
  • ORM: Prisma
  • API Framework: Node.js + Express
  • Configuration: dotenv, pgpass
  • Automation: Windows batch scripts for database reset/init/load
flowchart LR 
    subgraph DB[PostgreSQL Database]
        TBL1[(Tables & Schema)]
        DATA[(Data Rows)]
    end

    subgraph Prisma[Prisma ORM Layer]
        SCHEMA[prisma/schema.prisma]
        MIGR[SQL Migrations]
        CLIENT[Generated Prisma Client]
    end

    subgraph API[Node.js API Layer]
        CODE[src/api/index.js]
    end

    %% Database to Prisma
    TBL1 -- db pull --> SCHEMA
    SCHEMA -- generate --> CLIENT
    MIGR -- apply --> TBL1

    %% API layer usage
    CODE -- import & query --> CLIENT
    CLIENT -- run SQL --> DB
Loading

Disclaimer: Node.js was chosen over C++ as it is more commonly used for backend services in Singapore. The project serves to align with prevalent industry practices and to build familiarity with widely adopted backend methodologies.

Database ERD

erDiagram

    account {
        int id PK
        string handle_name
        string display_name
        string password_hash
        string email
        timestamp created_at
    }

    product {
        int id PK
        string name
        string description
        string category
        timestamp created_at
    }

    product_price_version {
        int id PK
        int product_id FK
        int version
        decimal price
        timestamp created_at
    }

    bundle {
        int id PK
        string name
        string description
        timestamp created_at
    }

    bundle_item {
        int bundle_id FK
        int product_id FK
    }

    bundle_price_version {
        int id PK
        int bundle_id FK
        int version
        decimal price
        timestamp created_at
    }

    cart {
        int id PK
        int account_id FK
        boolean is_bundle
        int product_id FK
        int product_version
        int bundle_id FK
        int bundle_version
        int quantity
        decimal price_snapshot
        uuid group_id
        timestamp created_at
        timestamp updated_at
    }

    purchase {
        int id PK
        int account_id FK
        boolean is_bundle
        int product_id FK
        int product_version
        int bundle_id FK
        int bundle_version
        decimal amount
        string purchase_status
        timestamp created_at
        timestamp updated_at
    }

    %% Relationships
    account ||--o{ cart : "has"
    account ||--o{ purchase : "makes"
    product ||--o{ product_price_version : "has versions"
    bundle ||--o{ bundle_item : "contains"
    product ||--o{ bundle_item : "part of"
    bundle ||--o{ bundle_price_version : "has versions"
    product ||--o{ cart : "in"
    bundle ||--o{ cart : "in"
    product ||--o{ purchase : "in"
    bundle ||--o{ purchase : "in"
Loading

About

Node.js + PostgreSQL project simulating game store backend. Understanding API design, transaction handling, and idempotency concepts commonly seen in the industry.

Topics

Resources

License

Stars

Watchers

Forks