Skip to main content

Command Palette

Search for a command to run...

I Almost Lost Commerza: The Brutal Reality of Building an Ecommerce System Without a Framework

How a 9,800-line AI disaster and zero Git history taught me the true cost of ‘Zero Framework’ engineering.

Updated
7 min readView as Markdown
I Almost Lost Commerza: The Brutal Reality of Building an Ecommerce System Without a Framework
S
I'm Syed Ahmer Shah, a full-stack developer and Software Engineering student passionate about building real-world web solutions. I explore web development, AI, and software design — and share what I learn through tutorials, dev logs, and personal projects. Currently growing my skills, one commit and one concept at a time.

I am 19 years old. I set out to build a production-grade e-commerce system from scratch. No Laravel. No React. Just raw PHP, MySQL, and a lot of stubbornness.

I call it Commerza. It is a security-first storefront and operations panel with 238 files of pure, custom architecture.

But I almost killed the entire project before anyone even saw a single line of code. This is the story of how relying too much on AI almost wrecked my system, and how the rebuild forced me to become a real software engineer.


The Code Red: A 9,800-Line Disaster

Like many developers today, I leverage AI tools. Gemini, Claude, Copilot — they act as a sounding board to accelerate development. But they are tools, not architects. I learned that the hard way.

Nearing what I thought was the “completion” phase of my backend, things had gotten messy. I had files ballooning to anywhere between 6,000 and 9,800 lines of code. The logic was tangling. Instead of doing the hard work of refactoring it myself, I got lazy. I asked GitHub Copilot to logically split those massive files into modular components.

It did not split them. It butchered them.

In a matter of seconds, Copilot scrambled the logic and outright deleted 40% of my backend. Critical functionalities vanished. My custom API endpoints, my image compressor, the parser feature, and several core JavaScript files were just gone.

Design with purpose: Native Dual-Theme support for an engineering-focused storefront experience.

I sat staring at the screen. I was ready to turn off the computer, delete the folder, and abandon the project completely.


The Biggest Mistake Was Not the AI

It took me two days and roughly 9.6 hours of pure screen time to manually stitch the backend back together.

Why did I have to do it manually? Because of the ultimate rookie mistake: It wasn’t on Git.

If I had been committing my code properly, a simple git restore . would have saved me. Instead, I paid in blood and time.

The Hard Truths About Version Control:

  • Push constantly: A local copy is not a backup. A Git repository is.

  • Protect your secrets: Never, ever share your .env file or database credentials on GitHub. I spent hours analyzing the difference between public and private repositories and utilizing .gitignore and git filter-branch to ensure my commit history was scrubbed of any leaked SMTP or database passwords before going public.

# Environment secrets
.env
.env.*
!.env.example

# Temporary local maintenance scripts
.history-scrub.ps1

# Dependency directories
node_modules/
vendor/
!frontend/assets/vendor/

# Local runtime artifacts
*.log
*.tmp
*.cache
*.out
*.pid
*.seed

# Package manager / test artifacts
npm-debug.log*
yarn-debug.log*
pnpm-debug.log*
coverage/
.phpunit.result.cache

# OS noise
.DS_Store
Thumbs.db
Desktop.ini
  • Own your code: AI can write syntax, but it cannot hold the context of your entire system. If you don’t understand the architecture, you can’t fix it when the AI breaks it.

The Operations Engine: A custom-built admin panel designed for real-world business monitoring.

The Frontend-First Trap

Not using Git wasn’t my only architectural sin. I made the massive mistake of building the frontend first.

I designed the UI using .html files and relied on hardcoded JSON fetching to populate the data. It looked great, but when it was time to actually connect the PHP backend, the data mutation flow was a nightmare. I had to rip out the static HTML, convert everything to server-rendered .php templates, and entirely rebuild how the client communicated with the server.

Always build the engine first. Paint the car later.

Rising from the Wreckage: The Architecture of Commerza

After the 9.6-hour rebuild, my mindset shifted. I stopped coding like a hobbyist and started coding defensively. I didn’t just rebuild the APIs; I built a fortress.

Here is what the architecture looks like today:

commerza/                  # Example
├── admin/                 # Restricted operations UI and Auth
│   ├── api/               # Admin-specific backend endpoints
│   └── frontend/          # Admin dashboards and management views
├── backend/               # The Engine
│   ├── core/data.php      # Shared bootstrap and DB connection
│   ├── security/          # Argon2id, CSRF, and CAPTCHA models
│   ├── payment/           # Stripe verification and COD logic
│   └── jobs/              # Cron-based automation scripts
├── frontend/              # Storefront static assets (CSS, JS, media)
├── .env.example           # Secure environment template
└── .htaccess              # Apache routing and security gatekeeper

Architecture over chaos. A high-level view of Commerza’s modular directory structure.


Engineering for Production

Building without a framework means you have to write your own security, performance, and SEO layers. I couldn’t just run an artisan command.

1. Database Safety & Concurrency I implemented strict transactional locking. When an order is placed, the system executes a SELECT ... FOR UPDATE lock on the database row. This prevents race conditions, double-orders, and negative stock if two users try to buy the last item at the exact same millisecond. Every user-facing query uses strict prepared statements to eliminate SQL injection.

