7.0.1 • Published 3 months ago

@studyportals/fawkes v7.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

fawkes

This project is used to centralize indexability logic for our Search microservices and Sitemap Generator. The main purpose is to completely remove discrepancies between pages indexed by Search and page URLs stored in Sitemap.

Link to documentation: https://studyportals.atlassian.net/wiki/x/BwAdvw

Base structure

  • organisations-seo (used by Organisation Search)
  • scholarships-seo (used by Scholarship Search)
  • sitemap-generator-seo (used by Sitemap Generator)
  • src
    • common
    • organisations
    • scholarships
    • sitemap-generator

Automatic Documentation System

Overview

This system automatically generates and maintains documentation for Fawkes indexing rules across multiple projects. It creates a hierarchical structure of Confluence pages that document all indexing policies and rules, ensuring that the documentation is always up-to-date with the actual codebase.

Link to documentation: Fawkes Indexing Rules Documentation

Features

  • Dynamic Documentation: Automatically extracts indexing rules and policies directly from the codebase
  • Multi-Page Structure: Creates a main index page with separate pages for each project
  • Hierarchical Organization: Structures content as Projects → Policies → Rules
  • Automatic Page Creation: Intelligently creates or updates pages as needed
  • Cross-Page Navigation: Provides intuitive navigation between all pages

Architecture

The system follows SOLID design principles to ensure maintainability and extensibility:

  • Single Responsibility: Each class has one specific responsibility
  • Open/Closed: Easily extendable without modifying existing code
  • Liskov Substitution: Interchangeable components through well-defined interfaces
  • Interface Segregation: Clean, focused interfaces
  • Dependency Inversion: High-level modules depend on abstractions

Key Components

  1. Content Builder: Extracts project, policy, and rule data from the Fawkes system
  2. Policy Fetchers: Project-specific components that fetch and format policy data
  3. Document Builder: Generates structured HTML content for Confluence pages
  4. Confluence Updater: Handles creation and updating of Confluence pages
  5. Token Retriever: Securely retrieves API token for Confluence access

How It Works

  1. The system starts by collecting all project data using the ContentBuilder
  2. For each project, it extracts policies and rules using project-specific fetchers
  3. The DocumentBuilder generates the content for the main index page and each project page
  4. The ConfluenceUpdater creates or updates pages in Confluence as needed
  5. Each project page links back to the main index, and the main index links to all project pages

Setup and Configuration

Environment Variables

The system requires the following environment variables:

CONFLUENCE_EMAIL=your-email@example.com
CONFLUENCE_API_TOKEN=your-api-token
CONFLUENCE_BASE_URL=https://your-instance.atlassian.net
CONFLUENCE_SPACE_KEY=YOUR_SPACE_KEY
CONFLUENCE_MAIN_PAGE_TITLE=Fawkes Indexing Rules Documentation

Important Note on Credentials: Currently, the system uses personal credentials (email and API token) for Confluence access. This is a temporary solution and should be replaced with a team or service account in the future to avoid dependency on a specific individual's account.

Deployment and Triggering

The system runs as an AWS Lambda function and is automatically triggered as part of the CI/CD pipeline. This ensures documentation is always updated whenever new code is deployed:

# buildspec.yml (excerpt)
post_build:
  commands:
    - |
      if [ -z "$PR_ID" ]; then
        LAMBDA_NAME="FawkesConfluenceUpdater-$STAGE"
        echo "Invoking Lambda function $LAMBDA_NAME"
        echo '{"source":"cicd-pipeline","timestamp":"'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"}' > payload.json
        aws lambda invoke --function-name $LAMBDA_NAME --invocation-type Event --payload fileb://payload.json response.json || echo "Lambda invocation failed, but continuing"
      fi

Trigger Flow:

  1. When code is pushed to the main branch, the CI/CD pipeline is triggered
  2. After successful deployment of a new Fawkes version, the post-build phase executes
  3. The Lambda function is invoked with a simple payload containing the source and timestamp
  4. The Lambda function authenticates with Confluence and executes the documentation generation process
  5. This only happens for production deployments (not PR builds)

This automated approach ensures documentation stays in sync with the actual codebase without manual intervention.

Scalability and Extension

Adding New Projects

To add documentation for a new project:

  1. Create a new class that implements the IPolicyFetcher interface
  2. Implement the getProjectName() and fetchPolicies() methods
  3. Register the new fetcher in the ContentBuilder constructor

Example:

export class NewProjectPolicyFetcher implements IPolicyFetcher {
  getProjectName(): string {
    return 'New Project Name';
  }

  fetchPolicies(): IPolicy[] {
    // Implement policy fetching logic
    return [...policies];
  }
}

// Then update ContentBuilder:
constructor(fetchers?: IPolicyFetcher[]) {
  this.policyFetchers = fetchers || [
    // Existing fetchers
    new NewProjectPolicyFetcher()
  ];
}

Customizing Page Content

The DocumentBuilder class contains methods for generating page content. To customize the format:

  1. Modify the buildMainDocument() method for changes to the main index page
  2. Modify the buildProjectDocument() method for changes to project pages
  3. Modify the buildPolicySection() and buildRulesTable() methods for changes to policy and rule sections

Conclusion

This documentation system ensures that Fawkes indexing rules are always well-documented and accessible to the team. By automatically generating documentation directly from the codebase, it eliminates the risk of documentation becoming outdated or inconsistent with the actual implementation.

7.0.1-0

3 months ago

6.0.1-8

3 months ago

6.0.1-9

3 months ago

6.0.1-6

3 months ago

6.0.1-7

3 months ago

6.0.1-5

