Skip to content

BE-1: Repository Setup (Core + DB + Tooling) #1

@tecnodeveloper

Description

@tecnodeveloper

Initialize the backend repository for the Book Store API using Node.js and Express. The project should include development tooling, linting/formatting, SQLite with an ORM, auto-reloading, Swagger docs, and a Dockerfile for deployment.

Goals

Set up a clean, consistent, and production-ready base project.

Tech Decisions

  • DB: SQLite (lightweight, file-based)
  • ORM: Prisma (modern, beginner-friendly, great DX)

Tasks

  • Initialize Node.js project (npm init)

Core Setup

  • Install core dependencies:

    • express
    • @prisma/client
  • Install dev dependencies:

    • nodemon
    • eslint
    • prettier
    • eslint-config-prettier
    • eslint-plugin-prettier
    • lint-staged
    • husky
    • prisma

Express App

  • Create basic Express server (app.js or server.js)
  • Add health route:
    • GET /health

Database Setup (SQLite + Prisma)

  • Initialize Prisma:

    npx prisma init
  • Configure SQLite in schema.prisma

  • Create Book model:

    • id (Int, primary key)
    • name (String)
    • author (String or JSON)
    • price (Float)
    • publisher (String, optional)
  • Run migration:

    npx prisma migrate dev
  • Generate Prisma client

  • Test DB connection

Linting & Formatting

  • Configure ESLint:

    • Initialize config
    • Add recommended rules
    • Integrate with Prettier
    • Add custom rules
    • Add .eslintignore
  • Configure Prettier:

    • Add .prettierrc
    • Add .prettierignore

Staged Linting (Pre-commit)

  • Initialize Husky

  • Add pre-commit hook

  • Configure lint-staged:

    • Run ESLint on staged .js files
    • Run Prettier on staged files
  • Ensure commits fail on lint errors

Dev Experience

  • Add .gitignore
  • Configure nodemon:
    • Add nodemon.json or script

Swagger Setup

  • Install:
    • swagger-ui-express
    • swagger-jsdoc
  • Create Swagger config
  • Add /api-docs route

Scripts

  • Add npm scripts:
    • start
    • dev
    • lint
    • lint:fix
    • format
    • prisma:migrate
    • prisma:generate

Docker (App Only)

  • Create Dockerfile
  • Define:
    • Node base image
    • Working directory
    • Install dependencies
    • Copy source code
    • Expose port
    • Start command

Acceptance Criteria

  • App runs:
npm run dev
  • Server starts without errors
  • Swagger available at /api-docs
  • SQLite DB connected via Prisma
  • Migration runs successfully
  • ESLint & Prettier work
  • Pre-commit hook blocks bad commits
  • Health route works

Definition of Done

  • Repo pushed to GitHub
  • DB setup working
  • Dockerfile builds successfully
  • Project runs with:
npm install
npm run dev

Optional (Nice to Have)

  • Add dotenv

  • Add folder structure:

    • /src/routes
    • /src/controllers
    • /src/middlewares
    • /src/services
  • Add README

Metadata

Metadata

Labels

No labels
No labels

Projects

Status

In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions