Prerequisites
Before you begin, ensure you have the following installed on your system:Node.js 18+
JavaScript runtime
PostgreSQL 16+
Relational database
Docker (Optional)
For containerized PostgreSQL
Install Dependencies
Install all required npm packages:This will install the following key dependencies:
- Express.js 5.2 - Web framework
- Prisma 7.2 - Database ORM
- TypeScript 5.9 - Type-safe development
- Zod 4.2 - Schema validation
- jsonwebtoken 9.0 - JWT authentication
- bcryptjs 3.0 - Password hashing
- Winston 3.19 - Logging
Configure Environment Variables
Copy the example environment file and configure it:Open
.env and update the configuration:.env
Start PostgreSQL Database
You can start PostgreSQL using Docker or your local installation:This will start a PostgreSQL container with the credentials from your
Using Docker (Recommended)
If you have Docker installed, start PostgreSQL with:.env file.Using Local PostgreSQL
If you have PostgreSQL installed locally, ensure it’s running and create a database:Make sure the database credentials in your
.env file match your PostgreSQL setup.Initialize Database
Run the database migrations and seed initial data:This command performs the following actions:
- Drops all existing tables (force reset)
- Pushes the Prisma schema to the database
- Runs the seed script to populate initial data
Alternative: Non-destructive Migration
For production or when preserving data, use:Start the Development Server
Launch the API server with hot reload:The server will start on the configured port (default:
http://localhost:4000).You should see output similar to:Verify Health Check
Test that the API is running correctly:You should receive a response indicating the API is healthy:
Available Scripts
The Platform API includes several npm scripts for development and deployment:Testing Your Setup
Now that your API is running, let’s test the complete authentication flow:1. Register a User
2. Login
3. Get User Profile
Using the access token from registration or login:4. Refresh Token
5. Logout
Project Structure
Understanding the project structure will help you navigate the codebase:Common Issues
Port already in use
Port already in use
If port 4000 is already in use, change the Then restart the server.
PORT variable in your .env file:.env
Database connection failed
Database connection failed
Verify that:
- PostgreSQL is running:
docker ps(for Docker) orpg_isready(for local) - Database credentials in
.envare correct - Database exists:
psql -U postgres -l - Network connectivity:
telnet localhost 5432
Prisma schema errors
Prisma schema errors
If you encounter Prisma schema errors:
JWT token errors
JWT token errors
Ensure your
JWT_SECRET and REFRESH_TOKEN_SECRET are at least 32 characters long. Generate new secrets:Next Steps
Authentication Guide
Learn about JWT authentication, refresh tokens, and security best practices
API Reference
Explore all available endpoints and their parameters
Database Schema
Deep dive into the database structure and relationships
Deployment
Deploy your Platform API to production