Thursday, November 28, 2024
Concept of Operations
Sunday, November 17, 2024
Data Transfer Objects
Data Transfer Objects (DTOs) decouple the internal structure of your models, entities, or database schema from the data exposed to the external world (e.g., APIs, front-end). They serve as a contract for the data being transferred, which helps ensure that changes in your data layer don't inadvertently affect the consumer.
Another benefit of DTOs is to enforce structured data and eliminate errors from missing [string] keys. By using a constructor, you control how the raw data is mapped. If a key is missing, you can provide a default value or handle the absence gracefully or you can add validation logic centrally in constructor. Using DTOs allows tools like PhpStorm or VSCode to identify missing properties during development. When working with arrays, typos in keys can go unnoticed until runtime, with DTOs you are using object fields which don’t have this weakness. Example without DTO (note the usage of error prone string keys):
private function prepareProductDetails(array $product): array {
$product['photos'] = $this->processProductPhotos($product['photos']??[]);
$product['tr_currency_formatted'] = isset($product['deposit'])
?Currency::formatTRY($product['deposit'])
return $product;
}
With DTO:
class ProductDetailsDTO {
public array $photos;
public ?float $deposit = null;
public ?string $tr_currency_formatted = null;
public function __construct(array $data) {
$this->photos = $data['photos'] ?? [];
$this->deposit = $data['deposit'] ?? null;
}
public function setFormattedCurrency(callable $formatter): void {
if ($this->deposit !== null) {
$this->tr_currency_formatted = $formatter($this->deposit);
}
}
}
Note the usage of object fields instead of string keys:
private function prepareProductDetails(array $product): ProductDetailsDTO {
$productDTO = new ProductDetailsDTO($product);
$productDTO->photos = $this->processProductPhotos($productDTO->photos);
$productDTO->setFormattedCurrency(fn($amount) =>
Currency::formatTRY($amount));
return $productDTO;
}
Saturday, October 19, 2024
Using UI with AI
17.02.2025: Open source AI models like DeepSeek open the door to self hosted AI. You will need a powerful server with lots of RAM and GPU. The key will be maximizing GPU VRAM, as this is the primary bottleneck for running large models. For efficient inference, the entire model (or as much of it as possible) needs to reside in VRAM. Such servers might cost more than AI API calls if you use a cloud server. One solution might be to have your own physical server to run the AI model and use the cloud server for the web app, which makes API calls to the AI on your server. You will also need to host a speech to text model.
19.06.2025: Desktop AI Compared
Sunday, October 13, 2024
Evaluating fairness of an Investment/Shareholders' Agreement
- Board representation (a seat on the board).
- Veto rights on major financial decisions (e.g., capital raises, mergers, or asset sales).
- Approval rights over key hires or changes in the business direction.
- Liquidation preferences to get paid first in case of a company exit.
Does the contract reflect a balanced distribution of power? If not, what share percentage would correspond to the class B shareholder's power? Is this normal for an initial investor in the startup, considering that convincing the first investor is often the most difficult?
- Even though the class A shareholder (founder) appoints the board member, any change in the board representative requires class B shareholder (investor) approval.
- Class A shareholder cannot transfer shares without class B consent for 3 years, while class B share holder is free to transfer to affiliates or related parties without restriction.
- Important strategic decisions need approval from the Steering Committee, where both A and B share holders have one representative each. Any deadlock in this two-person committee could give the B shareholder veto power over important business decisions.
- Do we agree that the founder/CEO of an ambitious startup with rapid growth goals needs to be able to act quickly, requiring minimal approval/bureaucracy?
- To fund rapid growth, we most probably will need other investors. Can we foresee that this agreement might irritate potential investors, lower the company's value, and lead them to request the same privileges?
- If the same privileges are granted to other investors, would reaching an agreement on any matter outside of routine business—especially considering the potential for irrational behavior (such as ego conflicts, etc.)—become practically impossible?
Sunday, September 22, 2024
What tech to use when you are just starting
| # | complex | simple |
|---|---|---|
| 1 | Mobile app | Progressive Web App (PWA) |
| 2 | MySQL/PostgreSQL | SQLite |
| 3 | Queue worker | defer() |
| 4 | Broadcast with events | Echo whisper |
| 5 | Mailgun | PHPMailer + gmail |
| 6 | ElasticSearch | SQL queries |
Friday, September 20, 2024
The role of the CTO
The role of the Chief Technology Officer (CTO):
- Understand business goals, assess feasibility, and set technical priorities accordingly. Create a technical roadmap.
- In the early stages of the company, be the lead engineer. As the company grows, hire technical personnel, provide guidance to the team.
- Review team outputs (code & documentation), ensure effort is aligned with priorities and outputs are clean and of high quality.
- Review tests and verify that important test cases are included.
- In case of personnel loss, temporarily fill the gap until a replacement is hired.
- Oversee IT, CI/CD infrastructure and security.
- Stay updated with technological trends.
- Represent the company's technological vision to partners, investors, or at industry events.