.
βββ Dockerfile # Docker configuration for containerization
βββ docker-compose.yml # Docker Compose configuration for local development
βββ infrastructure/ # AWS infrastructure automation scripts
β βββ config.sh # Configuration variables for infrastructure
β βββ deploy.sh # Full deployment script for new environments
β βββ ecr.sh # Amazon ECR (Container Registry) setup
β βββ ecs.sh # Amazon ECS (Elastic Container Service) setup
β βββ iam.sh # IAM roles and permissions setup
β βββ loadbalancer.sh # Application Load Balancer configuration
β βββ network.sh # VPC, subnets, and security groups setup
β βββ secrets.sh # AWS Secrets Manager configuration
β βββ update.sh # Update script for existing deployments
β βββ utils.sh # Utility functions for infrastructure scripts
βββ scripts/ # Build helper scripts to solve docker build issues
β βββ postbuild.js
β βββ prebuild.js
βββ src/ # Source code for the application
βββ cache/ # Caching mechanisms
βββ config/ # Application configuration
βββ controllers/ # API controllers
βββ ext/ # External integrations
β βββ indexer/ # Blockchain indexer integration
βββ logger/ # Logging configuration
βββ middleware/ # Express middleware
βββ parsers/ # Data parsing utilities
βββ routes/ # API route definitions
βββ service/ # Business logic services
β βββ priceService/ # Cryptocurrency price services
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
βββ env.ts # Environment configuration
βββ errors.ts # Error handling
βββ index.ts # Application entry point
βββ swagger.ts # API documentation with Swagger
-
Basic Setup:
pnpm install
-
Configure Environment Variables: Copy the
.env.example
file in the root of the project and set coingecko api key. -
Run the Development Server:
pnpm run dev
-
API Overview
- Visit
http://localhost:4000
The application can be updated using the provided update script:
-
Prerequisites:
-
Install AWS CLI
# For macOS brew install awscli # For Ubuntu/Debian sudo apt-get install awscli # For Windows (using PowerShell) choco install awscli
-
Configure AWS CLI with appropriate credentials
aws configure
You'll need to provide:
- AWS Access Key ID
- AWS Secret Access Key
- Default region (e.g., us-east-2)
- Default output format (json recommended)
-
-
Run the update script:
./infrastructure/update.sh [wait_time_in_seconds]
The script performs the following operations:
- Builds a new Docker image from the current codebase
- Tags and pushes the image to Amazon ECR
- Checks the current state of the ECS service
- Handles any health check failures or multiple deployments
- Updates the ECS service with the new image
- Waits for the deployment to complete (default: 5 minutes)
Optional parameter:
wait_time_in_seconds
: How long to wait for deployment to complete (default: 300 seconds)
-
Troubleshooting:
- If health check failures are detected, the script will show recent logs and prompt before continuing
- If multiple deployments are in progress, you'll be given options to:
- Wait for current deployments to complete
- Force cleanup by stopping all tasks
- Continue with the update anyway
-
Monitoring the update: After running the update script, you can monitor the deployment status:
aws ecs describe-services --cluster grants-calculator-cluster --services grants-calculator-api
Or check the logs:
aws logs get-log-events --log-group-name "/ecs/grants-calculator-api" --log-stream-name [log-stream-name]
Note
- For Logging.md to understand use winston for logging
- For Try catch handling done via catchError
- All routes are documented using swagger (NOT YET)