Installation Guide
This comprehensive guide covers everything you need to install, configure, and deploy the MTB Backend API in both development and production environments.System Requirements
Required Software
Node.js
Version 20.0.0 to 24.x.x
npm
Version 6.0.0 or higher
Database
SQLite (default), MySQL, or PostgreSQL
Git
For version control (optional)
Recommended System Specs
- RAM: Minimum 2GB, recommended 4GB+
- Storage: At least 500MB free space
- OS: Linux, macOS, or Windows
- CPU: 2+ cores recommended for production
The MTB Backend has been tested on Node.js 20.x and 24.x. Using versions outside the supported range may cause compatibility issues.
Installation Methods
Method 1: Fresh Installation
Install Node.js
Download and install Node.js from nodejs.org:
Install Dependencies
Install all required npm packages:This installs:
@strapi/[email protected]- Core framework@strapi/[email protected]- Authentication@strapi/[email protected]- Cloud deployment support[email protected]- SQLite database driveraxios@^1.13.4- HTTP clientreact@^18.0.0- Admin panel UI- TypeScript and type definitions
Method 2: Using Docker
While the repository doesnโt include a Dockerfile yet, you can containerize the application using a custom Dockerfile:For production deployments, consider using Docker Compose to orchestrate the application with your chosen database.
Configuration
Environment Variables
Create a.env file in the project root with the following configuration:
Understanding Server Configuration
Understanding Server Configuration
The server configuration from
/config/server.ts:1:HOST: Network interface to bind (0.0.0.0 allows external connections)PORT: HTTP port for the API serverAPP_KEYS: Encryption keys for sessions and cookies (required)
Database Configuration Details
Database Configuration Details
The database configuration from
/config/database.ts:3 supports multiple databases:SQLite (Default)- Best for: Development, small deployments
- No setup required
- Data stored in:
.tmp/data.db
- Best for: Medium to large production deployments
- Requires MySQL 5.7.8+ or MariaDB 10.3+
- Supports connection pooling and SSL
- Best for: Large-scale production deployments
- Requires PostgreSQL 10+
- Supports schemas and advanced features
/config/database.ts:23:Flow Payment Integration
Flow Payment Integration
The Flow payment integration is implemented in
/src/api/flow/controllers/flow.ts:8.Sandbox Environment (Testing):- URL:
https://sandbox.flow.cl/api - Use test credentials from Flow developer portal
- No real money transactions
- URL:
https://www.flow.cl/api - Requires verified Flow account
- Real payment processing
- Registration creation with payment status โPendienteโ
- Payment URL generation with HMAC-SHA256 signature
- Redirect to Flow payment page
- Webhook confirmation at
/api/flow/confirmacion
API Configuration
API Configuration
Default API settings from
/config/api.ts:1:defaultLimit: Default number of results per pagemaxLimit: Maximum results that can be requestedwithCount: Include total count in pagination
Generating Secure Keys
Generate cryptographically secure APP_KEYS:.env as a comma-separated string:
Database Setup
SQLite (Default)
No additional setup required. The database file is created automatically on first run:.tmp/data.db as configured in /config/database.ts:46.
MySQL Setup
PostgreSQL Setup
Running the Application
Development Mode
Start the server with auto-reload for development:- Automatic restart on file changes
- Detailed error messages
- Admin panel at
http://localhost:1337/admin - API at
http://localhost:1337/api
Development mode uses more memory and CPU due to file watching. Use production mode for deployment.
Production Mode
Using Process Managers
For production deployments, use a process manager to keep the application running:Middleware Configuration
The application uses these Strapi middlewares (from/config/middlewares.ts:1):
Content Type Overview
The MTB Backend includes these pre-configured content types:Club Schema
From/src/api/club/content-types/club/schema.json:1:
Inscripcion Schema
From/src/api/inscripcion/content-types/inscripcion/schema.json:1:
Inscrito Schema
From/src/api/inscrito/content-types/inscrito/schema.json:1:
Security Considerations
Security Checklist
- Generate strong, unique APP_KEYS
- Use strong database passwords
- Enable HTTPS in production
- Configure CORS to restrict origins
- Set up proper user roles and permissions
- Keep dependencies updated (
npm audit) - Use environment variables for all secrets
- Enable rate limiting for API endpoints
- Regular database backups
Recommended Environment Variables for Production
Troubleshooting
Error: APP_KEYS is not set
Error: APP_KEYS is not set
Solution: Generate APP_KEYS as shown above and add them to your
.env file.Database connection failed
Database connection failed
For MySQL/PostgreSQL:
- Verify database server is running
- Check credentials in
.env - Ensure database exists
- Test connection:
mysql -u strapi -porpsql -U strapi -d strapi
- Check
.tmpdirectory exists and is writable - Ensure sufficient disk space
Port already in use
Port already in use
Change the PORT in
.env or kill the process:Flow payment errors
Flow payment errors
Common issues:
- Invalid signature: Check
FLOW_SECRET_KEYis correct - Invalid API key: Verify
FLOW_API_KEY - Wrong base URL: Use sandbox URL for testing
- Network errors: Check firewall and internet connectivity
/src/api/flow/controllers/flow.ts:60 to see detailed Flow API requests.Build fails with TypeScript errors
Build fails with TypeScript errors
Next Steps
Configure Admin Panel
Set up roles, permissions, and customize the admin interface
API Reference
Explore all available API endpoints and parameters
Deploy to Production
Learn about deployment options and best practices
Strapi Documentation
Official Strapi 5 documentation
Additional Resources
- Strapi Configuration Documentation
- Strapi Deployment Guide
- Flow Payment API Documentation
- Node.js Best Practices
