Skip to main content
This guide will take you from zero to a running API with your first successful request. You’ll set up the database, start the server, and make a test API call.

Prerequisites

Before you begin, ensure you have:
  • Node.js 18 or higher
  • pnpm package manager
  • PostgreSQL database (local or remote)

Installation

1

Clone and install dependencies

git clone <your-repository-url>
cd backend
pnpm install
2

Configure environment variables

Create a .env file in the project root with your database connection:
DATABASE_URL="postgresql://user:password@localhost:5432/kioto_teteria"
JWT_SECRET="your-secure-jwt-secret-key"
PORT=3000
Replace the database credentials with your actual PostgreSQL connection details. Use a strong, random string for JWT_SECRET in production.
3

Set up the database

Generate the Prisma client and run migrations to create your database schema:
pnpm run prisma:generate
pnpm run prisma:migrate
This creates the following tables:
  • Admin - Admin users with authentication
  • Category - Product categories
  • Product - Tea and beverage products
  • Order - Customer orders
  • OrderItem - Individual items in orders
  • NewsletterSubscriber - Email subscribers
4

Start the development server

pnpm run start:dev
You should see:
🚀 Server ready at http://localhost:3000

Make Your First API Request

Now that your server is running, let’s test it with a real API call.

Fetch all products

curl http://localhost:3000/products
Expected response:
{
  "data": [],
  "meta": {
    "page": 1,
    "pageSize": 10,
    "total": 0,
    "totalPages": 0
  }
}
The response will be empty initially since you haven’t added any products yet. This is normal for a fresh installation.

Fetch products by category

Get products filtered by a specific category:
curl http://localhost:3000/products/category/1

Get a specific product

Retrieve a single product by ID:
curl http://localhost:3000/products/1

Next Steps

Congratulations! Your Kioto Teteria Backend is now running. Here’s what to explore next:

Authentication

Learn how to create admin accounts and authenticate API requests

Products API

Explore all product endpoints including creation and management

Orders API

Handle customer orders and order processing

Categories API

Organize products with category management

Common Issues

Database connection errors

If you see connection errors, verify:
  • PostgreSQL is running
  • Database credentials in .env are correct
  • The database exists (create it with createdb kioto_teteria if needed)

Port already in use

If port 3000 is occupied, change the PORT variable in your .env file:
PORT=3001

Prisma client errors

If you encounter Prisma errors, regenerate the client:
pnpm run prisma:generate

Build docs developers (and LLMs) love