How suyash-purwar/hackerrank-vscode works
Project's Main Components
• VS Code Extension Interface: This is the entry point (src/extension.ts) that integrates the extension into the VS Code ecosystem.
• Challenge and API Handling Modules: Include modules such as Challenge.ts, ChallengesProvider.ts, Hackerrank.ts, and Database.ts. These components interact with HackerRank’s internal endpoints—fetching challenges, processing protected routes, and managing API requests.
• Template Rendering: Represent the use of EJS templates (in src/templates) that are rendered to display challenge details, submission results, run outputs, and compilations.
• Utility Functions: Include the API poller (src/utils/apiPoller.ts) which likely manages periodic API calls for status updates.
• Local Data Management: Illustrate how user data (tokens, cookies, and solution files) are saved locally in the .hackerrankrc and the folder structure under the user’s configuration directory.
Relationships and Interactions
• First, a GET request to obtain CSRF token and cookies.
• Then, a POST request (with the CSRF token and user credentials) to log in.
• Dual-token mechanism (initially received and then updated post-login) in the flow.
• API-handling modules with the challenge rendering process:
• The ChallengesProvider fetches challenges from HackerRank.
• Challenge and Language modules transform this data into a format for VS Code.
• That the Template Renderer takes API data and uses EJS templates (for challenges, submissions, etc.) to display the content.
• File system branch where solution codes and user data (defined in the README) are stored (e.g., inside the hackerrank folder with .hackerrankrc and user directories).
Architectural Patterns and Design Principles
• Modular Design: Emphasize the separation of concerns by showing distinct modules (authentication, challenges, templating, utilities) and their interfaces (note the ‘src/modules/interface’ with type definitions).
• Template-Based Rendering: Indicate the use of EJS templates to create a clear separation between data handling and user presentation.
• Local Storage Management: Note the pattern where configuration (.hackerrankrc) and solution files are maintained within a structured file system.
Relevant Technologies, Frameworks, and Libraries
• TypeScript is the main language used (tsconfig.json present).
• VS Code Extension API – since the project is built as a VS Code extension.
• EJS templating for rendering challenge and submission views.
• Node.js and NPM (indicated by package.json and package-lock.json) for dependency management.
• ESLint and Prettier are used for code quality.
• Git for version control, as seen by .gitignore.