3 months ago

6.0.1-2

3 months ago

6.0.1-3

3 months ago

4.0.3-0

4 months ago

6.0.1-0

3 months ago

6.0.1-1

3 months ago

4.0.0

4 months ago

5.0.0

3 months ago

7.0.0

3 months ago

4.0.2-1

4 months ago

4.0.2-2

4 months ago

7.0.1

3 months ago

4.0.2-0

4 months ago

6.0.1-19

3 months ago

4.0.2-5

4 months ago

4.0.2-6

4 months ago

6.0.1-17

3 months ago

4.0.2-3

4 months ago

6.0.1-18

3 months ago

4.0.2-4

4 months ago

4.0.2-9

4 months ago

4.0.2-8

4 months ago

6.0.1-11

3 months ago

6.0.1-12

3 months ago

6.0.1-10

3 months ago

6.0.1-15

3 months ago

6.0.1-16

3 months ago

6.0.1-13

3 months ago

6.0.1-14

3 months ago

6.0.1-28

3 months ago

6.0.1-29

3 months ago

6.0.1-23

3 months ago

6.0.1-20

3 months ago

6.0.1-21

3 months ago

6.0.1-26

3 months ago

6.0.1-27

3 months ago

6.0.1-24

3 months ago

6.0.1-25

3 months ago

4.0.1-2

4 months ago

4.0.1-3

4 months ago

4.0.1-0

4 months ago

4.0.1-1

4 months ago

4.0.1-6

4 months ago

4.0.1-7

4 months ago

6.0.1-39

3 months ago

4.0.1-4

4 months ago

4.0.1-5

4 months ago

6.0.1-33

3 months ago

6.0.1-34

3 months ago

6.0.1-31

3 months ago

6.0.1-32

3 months ago

6.0.1-37

3 months ago

6.0.1-38

3 months ago

6.0.1-35

3 months ago

6.0.1-36

3 months ago

6.0.1-30

3 months ago

4.0.2-18

4 months ago

5.0.1-1

3 months ago

4.0.2-17

4 months ago

4.0.2-16

4 months ago

6.0.1-44

3 months ago

4.0.2-11

4 months ago

6.0.1-45

3 months ago

4.0.2-10

4 months ago

6.0.1-42

3 months ago

6.0.1-43

3 months ago

6.0.0

3 months ago

6.0.1-48

3 months ago

4.0.2-15

4 months ago

6.0.1-49

3 months ago

6.0.1-46

3 months ago

4.0.2-13

4 months ago

6.0.1-47

3 months ago

4.0.2-12

4 months ago

6.0.1-40

3 months ago

6.0.1-41

3 months ago

4.0.2-21

4 months ago

4.0.2-20

4 months ago

6.0.1-50

3 months ago

5.0.1-3

3 months ago

3.0.1-4

4 months ago

3.0.1-3

4 months ago

2.0.1-28

4 months ago

2.0.1-29

4 months ago

2.0.1-26

4 months ago

2.0.1-27

4 months ago

2.0.1-24

4 months ago

2.0.1-25

4 months ago

2.0.1-22

4 months ago

2.0.1-23

4 months ago

2.0.1-21

4 months ago

2.0.1-39

4 months ago

2.0.1-37

4 months ago

2.0.1-38

4 months ago

2.0.1-35

4 months ago

2.0.1-36

4 months ago

2.0.1-33

4 months ago

2.0.1-31

4 months ago

2.0.1-32

4 months ago

3.0.0

4 months ago

2.0.1-30

4 months ago

2.0.1-44

4 months ago

2.0.1-42

4 months ago

2.0.1-43

4 months ago

2.0.1-40

4 months ago

2.0.1-41

4 months ago

2.0.1-20

4 months ago

2.0.0-21

5 months ago

2.0.0-20

5 months ago

2.0.1-19

4 months ago

2.0.1-17

5 months ago

2.0.1-18

5 months ago

2.0.1-15

5 months ago

2.0.1-14

5 months ago

2.0.1-13

5 months ago

2.0.1-11

5 months ago

2.0.1-10

5 months ago

2.0.1-9

5 months ago

2.0.1-8

5 months ago

2.0.1-7

5 months ago

2.0.1-6

5 months ago

2.0.1-4

5 months ago

2.0.1-2

5 months ago

2.0.0

5 months ago

1.0.1-45

5 months ago

1.0.1-44

5 months ago

1.0.1-43

5 months ago

1.0.1-42

5 months ago

1.0.1-40

5 months ago

1.0.1-38

5 months ago

1.0.1-37

5 months ago

1.0.1-36

5 months ago

1.0.1-35

5 months ago

1.0.1-34

5 months ago

1.0.1-33

5 months ago

1.0.1-32

5 months ago

1.0.1-31

5 months ago

1.0.1-30

5 months ago

1.0.1-29

5 months ago

1.0.1-28

5 months ago

1.0.1-27

5 months ago

1.0.1-26

5 months ago

1.0.1-25

5 months ago

1.0.1-24

5 months ago

1.0.1-21

5 months ago

1.0.1-20

5 months ago

1.0.1-18

5 months ago

1.0.1-17

5 months ago

1.0.1-16

5 months ago

1.0.1-14

5 months ago

1.0.1-12

5 months ago

1.0.1-11

5 months ago

1.0.1-10

5 months ago

1.0.1-9

5 months ago

1.0.1-8

5 months ago

1.0.1-7

5 months ago

1.0.1-5

5 months ago

1.0.1-3

5 months ago

1.0.1-2

5 months ago

1.0.1-1

5 months ago

1.0.1-0

5 months ago