Skip to content

EduNex-Academy/infrastructure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Infrastructure Setup Guide

This folder contains the Docker Compose configuration for the EduNex platform's backend services.

Overview

The infrastructure includes:

  • PostgreSQL Databases - For subscription and course service data
  • Subscription Service - Handles billing and subscription management
  • Course Service - Manages course content and AWS S3 integration
  • API Gateway - Routes requests and handles authentication

Prerequisites

  • Docker and Docker Compose installed
  • Stripe API keys (for payment processing)
  • AWS credentials (for S3 and CloudFront)
  • Access to deployed Auth Service and Keycloak IAM

External Dependencies

The services connect to already deployed external services:

  • Auth Service: https://auth-api.edunex.app
  • Keycloak IAM: https://keycloak-auth.edunex.app

🔐 Environment Configuration (IMPORTANT)

This setup uses environment variables to keep secrets secure and out of version control.

1. Initial Setup

Copy the example environment file and configure it with your actual values:

cp .env.example .env

2. Configure the .env file

Edit the .env file and replace placeholder values with your actual credentials:

Required Stripe Configuration

  • Get your Stripe credentials from Stripe Dashboard
  • Navigate to Developers → API keys for STRIPE_API_KEY
  • Navigate to Developers → Webhooks for STRIPE_WEBHOOK_SECRET

Required AWS Configuration

  • Get your AWS credentials from AWS Console
  • Ensure your credentials have access to your S3 bucket
  • Configure your CloudFront distribution domain

Database Passwords

  • Set secure passwords for your PostgreSQL databases
  • These will be used for local development only

3. Environment File Security

  • .env.example - Template file (SAFE to commit)
  • .env - Actual secrets (NEVER commit this file)

The .env file is automatically ignored by git to prevent accidental commits of sensitive data.

Setup Instructions

1. Environment Setup

After configuring your .env file (see Environment Configuration above), verify your setup:

# Check that your .env file exists and has the required variables
cat .env

2. Start the Services

Run the following command from the infrastructure directory:

docker-compose up -d

This will:

  • Start PostgreSQL databases with initialization scripts
  • Build and start the subscription service
  • Build and start the course service
  • Build and start the API gateway

3. Verify Services

Check if all services are running:

docker-compose ps

Check service health:

# Subscription Service
curl http://localhost:8083/actuator/health

# API Gateway
curl http://localhost:8090/actuator/health

Service Endpoints

  • API Gateway: http://localhost:8090
  • Subscription Service: http://localhost:8083
  • Course Service: http://localhost:8082
  • Subscription Database: localhost:5435
  • Course Database: localhost:5433

Database Access

Subscription Database

  • Host: localhost
  • Port: 5435 (configurable via SUBSCRIPTION_DB_PORT)
  • Database: subscription_db (configurable via POSTGRES_DB_SUBSCRIPTION)
  • Username: subscription_user (configurable via POSTGRES_USER_SUBSCRIPTION)
  • Password: Set in your .env file

Course Database

  • Host: localhost
  • Port: 5433 (configurable via COURSE_DB_PORT)
  • Database: course_db (configurable via POSTGRES_DB_COURSE)
  • Username: postgress (configurable via POSTGRES_USER_COURSE)
  • Password: Set in your .env file

Troubleshooting

Common Issues

  1. Service fails to start: Check Docker logs

    docker-compose logs [service-name]
  2. Database connection issues: Ensure PostgreSQL is healthy

    docker-compose logs subscription-db
  3. Stripe configuration errors: Verify your API keys are correct and have proper permissions

Useful Commands

# View logs for all services
docker-compose logs -f

# View logs for specific service
docker-compose logs -f subscription-service

# Restart a specific service
docker-compose restart subscription-service

# Stop all services
docker-compose down

# Stop and remove volumes (caution: this will delete database data)
docker-compose down -v

Network Configuration

All services run on the edunex-platform-network bridge network, allowing internal communication between containers.

Volume Management

  • subscription_db_data: Persists PostgreSQL data
  • Database initialization: Uses ./db/subscriptions_init.sql for initial schema setup

Security Notes

  • Never commit actual Stripe API keys to version control
  • Use environment variables or secure secrets management in production
  • The current configuration is suitable for development/testing environments

Production Considerations

For production deployment:

  1. Use production Stripe keys instead of test keys
  2. Configure proper SSL/TLS certificates
  3. Set up proper logging and monitoring
  4. Use secrets management for sensitive credentials
  5. Configure proper backup strategies for the database

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors