hosting platform
Dakota Sites: a hosting and billing platform
# Overview
Dakota Sites is a web hosting and website-building business, and this project is the platform behind it. It's a standalone hosting and billing control plane I built so hosting, customers, and billing all run from one system I control end to end.
It has three parts:
- A public site that explains the service and links to sign-in.
- A staff admin panel for customers, sites, servers, products, billing, and operations.
- A customer portal where customers see their sites and status, manage DNS, SSH keys, and backups, and handle invoices and payment methods.
# What it does
Provisioning
- Native site setup: each site gets its own Linux user, a web root, its own PHP-FPM pool, a MariaDB database, DNS records, an Nginx virtual host, and SSL. WordPress is installed automatically through WP-CLI when wanted, and is optional per site.
- Checkout to live site: a customer picks a plan, pays through Stripe Checkout, and the site is created and provisioned automatically. Its status moves from pending to provisioning to active.
- Safe teardown: deprovisioning takes a backup first, then removes the database, web server and PHP config, Linux user, files, and record, in that order.
- Locking: provisioning runs are locked so two jobs can't work on the same site at once, and each step is recorded as a provisioning event.
Site management
- DNS: a Cloudflare DNS panel on every site (list, add, edit, delete records). New sites get their zone and proxied records created automatically.
- PHP: per-site PHP version and settings.
- Domains: redirects and alias domains.
- WordPress tools: sign-in links, password resets, and a one-click fix for the HTTPS redirect loops WordPress hits behind a proxy.
- SSH and SFTP keys: per-site key management for customers, up to 10 keys per site.
- SEO check: looks at a site's homepage, meta tags, robots file, and HTTPS redirect, and gives plain-language guidance.
Monitoring and backups
- Uptime monitoring: a background worker checks every active site on a schedule (every 5 minutes by default). Email alerts go out when a site goes down and when it recovers. The admin side adds diagnostics such as WordPress health, a database ping, error logs, and a stack repair.
- Server health: CPU, memory, and disk metrics for each hosting server, with history and alerts.
- Backups: scheduled daily, plus on demand, with retention settings. Backups run on the server that hosts the site. Files are archived and the database is dumped using local socket authentication, so no database password crosses the network. A copy can also be pulled off the server.
- Restore: a snapshot is taken automatically before any restore, and customers can run backups and restores from the portal without seeing server paths.
Multiple servers
- Hosting nodes: sites can live on several hosting servers. The panel manages each one over SSH, with each server's SSH key stored encrypted.
- Server setup: new servers are detected (OS family and PHP layout) and prepared from the panel.
- Site migrations: move a site from one server to another as a tracked migration. A cutover guard won't switch DNS to the new server until a test request to the new server and a PHP version check both pass.
Billing
- Stripe: products, subscriptions, invoices, and one-time payments.
- Customer self-service: customers update their payment method and manage subscriptions through Stripe's billing portal.
- Billing-aware hosting: a site's subscription status can suspend it or bring it back.
- Webhooks: every Stripe webhook is signature-checked before it's trusted.
AI-assisted operations
- AI assistants: one works within a single site, and another helps staff across the whole platform.
- Approval first: every action an assistant proposes is saved with a risk level, a pending status, and a rollback hint. Depending on policy, a person has to approve it before it runs, and who requested and who approved each action is recorded.
- Fixed commands: shell access for the assistant is limited to an admin-managed allowlist of named commands, not free-form commands.
# Security design
- Passwords and logins: passwords are hashed with bcrypt. Admin and portal logins have per-IP rate limits and per-account lockout.
- Staff roles: Owner, Admin, and Support. Support is read-only and can't open settings, user management, or API-key pages. Only the Owner manages staff users.
- Customer logins: each customer can have several portal logins, and customers only see their own sites.
- Session control: every request re-checks that the user is still active. A password reset, a disable, or a role change ends that user's other sessions.
- Session cookies: sessions are stored in the database, with HTTP-only cookies that are SameSite=Lax and Secure in production.
- CSRF tokens: synchronizer tokens protect the user-management, password, portal, and public forms.
- Encrypted secrets: stored server SSH keys and API keys are encrypted at rest.
- Least privilege: the panel and its worker run as a dedicated unprivileged user, not root.
- Small footprint: the public health check only reports "ok", with details only available from the server itself. Everything except the public homepage is marked noindex.
- Audit log: user management, provisioning, AI actions, and other admin changes are recorded.
- Careful deploys: every change ships as a bundle with a code (and, when needed, database) backup first, syntax checks, a health check after restart, and a written rollback.
# Tech stack
- App: Node.js 22, Express 5, EJS, Prisma ORM, MySQL or MariaDB, express-session with a MySQL store, bcrypt, express-rate-limit, node-cron, and Nodemailer.
- Hosting stack it manages: Nginx, PHP-FPM, MariaDB, WP-CLI, Let's Encrypt, and Cloudflare.
- Integrations: Stripe (Checkout, subscriptions, billing portal, webhooks), the Cloudflare API, and an AI model API.
- Runtime: PM2 under systemd, with a separate background worker for monitoring, backups, and scheduled jobs.
# What's next
- Roll CSRF tokens out to every admin form.
- Two-factor sign-in for staff (the database fields exist, but it isn't wired up yet).
- Per-site resource limits.
# Links
- Site: dakotasites.com
- Source: private