Foundations

The three pillars of every software system

The Three Pillars

Every software system you will ever encounter β€” TradeCraft, the rental marketplace, your banking app, Instagram β€” is made of three things:

πŸ—„οΈ

Databases

Where truth lives

πŸ–₯️

Interfaces

What users see

⚑

API Calls

The logic 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.

The BENED database stack:

Same SQL language, specialized for different jobs. That's the beauty of standardizing on PostgreSQL β€” TimescaleDB is PostgreSQL, just optimized for time.

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 in the BENED ecosystem:

Approach How it works Used for
Server-rendered (PHP) Server builds complete HTML, sends to browser TradeCraft, Research Archive, Support, Praxis
Hybrid (Next.js) Server renders initial HTML, React takes over for interactivity BENED Trailers

Neither is "better." PHP is simpler for content-heavy sites. Next.js is better when you need complex interactivity (search filters, booking calendars, real-time availability). Use the right tool for the job.

API Calls: The Logic 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 developers write (or what AI helps write). The important part is knowing what the box needs to do β€” that's architecture.

Putting It Together

Let's trace a real flow from TradeCraft:

User visits tradecraft.bened.works and clicks "Run Backtest"
                    β”‚
                    β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   INTERFACE   β”‚
            β”‚   (PHP page)  β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚ Sends request to the server
                    β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   API CALL    β”‚
            β”‚               β”‚
            β”‚ β€’ Parse strategy parameters
            β”‚ β€’ Query 2 years of candles from the database
            β”‚ β€’ Simulate trades day by day
            β”‚ β€’ Calculate returns, win rate, drawdown
            β”‚ β€’ Return results as data
            β”‚               β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                       β”‚
        β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   DATABASE    β”‚       β”‚   INTERFACE   β”‚
β”‚  TimescaleDB  β”‚       β”‚  Shows chart, β”‚
β”‚  (read only)  β”‚       β”‚  stats, tradesβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Mental Model

When you look at any feature β€” on any app, anywhere β€” break it down:

  1. What data do I need? β†’ That's the database
  2. What does the user see? β†’ That's the interface
  3. What happens when they act? β†’ That's the API call

Once you see it, you can't unsee it. Every app. Every feature. Three pillars.

Next: Databases β†’

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