Foundations

The three pillars of every software system

The Three Pillars

Every software system you will ever build β€” TradeCraft, the rental platform, a simple contact form β€” is made of three things:

πŸ—„οΈ

Databases

Where truth lives

πŸ–₯️

Interfaces

What users see

⚑

API Calls

The math in between

That's it. Everything else is implementation details.

Databases: The Source of Truth

A database is where your application's state lives. State is just a fancy word for "what's true right now."

Without a database, your app has amnesia. Refresh the page, everything's gone.

Your databases right now:

Interfaces: What Users See

An interface is the surface users interact with. It shows data from the database and accepts input that changes the database.

Two main approaches:

Approach How it works You use it for
Server-rendered (PHP) Server builds complete HTML, sends to browser Case portal, Praxis, TradeCraft
Hybrid (Next.js) Server renders initial HTML, React takes over for interactivity Trailer rental

Neither is "better." PHP is simpler for content-heavy sites. Next.js is better when you need complex interactivity (drag-and-drop, real-time updates, etc).

API Calls: The Math in Between

This is where "code" lives. An API call is just:

  1. Receive a request (user clicked something, timer fired, webhook arrived)
  2. Do some logic (validate, calculate, transform)
  3. Read or write to the database
  4. Return a response
User clicks "Place Order"
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   API CALL                         β”‚
β”‚                                                    β”‚
β”‚  1. Validate: Is the card valid? Is item in stock?β”‚
β”‚  2. Calculate: Total = price Γ— quantity + tax     β”‚
β”‚  3. Write DB: INSERT INTO orders (...)            β”‚
β”‚  4. Call Stripe: Charge the card                  β”‚
β”‚  5. Write DB: UPDATE orders SET status='paid'     β”‚
β”‚  6. Return: { success: true, orderId: 12345 }     β”‚
β”‚                                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
Interface updates: "Order confirmed!"

The code inside that box? That's what Copilot writes. Your job is knowing what the box needs to do, not how to write it.

Putting It Together

Let's trace a real flow from your TradeCraft app:

User visits /backtest and clicks "Run Backtest"
                    β”‚
                    β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   INTERFACE   β”‚
            β”‚   (PHP page)  β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚ POST /api/backtest.php
                    β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   API CALL    β”‚
            β”‚               β”‚
            β”‚ β€’ Parse strategy parameters
            β”‚ β€’ Query 2 years of candles from TimescaleDB
            β”‚ β€’ Simulate trades day by day
            β”‚ β€’ Calculate returns, win rate, drawdown
            β”‚ β€’ Return results as JSON
            β”‚               β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                       β”‚
        β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   DATABASE    β”‚       β”‚   INTERFACE   β”‚
β”‚  TimescaleDB  β”‚       β”‚  Shows chart, β”‚
β”‚  (read only)  β”‚       β”‚  stats, tradesβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Mental Model

When you look at any feature request, break it down:

  1. What data do I need? β†’ Database tables
  2. What does the user see? β†’ Interface (page, component)
  3. What happens when they act? β†’ API call (the logic)

Then tell Copilot what to build. The architecture is yours. The syntax is mine.

Next: Databases β†’

Deep dive into MySQL vs PostgreSQL vs TimescaleDB β€” when to use each, and why TradeCraft needs time-series.