Skip to content

Commit

Permalink
Merge branch 'main' into ft/versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Delyc authored Aug 23, 2024
2 parents a10ac46 + 219e563 commit 908c691
Show file tree
Hide file tree
Showing 1,202 changed files with 64,522 additions and 68,248 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ f424854667e15daf0ad59d5fc68cc3eba6ea152e
3929b03030d64a2fe9ce9ac25b52fec2da6d1391
# Apply `Symfony` Code Style to entire PHP code base
f5a93ae18ec8e036cb47bb05b71f40d49049a505
# Apply Prettier after updated config
bc92390b1fb7a7b16e88d7afd88ba5372afe4e51
43 changes: 43 additions & 0 deletions .github/workflows/check-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check Docs

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
prettier:
name: Lint prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/iron

- name: Run Prettier on Docs
working-directory: docs
run: npx prettier . --check

check-build:
name: Check Docs build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/iron

- name: Install tooling
working-directory: docs
run: npm install

- name: Build docs with VitePress
working-directory: docs
run: npm run docs:build
28 changes: 17 additions & 11 deletions .github/workflows/deploy-gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy GitHub Pages with Sphinx-docs
# Sample workflow for building and deploying a documentation site to GitHub Pages
name: Deploy GitHub Pages

on:
# Runs on pushes targeting the default branch
Expand All @@ -26,21 +26,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v2
- name: Install Sphinx and plugins
run: |
pipx install sphinx
pipx inject sphinx recommonmark
pipx inject sphinx sphinx_rtd_theme
- name: Build docs with Sphinx-docs

- uses: actions/setup-node@v4
with:
node-version: lts/iron

- name: Install tooling
working-directory: docs
run: make html
run: npm install

- name: Build docs with VitePress
working-directory: docs
run: npm run docs:build

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: docs/build/html/
path: docs/.vitepress/dist/

# Deployment job
deploy:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/php_linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ jobs:
working-directory: ./Website/htdocs/mpmanager

- name: Run PHPStan
run: ./vendor/bin/phpstan analyze --error-format=table app/Http app/Services app/Models/ app/Events app/Listeners app/Misc app/modules --memory-limit=2G --level=1
run: composer run phpstan-analyze
working-directory: ./Website/htdocs/mpmanager
continue-on-error: true

- name: Run Psalm
run: composer run psalm-check
Expand Down
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
micropowermanager.io
252 changes: 13 additions & 239 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@

# MicroPowerManager

---
MicroPowerManager (MPM) is a decentralized utility and customer management tool.
Manage customers, revenues and assets with this all-in one Open Source platform.

## Documentation

MPM's documentation is hosted on [micropowermanager.io](https://micropowermanager.io/).

## This project

Expand All @@ -41,245 +46,14 @@
- It uses Node 16.10
- It uses MariaDB 10.3 which is compatible with MySQL 5.7

## Setup

---

### Docker installation

**Windows and Mac:**

