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."
- Who are the users? β
userstable - What trailers are available? β
listingstable - What was AAPL's price at 2:35pm on March 4th? β
candlestable - What documents relate to this investigation? β
documentstable
Without a database, your app has amnesia. Refresh the page, everything's gone.
- PostgreSQL β The workhorse. Users, bookings, tickets, documents. Most apps use this.
- TimescaleDB β PostgreSQL with superpowers for time-series data. TradeCraft's market candles live here.
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:
- Receive a request (user clicked something, timer fired, webhook arrived)
- Do some logic (validate, calculate, transform)
- Read or write to the database
- 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:
- What data do I need? β That's the database
- What does the user see? β That's the interface
- 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.
Deep dive into PostgreSQL vs TimescaleDB β when to use each, and why TradeCraft needs time-series.