· 5 min read
How I built this portfolio: Go, PostgreSQL and a secure admin panel
The design decisions behind this site: updating content without redeploying, handling uploads safely, and what testing it properly uncovered.
- Go
- Next.js
- PostgreSQL
- Security

I wanted a portfolio I could keep current without touching code: add a certificate, publish a project, hide something while I review it. That one requirement shaped most of the design, and because I work on security systems, I treated this small site the way I would treat anything else I put on the internet.
The architecture
- PostgreSQL holds the content. Rules that must never break, such as "links start with
https://", areCHECKconstraints, so they hold even if the application has a bug. - A Go API (chi + pgx) serves it as JSON. Migrations are embedded in the binary and run on startup.
- Next.js renders the pages and caches them. Saving in the admin panel refreshes the affected pages straight away; a background refresh catches everything else.
The trade-off: a separate API is more work than letting Next.js talk to the database directly. I chose it because it gives one place for validation and access rules, and it is the kind of service I actually build.
One editor instead of ten
The site has about a dozen editable sections. Instead of writing an editor for each, I describe each section once in Go: its table, its fields and how each field is validated. The API builds its SQL from those descriptions, and the admin panel draws its forms from the same data. Table and column names only ever come from that code, and every value is sent as a query parameter, so form input can't change a query. Adding a field takes one line.
The trade-off: a generic editor can't do everything a hand-built one can. Screenshots with a single cover picture needed a special rule. For a one-person admin panel, that is a good deal.
Admin login
There is no sign-up page; accounts are created from the terminal. Passwords are hashed with Argon2id, following OWASP's guidance. The browser holds a random session token in an httpOnly cookie, and the database stores only its hash, so a leaked database can't be used to sign in. A wrong email and a wrong password give the same message and take about the same time, so the login page doesn't reveal who has an account.
Uploads are untrusted input
Pictures can carry more than pixels. Photos from a phone often contain GPS coordinates, and SVG files can contain scripts. So every upload goes through two steps:
- The website cleans it: turns it upright, resizes it, and re-encodes it as WebP, which drops the hidden metadata. A PDF certificate becomes a picture of its first page. SVG is refused.
- The API trusts nothing: it identifies the file by its first bytes, not its name, and accepts only WebP without metadata chunks, or PDF. Files are stored under the hash of their content.
I checked this with a test photo containing fake GPS data and a camera name: the stored copy contained neither.
Importing from Google Drive had its own risk. A feature that fetches a pasted link can be abused to make the server call addresses it shouldn't (SSRF). So the server never fetches the pasted link: it extracts the file ID, builds the download address itself, and follows redirects only to Google's own hosts. The site keeps its own copy, so it doesn't depend on Drive afterwards.
The contact form
The browser never talks to the API directly; the website forwards messages with a shared secret. Bots get a normal-looking success response, so they don't learn what gave them away. The IP address is never stored: a keyed hash lets me block a repeat spammer without keeping the address itself, and it is erased after 90 days. What you don't store can't leak.
What testing uncovered
Unit tests passed, so I tested the way things actually fail: a real browser, at phone, tablet and desktop widths, in both themes, against a temporary copy of the database so nothing real was at risk. I also stopped the API on purpose, and that found the most serious bug.
When the API was down, the site replaced my content with "No projects yet". The code treated "the API failed" and "there is nothing to show" as the same thing, returned an empty list, and the cache saved that empty page. On a host that puts idle servers to sleep, that could happen during normal use. The fix was to raise an error when the API fails, so the framework keeps serving the last good page. Empty and failed are different states, and code should keep them apart.
Other finds from the same round: a file above the upload limit crashed the whole admin page instead of showing a message, and my login limit counted successful sign-ins, so I could have locked myself out. Dependency scanning also flagged critical advisories in the Next.js version I was using, including one in image handling, which led to an upgrade.
What I would improve
The site still needs a stricter content security policy, and uploaded PDFs currently keep their own metadata. Both are on my list.