-# GitHub Explorer
-GitHub Explorer is a modern web dashboard and Node.js API helper for exploring GitHub user profiles, repositories, activities, languages, commits, and contributions. It provides a beautiful UI and a modular API for developers.
----
+
+ One Interface. All Repositories. Infinite Possibilities.
+
+ A futuristic framework that connects GitHub, GitLab, and more — all in one place.
+ Seamlessly transform raw API calls into elegant, UI-ready visual data with TypeScript and full analytics.
+
---
-## Features
-- View GitHub user profile, avatar, bio, followers, following, and repository count
-- Explore repository details: description, language, stars, forks, license, homepage
-- List and view commits, commit stats, and file diffs
-- Browse repository files and folders, view file content with syntax highlighting
-- Visualize language usage, commit stats, and monthly contributions with interactive charts
-- Copy file contents to clipboard
-- Responsive design with Bootstrap and custom styles
-- Modular API helper for Node.js scripts and automation
+📘 Full Documentation:
+🔗 [Read the full guide here](https://luisotavio13.github.io/github-framework-documentation/)
---
-## Architecture
+## 📚 INDEX
-**Frontend:**
-- `index.html`: Main dashboard UI
-- `style.css`: Custom styles for dark mode and responsive layout
-- Uses Bootstrap, FontAwesome, Chart.js, Highlight.js
+1️⃣ [Installation](#1-installation)
+2️⃣ [Features](#2-features)
+3️⃣ [Basic Usage](#3-basic-usage)
+4️⃣ [Detailed Docs](#4-detailed-docs)
+5️⃣ [Advanced Examples](#5-advanced-examples)
+6️⃣ [Troubleshooting](#6-troubleshooting)
+7️⃣ [Contributing](#7-contributing)
+8️⃣ [Changelog](#8-changelog)
+9️⃣ [License](#9-license)
-**Backend/API Helper:**
-- `src/`: Main source code
- - `core/GitHubAPIHelper.js`: Main class, orchestrates all services
- - `services/`: Modular service classes for user, repo, activity, language, commit, and contribution data
- - `utils/`: Helper functions and formatters
+---
-**Examples & Tests:**
-- `examples/`: Example usage scripts for Node.js
-- `tests/`: Jest test files for all modules
-- `docs/`: Documentation files
+## 1️⃣ INSTALLATION
+
+```bash
+npm install @luisotavio13/github-framework@1.0.0
+```
---
-## Installation
-1. Clone the repository:
- ```sh
- git clone https://github.com/your-username/github-explorer.git
- cd github-explorer
- ```
-2. Install dependencies:
- ```sh
- npm install
- ```
+## 2️⃣ FEATURES
+
+✨ Unified APIs for GitHub, GitLab & more
+✨ Full user and repository data
+✨ Dynamic sorting for repositories
+✨ Language usage graphs
+✨ Contribution history & commit stats
+✨ Ready-to-render UI components
+✨ Strong TypeScript typing
---
-## Configuration
-Edit `config.json` with your GitHub username and (optionally) a personal access token:
+## 3️⃣ BASIC USAGE
-```json
-{
- "githubUsername": "octocat",
- "githubToken": "your_github_token"
-}
+```javascript
+import GitHubAPIHelper from '@luisotavio13/github-framework';
+
+const config = {
+ username: 'your-username',
+ token: 'your-token' // optional
+};
+
+const apiHelper = new GitHubAPIHelper(config);
+
+await apiHelper.loadAllData();
+
+console.log(apiHelper.userData);
+console.log(apiHelper.reposData);
+console.log(apiHelper.languagesData);
+
+const profile = apiHelper.renderProfile();
+const repos = apiHelper.renderRepos('stars');
+const charts = apiHelper.renderCharts();
```
-Tokens are optional for public data but recommended for higher rate limits and private repositories.
+---
+
+## 4️⃣ DETAILED DOCS
+
+Documentation lives in the [`/docs`](./docs) folder:
+
+- 📘 [API Reference](./docs/API.md)
+- 📘 [GitLab Integration](./docs/gitlab.md)
+- 📘 [TypeScript Models](./docs/ts-github-models.md)
+- 📘 [Advanced Usage Guide](./docs/USAGE.md)
+- 📘 [Troubleshooting](./docs/TROUBLESHOOTING.md)
+- 📘 [Contributing](./docs/CONTRIBUTING.md)
+- 📘 [Changelog](./docs/CHANGELOG.md)
+- 📘 [Legal & Compliance](./docs/LEGAL.md)
---
-## Usage
-
-### Web Dashboard
-1. Open `index.html` in your browser
-2. Explore your profile, repositories, activities, languages, commits, and contributions visually
-
-### Node.js Example
-See `examples/basic-usage.js`:
-```js
-import GitHubAPIHelper from '../src/index.js';
-const config = { githubUsername: 'octocat', githubToken: '' };
-const github = new GitHubAPIHelper(config);
-await github.loadAllData();
-console.log(github.renderProfile());
-console.log(github.renderRepos('stars'));
-console.log(github.renderActivities());
+## 5️⃣ ADVANCED EXAMPLES
+
+📈 **Contribution Monitoring:**
+
+```javascript
+const monthlyContributions = apiHelper.contributionsData;
```
-### API Reference
-See [`docs/API.md`](API.md) for full details on all classes and methods.
+🧪 **Top Used Languages:**
+
+```javascript
+const topLanguages = Object.entries(apiHelper.languagesData)
+ .sort((a, b) => b[1] - a[1])
+ .slice(0, 3);
+```
---
-## Testing
+## 6️⃣ TROUBLESHOOTING
-Run all tests with Jest:
-```sh
-npx jest
-```
-Test files are located in the `tests/` folder and cover all main modules and services.
+See [TROUBLESHOOTING.md](./docs/TROUBLESHOOTING.md) for help with:
+
+- 🔐 Authentication errors
+- 🚫 API rate limit exceeded
+- 🔒 Private repositories
+- 🌐 Proxy configuration
---
-## Contributing
+## 7️⃣ CONTRIBUTING
-Contributions are welcome! To contribute:
-1. Fork the repository
-2. Create a new branch
-3. Make your changes
-4. Submit a pull request
+We welcome contributions! Please read [CONTRIBUTING.md](./docs/CONTRIBUTING.md) for:
-Please write clear commit messages and add tests for new features.
+- Git workflow
+- Code standards
+- Test automation
+- Documentation guidelines
---
-## FAQ
+## 8️⃣ CHANGELOG
-**Q: Do I need a GitHub token?**
-A: No, but it is recommended for higher rate limits and private data.
+Track version history in:
+📜 [CHANGELOG.md](./docs/CHANGELOG.md)
-**Q: Can I use this as a library in my own Node.js scripts?**
-A: Yes! Import `GitHubAPIHelper` from `src/index.js` and use its methods.
+---
-**Q: How do I customize the dashboard UI?**
-A: Edit `style.css` and `index.html` as needed. The code is modular and easy to extend.
+## 9️⃣ LICENSE
-**Q: What browsers are supported?**
-A: All modern browsers (Chrome, Firefox, Edge, Safari).
+Licensed under the **GNU GPL v3.0**.
+Read the [LICENSE](./LICENSE) file.
+For API legal info, see: [LEGAL.md](./docs/LEGAL.md)
---
-## License
+## 📬 SUPPORT
+
+For issues, suggestions or bug reports:
+📮 Open an issue or contact: ✉️ roberdoogarcia@gmail.com
+
-GPL
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index 89ec0e2..3d7ab91 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -1,29 +1,120 @@
-# Contributing Guide
+# 🤝 Contributing Guide
-Thank you for considering contributing to GitHub Explorer!
+Thank you for your interest in contributing to the **GitHub Framework**!
+We welcome pull requests, suggestions, and improvements of all kinds.
-## How to Contribute
-1. Fork the repository
-2. Create a new branch for your feature or fix
-3. Make your changes with clear commit messages
-4. Add or update tests as needed
-5. Submit a pull request with a detailed description
+---
-## Code Style
-- Use ES6+ JavaScript syntax
-- Follow existing code formatting and naming conventions
-- Write JSDoc comments for all public functions and classes
+## 🧭 Table of Contents
-## Testing
-- Add or update Jest tests in the `tests/` folder
-- Run `npx jest` before submitting your PR
+- [How to Contribute](#how-to-contribute)
+- [Development Workflow](#development-workflow)
+- [Code Style Guide](#code-style-guide)
+- [Testing & Coverage](#testing--coverage)
+- [Documentation Updates](#documentation-updates)
+- [Security Policy](#security-policy)
+- [Code of Conduct](#code-of-conduct)
-## Issues
-- If you find a bug or have a feature request, open an issue with details and steps to reproduce
+---
-## Community
-- Be respectful and constructive in discussions
-- Help review and test other contributions
+## ✅ How to Contribute
-## License
-GPL
+1. **Fork** the repository.
+2. Create a **new branch**:
+ ```bash
+ git checkout -b feature/my-feature
+ ```
+3. **Make your changes** and write tests if needed.
+4. Run tests locally to verify.
+5. **Commit** using clear, conventional messages:
+ ```
+ feat: add support for GitHub reactions
+ fix: handle 404 errors on repo fetch
+ ```
+6. Push to your fork and **create a pull request**.
+
+---
+
+## 🧪 Development Workflow
+
+```bash
+# Install dependencies
+npm install
+
+# Run in development mode
+npm run dev
+
+# Build for production
+npm run build
+
+# Run tests
+npm run test
+```
+
+Please ensure that your PR passes **all tests and lint checks**.
+
+---
+
+## 🎨 Code Style Guide
+
+- Language: **TypeScript**
+- Format: Prettier + ESLint
+- Naming: camelCase for variables, PascalCase for classes
+- Folder structure follows `src/`, `adapters/`, and `types/`
+- Comments are encouraged for complex logic
+
+Use:
+```bash
+npm run lint
+npm run format
+```
+
+---
+
+## 🧪 Testing & Coverage
+
+We use **Jest** for testing.
+
+- Place unit tests in `__tests__/`
+- Test coverage goal: **80%+**
+- Test new features and edge cases
+
+Run:
+```bash
+npm run test
+```
+
+---
+
+## 📘 Documentation Updates
+
+If your contribution affects how the framework is used, update the relevant docs in:
+
+- [`README.md`](../README.md)
+- [`/docs/USAGE.md`](./USAGE.md)
+- [`/docs/API.md`](./API.md)
+
+Use clear, concise language and include code examples where useful.
+
+---
+
+## 🔐 Security Policy
+
+If you discover a security vulnerability, **do not** open a public issue.
+Instead, contact us directly:
+✉️ `roberdoogarcia@gmail.com`
+
+---
+
+## 🌐 Code of Conduct
+
+We follow the [Contributor Covenant](https://www.contributor-covenant.org/) Code of Conduct.
+
+- Be respectful and inclusive
+- Assume good intent
+- No harassment or abuse of any kind
+
+---
+
+Thank you for making this project better!
+Every contribution, large or small, helps move it forward 🚀
diff --git a/docs/LEGAL.md b/docs/LEGAL.md
new file mode 100644
index 0000000..f410c98
--- /dev/null
+++ b/docs/LEGAL.md
@@ -0,0 +1,68 @@
+# 🛡️ Legal & API Compliance
+
+This document outlines the legal considerations and API compliance requirements related to the use of the GitHub Framework.
+
+---
+
+## 📑 License
+
+This project is licensed under the **GNU General Public License v3.0 (GPL-3.0)**.
+You are free to use, modify, and distribute the framework under the terms of this license.
+
+- Full license text: [LICENSE](../LICENSE)
+- SPDX Identifier: `GPL-3.0-only`
+
+---
+
+## 🔐 API Token Handling
+
+- Always store personal access tokens (PATs) in secure environments (e.g., `.env` files, vaults).
+- Do **not** commit secrets to your version control system.
+- The framework does **not** log or store tokens persistently.
+- Using tokens improves rate limits and access to private data.
+
+---
+
+## 🤝 API Terms of Use
+
+By using this framework, you agree to comply with the terms and usage policies of the respective APIs you integrate:
+
+### GitHub
+- API Terms: [https://docs.github.com/en/site-policy/github-terms/github-terms-of-service](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service)
+- Rate limits: 5,000 req/hour with token; 60 req/hour without
+
+### GitLab
+- API Terms: [https://about.gitlab.com/terms/](https://about.gitlab.com/terms/)
+- Rate limits may vary by instance (GitLab.com or self-hosted)
+
+You are responsible for staying within usage boundaries and respecting rate limits.
+
+---
+
+## 📡 Data Collection and Privacy
+
+- The framework does **not** transmit data to third-party servers.
+- All API data is retrieved client-side or server-side based on your environment.
+- The developer assumes responsibility for handling user data ethically and legally.
+
+If you build dashboards or store data persistently, ensure you comply with:
+
+- Local data protection laws (e.g., LGPD, GDPR)
+- GitHub/GitLab data usage restrictions
+- User consent if applicable
+
+---
+
+## 🧪 External Dependencies
+
+This project may use open-source libraries under permissive licenses (MIT, Apache 2.0).
+Ensure that usage and distribution comply with those licenses. All dependencies are listed in `package.json`.
+
+---
+
+## ❗ Disclaimer
+
+This framework is provided **as-is** without warranty.
+You are solely responsible for ensuring that your use of it is compliant with all relevant laws and API provider rules.
+
+For legal concerns, contact the project maintainer or consult a legal advisor.
diff --git a/docs/USAGE.md b/docs/USAGE.md
index 73f49f1..10169c7 100644
--- a/docs/USAGE.md
+++ b/docs/USAGE.md
@@ -1,32 +1,142 @@
-# Usage Guide
+# ⚙️ Advanced Usage Guide
-## Web Dashboard
-- Open `index.html` in your browser
-- Configure your GitHub username and token in `config.json`
-- Explore profile, repositories, activities, languages, commits, and contributions visually
+This guide provides practical examples and advanced techniques for using the `GitHubAPIHelper` class effectively in real-world applications.
+
+---
+
+## 📥 Initialization
+
+```ts
+import GitHubAPIHelper from '@luisotavio13/github-framework';
+
+const apiHelper = new GitHubAPIHelper({
+ username: 'your-username',
+ token: 'your-token' // optional
+});
+
+await apiHelper.loadAllData();
+```
+
+The `loadAllData()` method fetches:
+
+- `userData` — profile and statistics
+- `reposData` — all public (and private, if token is provided) repositories
+- `languagesData` — aggregated language usage
+
+---
+
+## 📌 Filtering Repositories
+
+You can filter and sort repositories by language, stars, forks, etc.
+
+```ts
+const jsRepos = apiHelper.reposData.filter(
+ repo => repo.language === 'JavaScript'
+);
+
+const topStarred = [...apiHelper.reposData].sort(
+ (a, b) => b.stars - a.stars
+).slice(0, 5);
+```
+
+---
+
+## 📈 Language Statistics
+
+```ts
+const topLanguages = Object.entries(apiHelper.languagesData)
+ .sort((a, b) => b[1] - a[1])
+ .slice(0, 3)
+ .map(([lang, count]) => `${lang}: ${count}`);
+```
+
+This is useful for UI dashboards, charts, and custom reports.
+
+---
+
+## 📊 Rendering UI Components
+
+The framework includes built-in methods for rendering components as HTML or strings:
+
+```ts
+const profileHTML = apiHelper.renderProfile();
+const reposHTML = apiHelper.renderRepos('stars'); // 'forks', 'name', etc.
+const chartsHTML = apiHelper.renderCharts();
+```
+
+These methods return raw HTML. You can inject them directly into your app or static site:
-## Node.js Example
-See `examples/basic-usage.js`:
```js
-import GitHubAPIHelper from '../src/index.js';
-const config = { githubUsername: 'TylorSwift2', githubToken: '' };
-const github = new GitHubAPIHelper(config);
-await github.loadAllData();
-console.log(github.renderProfile());
-console.log(github.renderRepos('stars'));
-console.log(github.renderActivities());
+document.getElementById('profile').innerHTML = profileHTML;
+```
+
+---
+
+## 📅 Contribution History
+
+```ts
+const contributions = apiHelper.contributionsData;
+
+Object.entries(contributions).forEach(([month, count]) => {
+ console.log(`${month}: ${count} commits`);
+});
+```
+
+The object returned is keyed by `YYYY-MM` with number of commits.
+
+---
+
+## 🧩 Using With Frameworks
+
+### React Example:
+
+```tsx
+import { useEffect, useState } from 'react';
+import GitHubAPIHelper from '@luisotavio13/github-framework';
+
+export function ProfileWidget() {
+ const [html, setHtml] = useState('');
+
+ useEffect(() => {
+ const api = new GitHubAPIHelper({ username: 'devuser' });
+ api.loadAllData().then(() => {
+ setHtml(api.renderProfile());
+ });
+ }, []);
+
+ return ;
+}
+```
+
+---
+
+## ⚠️ Error Handling
+
+Wrap async usage in `try/catch` to handle:
+
+```ts
+try {
+ await apiHelper.loadAllData();
+} catch (err) {
+ console.error('Failed to load data:', err);
+}
```
-## Testing
-- Run `npm install` to install Jest
-- Run `npx jest` to execute all tests in the `tests/` folder
+---
+
+## 🧪 Extending Integrations
+
+You can extend the framework to support more platforms (e.g., Bitbucket):
+
+- Create a new adapter in `src/adapters/bitbucketAdapter.ts`
+- Implement the same methods used in `githubAdapter` and `gitlabAdapter`
+- Register the adapter via factory pattern
+
+---
-## Customization
-- Edit `style.css` for custom styles
-- Extend service classes in `src/services/` for new features
+## 💬 Have Questions?
-## Troubleshooting
-- Ensure your GitHub token is valid for private data or higher rate limits
-- Check browser console or Node.js logs for error messages
+Open an issue or [contact support](mailto:luisotavio@example.com).
+Check `/docs/TROUBLESHOOTING.md` if something isn’t working as expected.
-GPL
+---
diff --git a/docs/gitlab.md b/docs/gitlab.md
new file mode 100644
index 0000000..2babfd1
--- /dev/null
+++ b/docs/gitlab.md
@@ -0,0 +1,141 @@
+# 📚 GitLab Integration: Developer Documentation
+
+## ⚙️ Overview
+This GitLab integration suite allows you to fetch and display detailed user and repository data using GitLab’s REST API. It’s organized into modular service classes that separate responsibilities for maintainability and clarity.
+
+---
+
+## 🧩 Components
+
+### 1. `GitLabUserService`
+**Purpose**: Retrieve GitLab user profile and contribution statistics.
+
+**Key Methods**:
+- `loadUserData()` — Fetches user data and contribution stats.
+- `renderProfile()` — Formats user profile info for display.
+
+**Returns**:
+```json
+{
+ avatarUrl: "",
+ name: "",
+ bio: "",
+ followers: 0,
+ following: 0,
+ publicRepos: 0,
+ stats: {}
+}
+```
+
+---
+
+### 2. `GitLabRepoService`
+**Purpose**: Manage and explore GitLab repositories.
+
+**Key Methods**:
+- `loadReposData(sort, per_page)` — Retrieves repositories.
+- `loadRepoFiles(repoId, path, ref)` — Lists files in a repo.
+- `loadFileContent(repoId, filePath, ref)` — Gets raw file content.
+- `renderRepos(sort)` — Formats repos for display.
+
+**Sort Options**: `stars`, `forks`, `updated`
+
+**Returns**:
+```json
+{
+ id, name, description, language,
+ stars, forks, updatedAt, url
+}
+```
+
+---
+
+### 3. `GitLabActivityService`
+**Purpose**: Track user activity (pushes, merges, creations).
+
+**Key Methods**:
+- `loadActivities(per_page)` — Gets recent activity.
+- `renderActivities()` — Formats it for UI.
+
+**Returns**:
+```json
+{
+ text, icon, date
+}
+```
+
+---
+
+### 4. `GitLabCommitService`
+**Purpose**: Access commit history and details.
+
+**Key Methods**:
+- `loadCommitsData(reposData, per_page)` — Commit count per repo.
+- `loadRepoCommits(repoId, page, per_page)` — Paginated commits.
+- `loadCommitDetails(repoId, sha)` — Extended info.
+
+**Returns**:
+```json
+{
+ sha, message, author, date, url,
+ stats: { additions, deletions, total },
+ files: []
+}
+```
+
+---
+
+### 5. `GitLabContributionService`
+**Purpose**: Summarize push contributions by month.
+
+**Key Methods**:
+- `loadContributionsData(year)` — Count pushes monthly.
+
+**Returns**:
+```json
+{
+ Jan: 0, Feb: 0, ..., Dec: 0
+}
+```
+
+---
+
+### 6. `GitLabLanguageService`
+**Purpose**: Analyze language usage by repo size.
+
+**Key Methods**:
+- `loadLanguagesData(reposData)` — Aggregates usage data.
+
+**Returns**:
+```json
+{
+ JavaScript: 123456,
+ Python: 78901,
+ ...
+}
+```
+
+---
+
+## 🛠 Required Utilities
+
+From `../../utils/helpers.js`:
+- `getAuthHeaders(token)` — Returns headers.
+- `formatFileSize(bytes)` — Human-readable size.
+
+---
+
+## 🚀 Getting Started
+
+```js
+const config = {
+ username: 'yourUsername',
+ token: 'yourAccessToken',
+ baseUrl: 'https://gitlab.com/api/v4'
+};
+
+const userService = new GitLabUserService(config);
+await userService.loadUserData();
+console.log(userService.renderProfile());
+```
+s
\ No newline at end of file
diff --git a/examples/example_04/index.js b/examples/example_04/index.js
new file mode 100644
index 0000000..5580c3c
--- /dev/null
+++ b/examples/example_04/index.js
@@ -0,0 +1,60 @@
+import {
+ GitLabUserService,
+ GitLabRepoService,
+ GitLabLanguageService,
+ GitLabContributionService,
+ GitLabActivityService,
+ GitLabCommitService
+} from '../../src/index.js';
+
+// Configuration for the GitLab API
+const config = {
+ username: 'your_gitlab_username',
+ token: '', // Can be left empty if public access is sufficient
+ baseUrl: 'https://gitlab.com/api/v4'
+};
+
+async function buildGitLabDashboard() {
+ try {
+ // 1. Fetch basic user profile info (e.g., name, avatar, bio)
+ const userService = new GitLabUserService(config);
+ await userService.loadUserData();
+ const profile = userService.renderProfile();
+ console.log('User Profile:', profile);
+
+ // 2. Fetch user repositories and sort by a specific criteria
+ const repoService = new GitLabRepoService(config);
+ await repoService.loadReposData('updated'); // Sort options: 'updated', 'stars', 'forks'
+ const repositories = repoService.renderRepos();
+ console.log('Repositories:', repositories);
+
+ // 3. Analyze programming languages used in those repositories
+ const languageService = new GitLabLanguageService(config);
+ await languageService.loadLanguagesData(repoService.reposData);
+ const languages = languageService.languagesData;
+ console.log('Languages Used:', languages);
+
+ // 4. Retrieve recent activities like issues, merge requests, etc.
+ const activityService = new GitLabActivityService(config);
+ await activityService.loadActivities();
+ const activities = activityService.renderActivities();
+ console.log('Recent Activities:', activities);
+
+ // 5. Fetch commit statistics for each repository
+ const commitService = new GitLabCommitService(config);
+ await commitService.loadCommitsData(repoService.reposData);
+ const commitsByRepo = commitService.commitsData;
+ console.log('Commits by Repository:', commitsByRepo);
+
+ // 6. Retrieve user contributions grouped by month for the current year
+ const contributionService = new GitLabContributionService(config);
+ await contributionService.loadContributionsData(); // Defaults to the current year
+ const monthlyContributions = contributionService.contributionsData;
+ console.log('Monthly Contributions:', monthlyContributions);
+
+ } catch (error) {
+ console.error('Error building GitLab dashboard:', error);
+ }
+}
+
+buildGitLabDashboard();
diff --git a/package-lock.json b/package-lock.json
index 65732e0..5b63eef 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.1",
"license": "GPL-3.0-only",
"dependencies": {
- "axios": "^1.6.7"
+ "axios": "^1.11.0"
},
"devDependencies": {
"@babel/core": "^7.28.0",
@@ -3100,13 +3100,13 @@
"license": "MIT"
},
"node_modules/axios": {
- "version": "1.10.0",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz",
- "integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
+ "version": "1.11.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.11.0.tgz",
+ "integrity": "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
- "form-data": "^4.0.0",
+ "form-data": "^4.0.4",
"proxy-from-env": "^1.1.0"
}
},
diff --git a/package.json b/package.json
index b52673b..c0b603d 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
"access": "public"
},
"dependencies": {
- "axios": "^1.6.7"
+ "axios": "^1.11.0"
},
"devDependencies": {
"@babel/core": "^7.28.0",
diff --git a/src/core/BaseAPIHelper.js b/src/core/BaseAPIHelper.js
new file mode 100644
index 0000000..1576131
--- /dev/null
+++ b/src/core/BaseAPIHelper.js
@@ -0,0 +1,65 @@
+/**
+ * Classe base para API Helpers
+ */
+export class BaseAPIHelper {
+ constructor(config) {
+ if (!config || !config.username) {
+ throw new Error('Nome de usuário é obrigatório');
+ }
+
+ this.config = {
+ username: config.username,
+ token: config.token || null,
+ baseUrl: config.baseUrl || null
+ };
+
+ // Serviços que serão implementados
+ this.userService = null;
+ this.repoService = null;
+ this.activityService = null;
+ this.languageService = null;
+ this.commitService = null;
+ this.contributionService = null;
+
+ // Estado atual
+ this.currentRepo = null;
+ this.currentPath = '';
+ this.currentCommit = null;
+ }
+
+ async loadAllData() {
+ throw new Error('Método loadAllData() deve ser implementado');
+ }
+
+ // Getters
+ get userData() { return this.userService?.userData; }
+ get reposData() { return this.repoService?.reposData; }
+ get activitiesData() { return this.activityService?.activitiesData; }
+ get languagesData() { return this.languageService?.languagesData; }
+ get commitsData() { return this.commitService?.commitsData; }
+ get contributionsData() { return this.contributionService?.contributionsData; }
+
+ // Métodos de renderização
+ renderProfile() { return this.userService?.renderProfile(); }
+ renderActivities() { return this.activityService?.renderActivities(); }
+ renderRepos(sort) { return this.repoService?.renderRepos(sort); }
+
+ renderCharts() {
+ return {
+ languages: {
+ labels: Object.keys(this.languagesData || {}),
+ data: Object.values(this.languagesData || {})
+ },
+ commits: {
+ labels: Object.keys(this.commitsData || {}).slice(0, 10),
+ data: Object.values(this.commitsData || {}).slice(0, 10)
+ },
+ contributions: {
+ labels: Object.keys(this.contributionsData || {}),
+ data: Object.values(this.contributionsData || {})
+ }
+ };
+ }
+}
+
+export default BaseAPIHelper;
\ No newline at end of file
diff --git a/src/core/GitHubAPIHelper.js b/src/core/GitHubAPIHelper.js
index 4c2a133..8ecd6f4 100644
--- a/src/core/GitHubAPIHelper.js
+++ b/src/core/GitHubAPIHelper.js
@@ -1,70 +1,32 @@
-/**
- * @license
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-import UserService from '../services/UserService.js';
-import RepoService from '../services/RepoService.js';
-import ActivityService from '../services/ActivityService.js';
-import LanguageService from '../services/LanguageService.js';
-import CommitService from '../services/CommitService.js';
-import ContributionService from '../services/ContributionService.js';
-/**
- * GitHubAPIHelper - Main facade class for GitHub API operations
- *
- * Provides a unified interface to access GitHub user data, repositories,
- * activities, languages, commits and contributions through specialized services.
- * Implements the Facade design pattern to simplify complex API interactions.
- */
-class GitHubAPIHelper {
- /**
- * Constructs a new GitHubAPIHelper instance
- * @param {Object} config Configuration object
- * @param {string} config.githubUsername GitHub username (required)
- * @param {string} [config.githubToken] GitHub personal access token (optional)
- * @throws {Error} When githubUsername is not provided
- */
+import BaseAPIHelper from './BaseAPIHelper.js';
+import GitHubUserService from '../services/github/UserService.js';
+import GitHubRepoService from '../services/github/RepoService.js';
+import GitHubActivityService from '../services/github/ActivityService.js';
+import GitHubLanguageService from '../services/github/LanguageService.js';
+import GitHubCommitService from '../services/github/CommitService.js';
+import GitHubContributionService from '../services/github/ContributionService.js';
+
+class GitHubAPIHelper extends BaseAPIHelper {
constructor(config) {
- if (!config || !config.githubUsername) {
- throw new Error('GitHub username is required');
- }
-
- this.config = {
- githubUsername: config.githubUsername,
- githubToken: config.githubToken || null
+ super({
+ username: config.username,
+ token: config.token
+ });
+
+ // Mapeia para os campos esperados pelos serviços internos
+ const serviceConfig = {
+ githubUsername: config.username,
+ githubToken: config.token
};
- // Initialize specialized services
- this.userService = new UserService(this.config);
- this.repoService = new RepoService(this.config);
- this.activityService = new ActivityService(this.config);
- this.languageService = new LanguageService(this.config);
- this.commitService = new CommitService(this.config);
- this.contributionService = new ContributionService(this.config);
-
- // Current state tracking
- this.currentRepo = null;
- this.currentPath = '';
- this.currentCommit = null;
+ this.userService = new GitHubUserService(serviceConfig);
+ this.repoService = new GitHubRepoService(serviceConfig);
+ this.activityService = new GitHubActivityService(serviceConfig);
+ this.languageService = new GitHubLanguageService(serviceConfig);
+ this.commitService = new GitHubCommitService(serviceConfig);
+ this.contributionService = new GitHubContributionService(serviceConfig);
}
- /**
- * Loads all available GitHub data for the user
- * @async
- * @returns {Promise} True if all data loaded successfully
- * @throws {Error} If any data loading fails
- */
async loadAllData() {
try {
await this.userService.loadUserData();
@@ -75,140 +37,10 @@ class GitHubAPIHelper {
await this.contributionService.loadContributionsData();
return true;
} catch (err) {
- console.error('Error loading data:', err);
+ console.error('Erro ao carregar dados do GitHub:', err);
throw err;
}
}
-
- /* Data Accessors */
-
- /**
- * Gets user profile data
- * @returns {Object} User profile information
- */
- get userData() { return this.userService.userData; }
-
- /**
- * Gets repositories data
- * @returns {Array