- [Docker Desktop](https://www.docker.com/products/docker-desktop).

**Linux:**

- Docker provides installation instructions for various Linux distributions. You can find them on
the [Docker installation page for Linux.](https://docs.docker.com/engine/install/).

### Docker Compose

Docker Compose is often included with the Docker Desktop installations for Windows and Mac. For Linux, you might need to
install it separately.

**Windows and Mac:**

- Included with Docker Desktop.

**Linux:**

- Docker Compose on GitHub <https://github.com/docker/compose/releases>
- On the GitHub page, you can find instructions for downloading and installing Docker Compose on Linux. Be sure to check
for the latest release.

### Repository setup

1. Clone or download the repository
2. Build the docker containers with `docker-compose up`

## Development

---

The development environment is served under <http://localhost:8000>

## Frontend

The frontend is served under <http://localhost:8001>. You can find frontend files under `Website/ui`.
The frontend is built with Vue.js. After first run with `docker-compose up` dependencies will be installed
automatically.
If you want to install dependencies manually, you can run `npm install` under `Website/ui` folder.

### Folder Structure

When adding new files to the project, please adhere to the following folder structure:

- **Creating New Modules:**
Modules are the components used in pages. For example, the Client module holds components related to clients. Every
component associated with clients should be placed under the Client module.

```sh
Website/ui
├── src
│ ├── modules
│ │ ├── newModule
```

- **Creating New Pages:**
Pages are the components used in routes. We follow the nuxt.js folder structure for pages. The `index.vue` file under
a page folder represents the listing page of the page, while the `_id.vue` file represents the detail page. Since we
are not using nuxt.js, routes need to be defined manually. You can find the routes in
the `Website/ui/src/ExportedRoutes.js` file.

```sh
Website/ui
├── src
│ ├── pages
│ │ ├── newPage
| | | ├── index.vue
| | | ├── _id.vue
```

#### Plugins

Plugins are additional components developed as separate packages to enhance our product. This separation helps keep the
main codebase clean. Each plugin should reside in its own folder under the `Website/ui/src/plugins` directory.
Additionally, each plugin should have its own backend code, which will be explained in the backend section.

```sh
Website/ui
├── src
│ ├── plugins
│ │ ├── newPlugin
```

In the backend section, you'll find instructions on how to create a plugin.

## Backend

The backend is built with Laravel. The backend is served under <http://localhost:8000/api>. You can find backend
files under `Website/htdocs/mpmanager`. After the first run with `docker-compose up`, dependencies will be installed
automatically. If you prefer to install dependencies manually or need to add additional packages, follow these steps:

1. Enter the Docker container named "laravel" by navigating to the "mpmanager" directory:

```bash
docker exec -it laravel bash
cd mpmanager
```

2. Run the following command to install dependencies, replacing {package-name} with the actual name of the package:

```bash
./composer.phar install {package-name}
```

These steps ensure that you can manage dependencies either automatically during the initial docker-compose up or
manually when needed.
Make sure to replace `{package-name}` with the actual name of the package you want to install.

We followed the laravel folder structure for the backend. If you want to learn more about the folder structure, you can
check the [Laravel documentation](https://laravel.com/docs/9.x/structure).

### Sharding in Micropower Manager

Sharding is a technique employed to partition a large database into smaller, more agile, and easily manageable segments
known as data shards. In the context of Micropower Manager, sharding is integral to the implementation of Software as a
Service (SaaS) functionality.

#### Shard Representation

Each shard in Micropower Manager represents an individual company leveraging the platform for their Customer
Relationship Management (CRM) needs.

#### Central Database - "micro_power_manager"

To facilitate this, a central database named "micro_power_manager" is established. This central database houses
company-specific information and common data such as installable plugins.

#### New Company Registration Process

When a new company registers an account, a dedicated database is dynamically created for that specific company. This new
database incorporates Micropower Manager's core migration files located at `Website/htdocs/mpmanager/database/migrations/micropowermanager`

#### User Session Interaction

Upon successful registration, when a user associated with a particular company logs into Micropower Manager, the
database connection for their session is dynamically altered. This ensures that the user gains access to and interacts
with data exclusive to their company, providing a personalized and secure experience within the application.

### Migration on First run

When you run the application for the first time, you need to run the following command to migrate the database:

```bash
docker exec -it laravel bash
cd mpmanager
php artisan sharding:initialize
```

This command will create the central database which is required for MPM to function.

If you want to load sample (dummy) data for testing run:

```bash
docker exec -it laravel bash
cd mpmanager
php artisan dummy:create-company-with-dummy-data
php artisan migrator:copy
php artisan migrator:migrate
```

This commands will create the first company database with dummy data from a snapshot.
It will then apply any migrations that have been added to the application after the snapshot has been taken.

You can use the following credentials to login to the application:

```sh
username: [email protected]
password: 123123
```

The dummy protected page password of this company is 123123.

### Sharding Specific Migration Commands

- **Creating Migration File:**
When creating a migration file, you need to use the following command:

```bash
docker exec -it laravel bash
cd mpmanager
php artisan migrator:create {migration-name}
```

This command creates a migration file in Micropower Manager's core migration files location: `Website/htdocs/mpmanager/database/migrations/micropowermanager`

After creating the migration file, you can shift it to other company databases using the following command:

```bash
docker exec -it laravel bash
cd mpmanager
php artisan migrator:copy
```

This command syncs the migration files in the core migration folder for other company migrations.

To migrate the database, use the following command:

```bash
docker exec -it laravel bash
cd mpmanager
php artisan migrator:migrate
```

Alternatively, you can migrate the database for a specific company using the following command:

```bash
docker exec -it laravel bash
cd mpmanager
php shard:migrate {company_id} {--force}
```

### Install Plugins

We have a custom plugin creator command that generates a template. Use the following command to create a new plugin:

```bash
docker exec -it laravel bash
cd mpmanager
php artisan micropowermanager:new-package {package-name}
```

This command creates a plugin template in the Website/htdocs/mpmanager/packages/inensus folder. Upon creation, you can proceed with plugin development. You can check other plugins for reference.
Additionally, this command will create UI folders for the newly created plugin. Move the created UI folder to the Website/ui/src/plugins folder.
## Getting Started

### phpMyAdmin
Explore MPM's capabilities by

To project also includes phpMyAdmin which enables quick database operations without installing third-party software or writing any single line into the terminal.
- logging into the [Demo Version](https://demo.micropowermanager.io/)
- setting up a local installation following this [guide](https://micropowermanager.io/development/development-environment.html)

The default credentials for the database are:
## Support

```sh
username: root
password: wF9zLp2qRxaS2e
```
- [OSEA Discord](https://discord.osea-community.org/) (`#micropowermanager` channel)
- [EnAccess](https://enaccess.org/)
5 changes: 0 additions & 5 deletions Website/htdocs/mpmanager/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@ Homestead.json
Homestead.yaml
/start.sh
./creator.log

# ignore all company specific migrations
/database/migrations/**
!/database/migrations/base/
!/database/migrations/micropowermanager/
Loading

0 comments on commit 908c691

Please sign in to comment.