Portmon.
SaaS web application and REST API for monitoring open network ports on the IP addresses a company registers. It shows each address with its ports, port states and last scan time, a metrics panel and a feed of recent changes. Access is split between vendor and company roles, and a Stripe subscription with a free trial unlocks the product for a company.
- Year
- 2025
- Built for a client
- My part
- Lead developer
- Website
- Not public
- No public link
My role
Capabilities
Monitoring
- Infinite table of IP addresses with cursor paging, virtualized rows and expandable rows for addresses with several ports
- Search, port state and time range filters, sorting and page size kept in the URL
- Add, edit, delete and restore of an IP address
- Side panel with a chart of ports by state, the total of addresses, changes of the last 24 hours and a feed of the latest port changes
Companies, users and roles
- Four roles with one permission matrix for the API and the interface
- Company list with user, address and open port counts, and activate and deactivate
- User list with status tabs and a role filter, and editing of name, company and roles
- Permissions screen showing which of 12 permissions each role has
Patterns and decisions
- I led 1 other developer and built half. Another developer built the back end. The application is a web interface and a REST API for monitoring open network ports on the IP addresses a company registers. A separate scanner fills the database, and the application reads it.
- The code is a Turborepo monorepo with pnpm workspaces. Two applications, a Koa API and a Next.js interface, share five packages: Zod schemas, derived TypeScript types, status enums, constants and the Prisma client. The same email, password and IP rules run in the browser and on the server.
- The API has 30+ endpoints and the database 15+ Prisma models on PostgreSQL. Addresses use the native network address column type. A hand-written OpenAPI document describes the API.
- One validation middleware merges body, query and params and answers with errors keyed by field. The interface reads them and sets each message under the matching input.
- Authentication uses an email and password. A random access token is stored in the database and travels in an httpOnly cookie or a Bearer header. A 401 from the API clears the cached account in the browser, so the interface returns to sign-in.
- The interface is Next.js with the App Router, React Compiler and Tailwind CSS. Data comes through TanStack Query, prefetched on the server, and the URL state is parsed with nuqs.
- Deleting is soft for IP addresses, companies and users. A deleted entry can be restored from the same table, a deactivated company loses its sessions, and nobody can delete or activate the signed-in account.
Cases
One permission model for four roles. Vendor staff run many companies, company admins run only the company of the account, and viewers may only look. Scattered checks would drift apart. The code keeps a single typed matrix of role, resource and action. A rule is either a plain yes or no, or a function that compares the user's company with the record's company. Every write route runs the same check, and list queries narrow their scope by the user's highest role. The same endpoint returns everything to a global admin and only one company's data to a company user. The interface follows the same matrix. Add and menu controls disappear for viewers, and a Permissions screen shows which of 12 permissions each role holds. Port counts and the changes of the last 24 hours are computed per role in the same way.
A subscription that locks the application. Access had to follow a paid Stripe subscription per company, with a free trial, and without a billing table of our own. Checkout sessions carry the company id. The first purchase gets a 7-day trial and later ones do not. Plans and prices are read live from Stripe products, so a price change needs no deploy. A webhook, checked by its signature, stores the subscription end date on the company at purchase and at renewal. A session refresh endpoint then reissues the cookie with that date as its expiry. A guard in front of every private route ends the session once the date has passed, and vendor roles are exempt. On the pricing page a company admin sees the buy buttons, other roles are told to ask the company admin, and an active company sees a confirmation instead.
A monitoring table that stays fast on large IP lists. A company can own a very long list of addresses, and each address can have many ports. The API pages by cursor. It asks for one row more than the page size to know whether a next page exists. The interface loads the next page as the user nears the bottom and renders only the visible rows with TanStack Virtual. Each address is one summary row that expands to show its other ports. Search, port state, time range, sort and page size live in the URL and are parsed on the server. A filtered view is therefore a link that opens the same way for whoever receives it. A change of filter queries the server again and shows a loader, never a stale list, and an empty result explains itself in words.