System requirements
Ensure your system meets these requirements before installation:Required software
- Node.js - Version 16.x or higher
- PostgreSQL - Version 12.x or higher
- npm - Version 7.x or higher (comes with Node.js)
Optional tools
- Docker & Docker Compose - For containerized deployment
- Git - For version control
- Postman or Insomnia - For API testing
Installation methods
- Local Installation
- Docker Installation
Database setup
Create a PostgreSQL database
Connect to your PostgreSQL server and create a new database:Configure the database connection
The API uses Prisma ORM to interact with PostgreSQL. Configure your database connection in the.env file:
username- Your PostgreSQL username (default:postgres)password- Your PostgreSQL passwordlocalhost:5432- Your database host and portmedical_appointments- Your database name
Environment configuration
Create environment file
Copy the example environment file:Configure environment variables
Edit.env with your specific configuration:
.env
Environment variable reference
| Variable | Description | Default | Required |
|---|---|---|---|
PORT | Server port number | 3005 | No |
NODE_ENV | Environment mode | development | No |
SALT_ROUNDS | bcrypt salt rounds for password hashing | 11 | No |
DATABASE_URL | PostgreSQL connection string | - | Yes |
JWT_SECRET | Secret key for signing JWT tokens | - | Yes |
Database migrations
Run Prisma migrations
Create the database schema by running migrations:- Create all necessary tables based on the Prisma schema
- Generate the Prisma Client
- Apply all pending migrations
Prisma schema overview
The database includes these main tables: User table:Generate Prisma Client
Generate the type-safe Prisma Client:Seed the database
Load sample data
Populate the database with initial test data:- Sample user accounts with different roles (Admin, Doctor, Patient)
- Example time blocks for doctor availability
- Sample appointments
Seeding is optional and primarily useful for development and testing. Skip this step in production environments.
Start the server
Development mode
Run the server with auto-reload on file changes:--watch flag to automatically restart when files change.
Production mode
Run the server in production mode:Verify the server is running
You should see output similar to:Verification steps
Test the base endpoint
Verify the server is responding:Access Swagger documentation
Open your browser and navigate to:Test database connection
Verify Prisma can connect to the database:http://localhost:5555.
Register a test user
Create a test user account:Troubleshooting
Common issues
Database connection failed- Verify PostgreSQL is running:
pg_isready - Check your
DATABASE_URLin.env - Ensure the database exists:
psql -l
- Change the
PORTin.envto an available port - Kill the process using the port:
lsof -ti:3005 | xargs kill -9
- Regenerate the client:
npx prisma generate - Clear the Prisma cache:
rm -rf node_modules/.prisma
- Reset the database:
npx prisma migrate reset - Check for schema conflicts in
prisma/schema.prisma
Next steps
Quickstart Guide
Follow our quickstart to make your first API calls
Authentication
Learn how to authenticate users and manage JWT tokens
User Roles
Understand role-based access control in the system
Time Blocks
Learn about the time block and appointment system