· 4 min read
One Next.js monolith for a factory's site, admin and dealer messaging
CELE builds farm implements in Armstrong, Santa Fe. Its web platform is a single Next.js app that serves the catalog, a full admin and a dealer inbox, and the boundaries between them are the interesting part.
CELE makes seeders, harrows and weed-control rigs in Armstrong, Santa Fe. The company has been building farm implements for over forty years, and its website has to do three different jobs: sell the catalog to farmers, give the staff a way to run the business behind it, and let its network of 44 dealers talk to the factory.
The obvious move would be three services. The project went with one Next.js app, and this post is about why that was the better answer.

Three surfaces, one codebase
The app is a modular monolith on the Next.js 16 App Router. It has three areas that share one auth layer, one database and one design system:
- The public site under
app/(site): home, the product catalog with interactive spec sheets, news, the company page, a dealer map built with Leaflet, a quote-request cart and a power calculator. - The admin under
app/admin: a CMS, CRUD for products, news and dealers, inquiries and quotes, users and permissions, and an integrated mailbox client. - Messaging under
app/admin/mensajes: real-time conversations between staff and dealers, with email and web-push notifications.

The reason to keep them together is that they all read the same things. A product edited in the admin is the product on the public page. A dealer created in the admin is a pin on the public map and a participant in the inbox. One schema, one set of Drizzle types, no sync layer between services.
What sits underneath
| Concern | Choice |
|---|---|
| Rendering | Next.js 16, React 19, Cache Components (PPR), React Compiler |
| Data | Neon Postgres with Drizzle ORM and versioned migrations |
| Auth | Custom: JWT with jose, scrypt passwords, sessions, RBAC, TOTP MFA |
| Realtime | Upstash Redis and ioredis pub/sub behind a WebSocket route |
IMAP and SMTP (imapflow, nodemailer), credentials encrypted at rest |
|
| Files | Vercel Blob, public for media and private for product manuals |
| Protection | BotID on forms, login and uploads; Sentry for errors |
The custom auth is the choice people ask about. Off-the-shelf auth would have been fine for sign-in, but this app needs a role model that the product itself depends on: owners and admins get everything, dealers get messaging and manuals, and clients get nothing administrative. Permissions are checked in Server Components, Server Actions and Route Handlers through one requirePermission helper, and the proxy only does coarse routing. The proxy is a convenience, never the authority.
The data model in one paragraph
Identity tables (users, sessions, roles, role_permissions, user_roles) sit next to business tables (products, news, dealers, inquiries, quotes) and a pair of CMS tables (page_content and page_images) keyed by page and slot. Technical reviews, a viewer where a product gets annotated photos with pins, have their own small cluster of tables, and messaging has conversations, participants, messages and attachments. Nothing is exotic, which is the point: a factory's data should be boring enough that the next person can read the schema in an afternoon.
Migrations without drama
The database workflow has two modes. In development, db:push syncs the schema straight to a Neon dev branch. In production, db:generate writes a SQL migration, it gets committed, and db:migrate applies it on deploy. The migrate step is idempotent, so it is safe to run on every release.
The repo's own notes are honest about the rough edge. The live database was built with push first, so its migration ledger drifted, and migrations 0015 to 0018 are hand-written catch-up SQL guarded with IF NOT EXISTS. A reconciled snapshot now represents the full schema, so future generated migrations diff from a valid baseline. The rule that came out of it: never edit a migration that has been applied anywhere, and prefer additive changes with safe defaults so a release never needs downtime.
Why not services
A monolith can be a trap, so here is what made it safe in this case.
- One team, one deploy. There is no org chart that needs service boundaries.
- Shared reads dominate. Almost every screen joins products, dealers or content. Splitting them would turn joins into network calls.
- The seams are in the folders.
app/,components/,lib/andhooks/have clear directions of dependency, and each domain has its own folder underlib/(db,auth,mail,notifications,seo). If the messaging module ever needed to leave, its edge is already drawn. - Realtime is the one thing that does not fit the model, and it is isolated: the WebSocket route authenticates before the upgrade, accepts no arbitrary commands and caps payload size.
The system is documented with a map in the repo that is deliberately kept honest: it says it describes the code that exists and presumes no service that is not in the repository. That discipline, treating app/ as the source of truth for routes and lib/db/schema.ts as the source of truth for data, is what keeps a monolith navigable as it grows.

The next posts cover how the admin lets staff edit the site inline, how caching and SEO are set up, and what a security review of the app found.