.
├── 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)