Quick Start Guide
This guide will help you set up and run the Banca Management Backend locally, configure your environment, and make your first authenticated API request.Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version 20.x required
PostgreSQL
Version 14+ recommended
Redis
Optional for caching
The project uses Prisma ORM which requires a PostgreSQL database. For production, Supabase with transaction pooler (port 6543) is recommended.
Installation
Install dependencies
- Express.js and middleware (cors, helmet, express-rate-limit)
- Prisma Client and CLI
- Authentication (jsonwebtoken, bcryptjs)
- Validation (zod)
- Logging (pino)
- Testing (jest, supertest)
Configure environment variables
Create a Edit
.env.local file in the root directory based on .env.example:.env.local with your configuration (see Environment Configuration below).Seed initial data (optional)
Environment Configuration
The.env.local file contains critical configuration. Here are the essential variables:
Server Configuration
Database URLs
The system supports three database connection strings for optimal performance:
If
DATABASE_URL_REPLICA is not configured, the system automatically falls back to the primary DATABASE_URL for read queries.JWT Configuration
Business Rules
Redis Cache (Optional)
Transaction Settings
Making Your First API Request
Once the server is running, you can interact with the API. Here’s how to authenticate and make your first request.1. Register a User
For development, you can set
DISABLE_AUTH=true in your .env.local to bypass authentication and simulate an ADMIN user.2. Login
3. Access Protected Endpoints
Use theaccessToken from the login response in the Authorization header:
4. Explore Available Routes
Here are some key endpoints to explore:Development Scripts
The project includes several useful npm scripts:Next Steps
System Architecture
Learn about the layered architecture, data models, and request flow
API Reference
Explore detailed API documentation for all endpoints
Authentication
Deep dive into JWT auth, roles, and security
Commission System
Configure hierarchical commission policies
Troubleshooting
Migration errors with Supabase/PgBouncer
Migration errors with Supabase/PgBouncer
Use
npm run migrate:deploy instead of migrate:dev. Shadow database is disabled for PgBouncer compatibility.JWT token errors
JWT token errors
Ensure your
JWT_ACCESS_SECRET and JWT_REFRESH_SECRET are set and match between requests. Check token expiration settings.CORS errors from frontend
CORS errors from frontend
Add your frontend origin to the
CORS_ORIGIN environment variable (comma-separated for multiple origins).Database connection timeouts
Database connection timeouts
For Supabase, verify you’re using the correct pooler port (6543 for transaction pooler, 5432 for session pooler). Check connection limits.
Need help? Contact the maintainer at [email protected]