2. The Anti-Bot Layer The login and checkout flows are protected by a layered CAPTCHA model. It attempts a silent reCAPTCHA v3 verification first. If it detects suspicious behavior, it degrades to a v2 checkbox, and finally to a custom mathematical fallback challenge. Combined with strict CSRF tokens and rate limiting, brute-force attacks are neutralized at the door.

3. Identity & Access Passwords are hashed using Argon2id. But security isn’t just about passwords. I built a sub-admin lifecycle where, if a staff member is suspended or their permissions are altered, their session is immediately revoked server-side. No waiting for a cookie to expire.

4. Performance & Dual-Theme UI The frontend is highly optimized. I configured .htaccess to handle static asset caching and clean-routing for SEO (turning messy PHP queries into clean URLs). The UI features a native, zero-dependency Dual-Theme system. Users can toggle between a high-contrast Dark Mode (OrangeRed + Black) and a clean Light Mode (NavyBlue + White), with the preference persisting via local storage.

5. Payments Checkout handles both Cash on Delivery (with configurable OTP limits for high-value orders) and Stripe card payments, with server-side PaymentIntent verification to ensure no transaction is manipulated on the client side.

Security as a baseline: Implementing transactional row-locking and prepared statements to eliminate race conditions.


The Final Lesson

Frameworks are incredibly useful, but they abstract the hard parts of engineering. By avoiding them, I crashed my own system, lost my code, and had to learn the raw mechanics of web security, transactional databases, and server routing.

It was brutal. But because of that Code Red, I don’t just know how to use a tool — I know how to build the machine.

Explore the Codebase: You can view the full repository, including the [SECURITY.md](https://github.com/ahmershahdev/commerza?tab=security-ov-file#) and detailed documentation, on GitHub: ahmershahdev/commerza

Live Deployment: The production environment will be officially live between 15 to 20 May 2026 here: commerza.ahmershah.dev


Connect With the Author

Platform Link
✍️ Medium @syedahmershah
💬 Dev.to @syedahmershah
🧠 Hashnode @syedahmershah
💻 GitHub @ahmershahdev
🔗 LinkedIn Syed Ahmer Shah
🧭 Beacons Syed Ahmer Shah
🌐 Portfolio ahmershah.dev
K
kodadev8922mo ago

Building an e-commerce system from scratch at 19 is seriously impressive. The lessons from doing it the hard way are worth more than any framework tutorial 👏

S

This post hits harder than most “AI coding” discussions because it shows the part people usually hide: recovery.

A lot of developers are treating AI like an architect when it’s really just a very confident assistant. The scary part is that AI-generated code often looks correct even when it completely breaks system constraints underneath.

The biggest takeaway for me wasn’t “frameworks are bad” — it was that deep system understanding matters more than tooling. Whether you use Laravel, raw PHP, Node, or Go, if you don’t understand transaction flow, auth lifecycle, concurrency, and rollback strategy, eventually something will break in production and AI won’t save you.

Also:

“Build the engine first. Paint the car later.”

That’s genuinely one of the best pieces of advice for beginner devs building large systems.

Respect for being transparent about the Git mistake too. Almost every serious developer has a painful “I should’ve committed that” moment at some point 😭

The rebuild probably taught you more about backend engineering than 20 tutorials combined.

P
pokibo77822mo ago

which SMTP you used ?

J
Jeva Cafek2mo ago

how you added email automation ? i also want to integrate this

F

So good 😊👍

S

Thanks for reading and for the support, Faiq.

C

Great deep dive into Commerza, Ahmer! Building a security-first engine from scratch is no small feat, especially in e-commerce where trust is everything.

I have a question regarding the architecture: How did you balance these heavy security protocols with the overall performance and load times? Often, strict security measures (like complex middleware or heavy validation) can slow down the TTFB. Would love to hear your approach on keeping the engine lightweight while staying highly secure. Solid work on this!

S

That is a great question. To keep the TTFB low, I focused on making the security layers as "thin" as possible. Instead of heavy middleware, I used optimized validation classes and prepared statements that add negligible overhead. I also made sure that security checks (like session validation) happen early in the execution flow to prevent unnecessary processing if a request is unauthorized. It’s definitely a constant balancing act.

L

Got it—short version: containers aren’t just a Linux wrapper; they use namespaces and cgroups to isolate and control resources at the OS level.

S

Precisely. Understanding that low-level isolation via namespaces is what makes modern deployment so powerful. While Commerza started as a raw PHP project, moving toward that kind of containerized environment is definitely the next logical step for stability.

The Engineering Logs

Part 9 of 17

Hey, I'm Syed Ahmer Shah. The Engineering Logs is my personal archive of navigating full-stack development, AI integration, and the actual, unglamorized grind of building systems from scratch. Instead of generic tutorials, I write down real architectural decisions, code that broke, and the exact fixes that saved it. Everything here is documented as it happens—from optimizing database logic to breaking down complex systems thinking. This is where theory gets thrown out for raw execution. Syed Ahmer Shah | Engineering Logs: Design, Sync, Energize is a transparent look at what it really takes to master the stack and build high-performance architecture. If you are here for clean code, hard technical truths, and zero-bullshit engineering, stick around.

Up next

Your $20/mo AI Wrapper is Dead: Why OpenClaw is Making 60% of SaaS Tools Obsolete

You're probably dropping \(20 a month for ChatGPT, another \)20 for Claude, and then paying GitHub Copilot/Claude Code or Make just to move some text between apps. It's a tax on our productivity, and