Skip to content

Commit

Permalink
Add LICENSE and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Pozo committed Jul 23, 2024
1 parent 59bd189 commit 22e51a8
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 12 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 Zoltan Polgar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
104 changes: 92 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,95 @@
GOOGLEFINANCE(ticker, [attribute], [start_date], [end_date|num_days], [interval])
# Investment Funds

## Introduction
The `investment-funds` project is designed to facilitate access to and management of Hungarian investment fund data. It operates by processing CSV files obtained from the bamosz.hu website, transforming this data into a structured format, and making it accessible through a custom-built REST API. This approach aims to provide an easy and efficient way to access Hungarian funds data for analysis and integration into financial applications.

- **ticker** - The ticker symbol for the security to consider. It’s mandatory to use both the exchange symbol and ticker symbol for accurate results and to avoid discrepancies. For example, use “NASDAQ:GOOG” instead of “GOOG.”
- **attribute** - [ OPTIONAL - "price" by default ] - The attribute to fetch about ticker from Google Finance and is required if a date is specified.
- **start_date** - [ OPTIONAL ] - The start date when fetching historical data.
- **end_date|num_days** - [ OPTIONAL ] - The end date when fetching historical data, or the number of days from start_date for which to return data.
- **interval** - [ OPTIONAL ] - The frequency of returned data; either "DAILY" or "WEEKLY".
## Technologies Used
- **Kotlin & Java**: For backend logic and data manipulation.
- **Spring Boot**: For creating the web application and RESTful services.
- **Maven**: For dependency management and project build.
- **Google Apps Script**: For the Google Sheets extension.

```commandline
curl -X POST \
-H "Content-Type: application/json" \
-d '{"attribute":"rate", "startDate":"2024/03/01"}' \
http://localhost:8080/sheets/funds/HU0000731914 | jq .
```
## Repository Structure
- `sheets-extension/`: Contains Google Apps Script files for the Google Sheets extension.
- `src/main/kotlin/com/github/pozo/investmentfunds/`: Kotlin and Java source files for backend services.
- `api/`: Contains REST API endpoints that serve the processed funds data to clients.
- `service/`: Implements the business logic, including the processing of CSV files from bamosz.hu, data transformation, and management.
- `model/`: Defines the data models representing the structure of funds data.
- `repository/`: Handles data persistence, allowing for efficient storage and retrieval of fund information.
- `util/`: Includes utility classes for CSV parsing, data conversion, and other common tasks.

## Data Grabbing and Processing
The `api/grabber` package within the project plays a crucial role in ensuring the application's data is up-to-date and accurate. It is responsible for fetching, parsing, and processing investment fund data from external sources, particularly CSV files from the bamosz.hu website. This package includes several key components:

- **GrabberService**: Orchestrates the data grabbing process, including downloading, parsing, transforming, and updating the database with new data.
- **CsvDownloader**: Downloads CSV files from the bamosz.hu website.
- **CsvParser**: Parses the downloaded CSV files into a structured format.
- **DataTransformer**: Transforms parsed data into the application's domain models.
- **DataUpdater**: Updates the application's database with the new or updated data.

This structured approach ensures modularity, ease of maintenance, and clear separation of concerns, crucial for the scalability and reliability of the application.

## Terraform Configuration for AWS and GitHub Integration

This project leverages Terraform to automate the setup and management of AWS resources and integrates with GitHub for CI/CD workflows. Below is an overview of the key Terraform configuration files and their roles in the project.

### AWS ECS (`ecs.tf`)

- **AWS ECS Cluster**: Hosts the containerized services.
- **IAM Roles**: Includes `investmentfunds-role` for EC2 instances and `investmentfunds-ecs-role` for ECS tasks.
- **ECS Task Definition**: Defines the application and Redis containers, including CPU, memory, and environment variables.
- **ECS Service**: Manages the deployment of the task definition to the ECS cluster.
- **Networking**: Configures VPC, subnets, and security groups to support the ECS service.
- **Load Balancer**: Distributes incoming traffic across ECS tasks and manages HTTP to HTTPS redirection.

### AWS ECR (`ecr.tf`)

- **AWS ECR Repository**: Named `investmentfunds/api`, stores Docker images for the API, supports mutable image tags, and enables image scanning on push.

### GitHub Integration (`github.tf`)

- **GitHub Actions Secrets**: Stores AWS credentials and configurations as secrets in the GitHub repository for CI/CD workflows.
- **GitHub Actions Variables**: Defines variables like ECS cluster name, task definition family, and service name for use in GitHub Actions workflows.

### IAM Roles for GitHub Actions (`github-roles.tf`)

- **IAM Roles**: `github-build-actions-role` for building and pushing Docker images, and `github-deploy-actions-role` for deploying images to ECS.
- **Policies**: Define permissions for interacting with ECR and ECS, including pushing images and updating services.

### Terraform Configuration (`main.tf`)

- **Version and Providers**: Specifies the minimum Terraform version and configures the AWS and GitHub providers.
- **Provider Configuration**: Sets up the AWS region and GitHub token for Terraform operations.

This configuration ensures a seamless integration between AWS services for hosting the application and GitHub for continuous integration and deployment, aligning with best practices for cloud-native application development.

## GitHub Workflows

The project utilizes GitHub Actions for Continuous Integration (CI) and Continuous Deployment (CD) to automate the testing and deployment process. There are two main workflows defined in `.github/workflows/`:

### Deploy Workflow (`deploy.yaml`)

Triggered on pull requests to the `main` branch or direct pushes to `main`, this workflow automates the deployment of the investment funds API to AWS ECS. It includes steps for checking out the repository, configuring AWS credentials, building and pushing the Docker image to Amazon ECR, and updating the ECS service with the new image.

### PR Workflow (`pr.yaml`)

Triggered by pull requests to the `main` branch, this workflow focuses on building the Docker image for the API. It serves as a validation step to ensure that the Docker image can be successfully built from the PR's codebase.

These workflows ensure that new changes are automatically tested and deployed, maintaining the reliability and stability of the application.

### Google Sheets Extension
- Add the `.gs` files from `sheets-extension/` to a Google Sheets project via the Script Editor.
- Use custom functions like `FUND_RATE_LOOKUP()` directly in your sheets.

### AppScript Development Environment Setup
To develop and test the Google Sheets extension scripts (`sheets-extension/`), you'll need to set up the Google Apps Script development environment. Follow these steps to get started:

1. **Open Google Sheets**: Create a new Google Sheets document or open an existing one where you want to use the extension.

2. **Access Script Editor**: From the Google Sheets menu, navigate to `Extensions > Apps Script`. This will open the Google Apps Script editor in a new tab.

3. **Setup Project**: In the Apps Script editor, you can write your code directly or paste the `.gs` files from the `sheets-extension/` directory. The editor provides a basic IDE-like environment with syntax highlighting and code completion for Apps Script development.

4. **Enable Google Apps Script API**: Visit the [Google Cloud Platform Console](https://console.cloud.google.com/), select or create a project, and make sure the Google Apps Script API is enabled for your project. This step is crucial for programmatically managing scripts and deploying them.

5. **Test Your Script**: Use the `Run` button in the Apps Script editor to test your script. You may need to authorize the script to run under your Google account the first time.

0 comments on commit 22e51a8

Please sign in to comment.