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.
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_migratorowns the schema; the app connects only asmasna3_app, which hasSELECTandINSERTon 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-leftand 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,
/healthand/health/readyendpoints, 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- WhatsApp+20 106 358 2529
- LinkedInkareem-mohamed-swe
- CVDownload PDF (3 pages)