KM
All projects

Masna3 مصنع

A garment factory ran production and contractor accounts on Excel. I replaced it with one system that tracks every piece from fabric to finished garment and closes the books each month, built alone from requirements to staff training.

Role
Sole engineer: requirements, design, build, deployment, training
Client
Garment factory in Egypt, through 3A Technology Solution
Timeline
Sep 2026 – present · 760 commits
Status
In production since 2026; month-end close live since Oct 2026
Stack
.NET 10, Razor Pages, EF Core, PostgreSQL, Tailwind CSS, Docker, GitHub Actions
Code
Private client code · public write-up on GitHub

The problem

The factory sends fabric and cut pieces to its own floor and to outside contractors, gets finished garments back, pays contractors weekly advances and settles with them every month. All of it was tracked by hand in Excel sheets.

The factory also runs a licensed point-of-sale system for sales, final stock and invoicing. That system could not be changed, so anything new had to work beside it.

What I built

  • Production: work orders and production stages, issue and receipt of fabric and cut pieces, a live view of what each contractor is holding, and discrepancies flagged when quantities don't match.
  • People: workers and contractors with piece rates, attendance, payroll, bonuses and advances, and a monthly settlement per contractor.
  • Materials and products: materials with unit prices, product sheets with bill of materials, costing and photos.
  • Accounting: double-entry journals generated from operations, trial balance, balance sheet, cash flow and a month-end close that runs in order and locks each month's figures.
  • Integration: Excel import and export with the POS, which is never modified.

Architecture

One ASP.NET Core application in four layers. The Domain project holds the business rules and is not allowed to reference anything: the build fails if it does. Each use case has its own handler in the Application layer, and EF Core mapping stays in Infrastructure so the domain has no database attributes.

Masna3 containers: the app connects to PostgreSQL only as a role that cannot update or delete stock movements.Factory staff use the Masna3 web app over HTTPS. The app has four layers: Web, Application, Domain and Infrastructure. Infrastructure connects to PostgreSQL on Neon as masna3_app, which may only select and insert movements. A separate migrator role owns the schema. The factory licensed POS keeps sales and invoicing and exchanges data with Masna3 only through Excel files. GitHub Actions runs 265 tests and deploys only when all pass.Factory staffmanager · supervisorArabic UI, phone + desktopMasna3 web appASP.NET Core · .NET 10 · RenderWeb: Razor Pages, two role layoutsApplication: use-case handlersDomain: rules, zero dependenciesInfrastructure: EF Core, migrationsLicensed POSsales · final stockinvoicing (untouched)PostgreSQL (Neon)masna3_app:SELECT + INSERT onlyon movementsmasna3_migrator: schemaGitHub Actions265 tests on real PostgreSQL;deploy only when all passHTTPSExceldeploys
Masna3 containers: the app connects to PostgreSQL only as a role that cannot update or delete stock movements.

Key decisions

Make the stock ledger append-only in the database, not just in code

Situation
Every stock and money figure is derived from movements. If a movement can be edited quietly, every balance after it becomes untrustworthy, and the owner and accountant need to trust these numbers.
Decision
Two PostgreSQL roles. masna3_migrator owns the schema; the app connects only as masna3_app, which has SELECT and INSERT on movements and nothing else. A test runs the real role script to prove updates and deletes are refused.
Trade-off
Corrections are recorded as new reversing movements instead of edits. Setting up a new database takes care: on Neon, a role created through the API inherits write-all permissions, so the app role is created with plain SQL. That is documented in the runbook.

Integrate with the POS through Excel only

Situation
The POS is licensed software the factory depends on for sales and invoicing. Touching its database could break it or void support.
Decision
Masna3 never writes to the POS. Data moves through Excel import and export, with a preview before anything is saved.
Trade-off
One manual step for the accountant, in exchange for zero risk to the system that takes the money.

Let the build enforce the rules reviewers would miss

Situation
I'm the only engineer, so there is no second reviewer to catch an architecture slip or a broken right-to-left layout.
Decision
Build guards: the Domain project fails the build if it gains any reference, a CSS lint rule fails the build on margin-left and other physical-direction properties, and warnings are errors in production code.
Trade-off
Slightly slower iteration when a guard fires, but mistakes are caught on my machine instead of in front of the client.

Quality and operations

  • 265 automated tests: 87 domain, 26 application and 152 integration tests that run against real PostgreSQL containers (Testcontainers).
  • CI/CD: GitHub Actions runs everything on each commit; a deploy happens only when all tests pass.
  • Production: one Docker container on Render (Frankfurt) with PostgreSQL on Neon, secrets only in the host's environment, /health and /health/ready endpoints, and an uptime check every ten minutes.
  • Runbook: releases, rollback, backups and a rehearsed restore are written down. A September 2026 expert review is recorded with what was found and fixed.

Screens

More projects

Hiring a .NET or full-stack developer?

I'm based in Cairo and ready to relocate to Saudi Arabia or elsewhere in the Gulf. Notice period: 30 days.

Kareemmoursy75432@gmail.com