Skip to content

An elegant foundation for SaaS projects. With docker compose, migrations, integration tests, pre-commit, code and commit linting, GitHub Actions, git hooks, etc.

License

Notifications You must be signed in to change notification settings

codigoisaac/SaaS-Base

Repository files navigation

SaaS-Base

A lean, fully wired foundation for SaaS development. It provides a complete Next.js setup, Docker-managed PostgreSQL, structured migrations, and automated environment orchestration - so your project boots with a single command and stays consistent across machines.

The foundation also includes integration testing, plus enforced code quality through ESLint and Prettier. For Git hygiene, it uses Husky, Commitlint, and Commitizen to keep your commit history clean, predictable, and automation-friendly.

Everything is preconfigured to eliminate setup friction, prevent “works on my machine” headaches, and let you focus directly on building product features - not infrastructure.


🚀 Features

🌟 Automated Dev Workflow

The automated development workflow ensures you never waste time manually preparing your environment.

Instead of juggling multiple terminal commands, connection waits, and database setup steps, a single script handles everything: starting infrastructure, validating service readiness, applying migrations, and booting the application. This removes entire classes of “it works on my machine” problems, keeps onboarding effortless for new developers, and makes day-to-day development dramatically smoother and more reliable.

The dev script performs everything in sequence:

  1. Starts Docker services
  2. Waits for PostgreSQL
  3. Applies migrations
  4. Runs Next.js in development mode

Run it with:

npm run dev

Under the hood, what this command will do is:

npm run services:up && npm run services:wait:database && npm run migrations:up && next dev

🌟 Husky + Commitlint + Commitizen

To ensure your project’s Git history stays clean, consistent, and reliable.

Husky enforces checks before bad commits sneak in, Commitlint guarantees every commit message follows a predictable and searchable format, and Commitizen gives contributors an easy, structured way to write proper commit messages without memorizing conventions. Together, they prevent chaotic commit logs, improve collaboration, power automated changelogs, and make long-term maintenance far less painful.

  • Husky hooks installed automatically through prepare script
  • Commitlint enforces conventional commits
  • Commitizen interactive prompts via:
npm run commit

🌟 Jest Test Suite (Integration-Ready)

  • Jest fully configured for ESM
  • Integration tests located in tests/integration/api/v1/...
  • Tests call real Next.js API routes
  • CI test flow automatically spins up services and runs migrations
  • Scripts:
    • npm test
    • npm run test:watch
    • npm run test:ci — runs Next.js + Jest concurrently

🏅 GitHub Actions to ensure quality

Made to ensure the project grows in a clean, secure and professional way, running this GitHub Action on all pull requests:

  • Automated tests
  • Commit linting
  • Code quality linting
  • Code style linting

If you or someone else ever make a bad PR, GitHub will let you know.

alt text

Tip: You can make the tests Required for merge in GitHub's interface. That way, if some check don't pass, the Merge button won't be available, adding some extra security for the project.

🐳 Dockerized Local Environment

Docker Compose (infra/compose.yaml) that provides a PostgreSQL container.

Service commands:

  • npm run services:up — start infrastructure containers
  • npm run services:stop — stop containers
  • npm run services:down — remove containers and volumes

🐘 PostgreSQL + Migrations

  • PostgreSQL managed via Docker Compose
  • Automatic database readiness check (infra/scripts/wait-for-postgres.js)
  • Migration system powered by node-pg-migrate
  • Migration files stored in infra/migrations
  • Scripts:
    • npm run migrations:create — create a new migration file
    • npm run migrations:up — apply pending migrations

🏘️ Next.js Application Structure

  • API routes organized under pages/api/v1/...
  • Example endpoints (such as status)
  • Ready-to-expand modular folder structure
  • ESM-first setup ("type": "module" in package.json)

🧼 ESLint + Prettier

  • ESLint with Next.js, Jest, and Prettier integrations
  • Prettier config prewired
  • Linting commands:
    • npm run lint:eslint:check
    • npm run lint:prettier:check
    • npm run lint:prettier:fix

📜 License

MIT License.

About

An elegant foundation for SaaS projects. With docker compose, migrations, integration tests, pre-commit, code and commit linting, GitHub Actions, git hooks, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published