This guide provides step-by-step instructions for installing and setting up the Invoice API project.
- Node.js (v20 or higher)
- Docker and Docker Compose
- npm or pnpm package manager
git clone https://github.com/Warisaremou/billzy-api.git billzy-api
cd billzy-apiCopy the example environment file to create your local configuration:
cp env-example .envEdit the .env file with your configuration:
# APP
NODE_ENV=development
APP_PORT=5050
APP_NAME="Billzy"
API_PREFIX=api
API_VERSION=1.0.0
APP_FALLBACK_LANGUAGE=en
FRONTEND_DOMAIN=http://localhost:4200
# DATABASE (for running outside Docker)
DATABASE_TYPE=mariadb
DATABASE_HOST=localhost
DATABASE_PORT=3309
DATABASE_USERNAME=root
DATABASE_PASSWORD=rootpassword
DATABASE_NAME=my_invoice
# AUTH
AUTH_JWT_SECRET=<generate-secret-here>Generate a JWT secret for authentication:
openssl rand -hex 64Copy the output and paste it as the value for AUTH_JWT_SECRET in your .env file.
Note: When running outside Docker, use
DATABASE_HOST=localhostandDATABASE_PORT=3309. When running inside Docker containers, useDATABASE_HOST=dbmsandDATABASE_PORT=3306.
npm installdocker compose up -dWait a few seconds for the services to fully initialize, then verify they are running:
docker psCreate the database schema by running migrations:
npm run migration:runPopulate the database with initial data:
npm run seed:runThis will create:
- Default roles (super_admin, admin, user)
- 6 sample companies
- 2 sample super_admin users
Run the application with hot-reload enabled:
npm run api:devOnce the application is running, you can verify the installation by accessing:
- API Info:
http://localhost:5050/api/info - API Documentation (Swagger):
http://localhost:5050/api/docs
To generate a new migration
npm run migration:generate -- src/database/migrations/<DescriptionOfMigration>Ex: npm run migration:generate -- src/database/migrations/FirstMigration
Run migration
npm run migration:runRevert migration
npm run migration:revertDrop all tables in database
npm run schema:dropRun seed
npm run seed:runIf you encounter ENOTFOUND dbms error when running outside Docker:
- Ensure your
.envfile hasDATABASE_HOST=localhostandDATABASE_PORT=3309 - Verify the database container is running:
docker ps
If port 5050 is already in use:
- Change
APP_PORTin your.envfile - Or stop the conflicting service
You can also create database manually using a database client of your by connecting to the MariaDB instance.
Lint and fix code:
npm run lintFormat code with Prettier:
npm run formatRun tests:
npm run testRun tests in watch mode:
npm run test:watchRun tests with coverage:
npm run test:covRun integration tests:
npm run test:integrationRun integration tests in watch mode:
npm run test:integration:watchRun integration tests with coverage:
npm run test:integration:covRun e2e tests:
npm run test:e2e