This guide provides instructions for deploying the Array Banking Application using Docker and setting up monitoring with Prometheus and Grafana.
The Array Banking Application is containerized using Docker and orchestrated with Docker Compose. The application consists of the following components:
- PostgreSQL Database: Stores user accounts and transaction data (accessible on host at port 5433)
- Flask Backend: Provides the API and server-side rendering
- SvelteKit Frontend: Provides the single-page application interface
- Nginx Proxy: Routes requests to the appropriate service
- Monitoring Stack: Collects and visualizes metrics and traces
- Docker and Docker Compose installed
- Git (to clone the repository)
- 4GB+ of RAM available for the containers
- Ports 2791 (app), 9090 (Prometheus), and 3000 (Grafana) available
git clone <repository-url>
cd array-banking-appCreate a .env file in the root directory to customize the deployment:
# Database Configuration
DB_USER=postgres
DB_PASSWORD=your_secure_password
DB_NAME=bankdb
# JWT Configuration
JWT_SECRET_KEY=your_secure_jwt_key
# Grafana Configuration
GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=your_secure_passworddocker-compose up -dThis command will:
- Build all the necessary Docker images
- Create and start the containers
- Initialize the database with the schema
- Set up the monitoring stack
- Banking Application: http://localhost:2791
- SPA (Single Page Application): http://localhost:2791/spa
- SSR (Server-Side Rendered): http://localhost:2791/ssr
- PostgreSQL Database:
- From host machine: localhost:5433
- Connection string:
postgresql://postgres:postgres@localhost:5433/bankdb - Note: Inside the Docker network, services still connect to PostgreSQL using port 5432
docker-compose downTo remove all data (including the database):
docker-compose down -vThe application includes a comprehensive monitoring stack with:
- Structured Logging: JSON-formatted logs with request IDs for correlation
- OpenTelemetry Tracing: Distributed tracing for API requests and database queries
- Prometheus Metrics: Collection of system and business metrics
- Grafana Dashboards: Visualization of metrics and performance data
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (default credentials: admin/admin or as configured in .env)
The Grafana instance comes pre-configured with the following dashboards:
- Banking App Dashboard: Overview of application performance and business metrics
- System metrics (CPU, memory)
- API performance (request rates, latencies)
- Business metrics (transaction counts, amounts)
- Error rates and types
The application collects the following types of metrics:
- CPU and memory usage
- Container health
- Network I/O
- Request counts by endpoint
- Response times (average, p95, p99)
- Error rates by status code
- Rate limiting events
- Transaction counts by type (deposit/withdrawal)
- Transaction amounts
- Error counts by type
- User activity
Container logs can be viewed using Docker commands:
# View logs for all containers
docker-compose logs
# View logs for a specific service
docker-compose logs backend
# Follow logs in real-time
docker-compose logs -fThe backend service produces structured JSON logs that can be parsed and analyzed by log management tools.
-
Database Connection Errors
- Check that the PostgreSQL container is running:
docker-compose ps - Verify database credentials in the .env file
- Check database logs:
docker-compose logs postgres
- Check that the PostgreSQL container is running:
-
Application Not Accessible
- Ensure all containers are running:
docker-compose ps - Check if the proxy container is healthy:
docker-compose logs nginx-proxy - Verify that ports are not in use by other applications
- Ensure all containers are running:
-
Monitoring Not Working
- Check that Prometheus and Grafana containers are running
- Verify that the OpenTelemetry collector is receiving data:
docker-compose logs otel-collector - Check Prometheus targets at http://localhost:9090/targets
-
Port Conflicts
- If you have services already running on your host machine (like PostgreSQL on port 5432), you may encounter port conflicts
- The PostgreSQL container is configured to use port 5433 on the host to avoid conflicts with locally installed PostgreSQL
- If you encounter other port conflicts, you can modify the port mappings in the docker-compose.yml file
- Format is
"host_port:container_port", so change the host_port to an available port
To restart a specific service:
docker-compose restart <service-name>For example, to restart the backend:
docker-compose restart backend