Engineering note · SemaKazi
Auditing my own MVP before production
- Project
- SemaKazi — Personal project
- Issue
- #31–#36: pre-production audit findings (2 × P0, 4 × P1)
- My role
- Sole developer; wrote the audit and opened the issues
- Stack
- Node.js · Express · SQLite
- Status
- Open, fixes in progress
The problem
SemaKazi helps informal-sector workers in Kenya (fundis) show verified skills and build a reputation through reviews. I built the MVP to run well on a free hosting tier. In August I made the backend seed demo data on every start (PR #28), and gave JWT_SECRET a local fallback (PR #29). Both choices kept development unblocked. Before putting real users on it, I wanted to know which of those shortcuts would be unsafe in production.
What I did
I read the backend as if I were reviewing someone else's code. I logged each finding as a GitHub issue with file references and acceptance criteria. I ranked them in two groups. P0 means it must be fixed before launch, because the source is public and the risk needs no special access. P1 means it weakens trust or recovery, and should be fixed before real data builds up.
- #31 (P0):
seedIfEmpty()runs on every start, so a fresh production database would get demo accounts with documented passwords. The plan is to seed only through an explicit non-production command. - #32 (P0):
ADMIN_TOKENfalls back to a fixed development value whateverNODE_ENVis. That token guards review moderation, including permanent deletion. The plan is to refuse to start in production without a real token. - #33 (P1): some write endpoints check that a token is valid but not the account's role. A fundi could leave a review and a client could add proof of work. The plan is to return 403 for the wrong role.
- #34 (P1): flagged reviews are hidden on the reviews route, but the profile detail and the search rating averages still include them.
- #35 (P1):
npm auditreports one critical and three moderate advisories in runtime dependencies, with fixes available. - #36 (P1): SQLite sits on a persistent disk, but there is no backup or tested restore.
Each issue also asks for a test. For #31, it must prove that an empty production database stays empty. For #32, it must prove the development token is rejected in production.
How I checked it
I confirmed each finding against the code or a tool, not from memory.
- #31: I traced the call in
src/server.jstosrc/db/seed.jsand saw it has no environment check. - #32: I compared the two settings in
src/config.js. The JWT secret already fails closed; the admin token does not.
if (!jwtSecret && isProduction) throw new Error(...); // PR #29
adminToken: process.env.ADMIN_TOKEN || 'semakazi-local-admin-dev-only'
- #33: I read the auth middleware on each
POSTroute inreviews.js,request.jsandproofOfWork.js. - #34: I compared the SQL. The reviews route filters on
flagged = 0;profiles.jsdoes not. - #35: I ran
npm cithennpm auditinsemakazi-backend. - #36: I read
docs/DEPLOY_RENDER.mdand found no backup step.
None of these is fixed yet. Each issue will close only when its acceptance criteria pass, including npm test.
What I learned
A development fallback is only safe if production refuses it. I applied that rule to JWT_SECRET, then copied the fallback pattern for the admin token without the check. The audit caught the gap. A convenience that helps on day one, such as auto-seeding, can turn into a risk once the data is real. I now want a short list of production checks before any launch, and each one backed by a test.