Skip to content

Commit

Permalink
Merge pull request #246 from xtreme1-io/main
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
jaggerwang authored May 7, 2024
2 parents eda2ba7 + b083df1 commit 221ec56
Show file tree
Hide file tree
Showing 16 changed files with 990 additions and 186 deletions.
130 changes: 3 additions & 127 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,128 +1,4 @@
# Contributor Covenant Code of Conduct
# Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
support@basic.ai.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
This is a project of the [The Linux Foundation](https://www.linuxfoundation.org/)
and follows the LF [Code of Conduct](https://events.linuxfoundation.org/about/code-of-conduct/).
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Contribute to Xtreme1

Thank you very much for your interest in the Xtreme1 project. We welcome your suggestions, comments (including criticisms) and contributions to the Xtreme1 project.

Your suggestions and comments on Xtreme1 can be made directly through GitHub's [Issues](https://github.com/xtreme1-io/xtreme1/issues/new/choose).

There are many ways to participate in and contribute to Xtreme1 projects: code implementation, test writing, document improvement, and so on. Any contribution will be welcomed and you will be added to the list of contributors.

## Initial contact

For the first time in Xtreme1 community, you can:

* Follow [Xtreme1 GitHub](https://github.com/xtreme1-io/xtreme1)
* Follow [Xtreme1 Twitter](https://twitter.com/Xtreme1io)
* Follow [Xtreme1 YouTube](https://www.youtube.com/@basicai)
* Follow [Xtreme1 LinkedIn](https://linkedin.com/company/basicaius)
* Follow [Xtreme1 Facebook](https://www.facebook.com/basicaiinc)
* Follow [Xtreme1 Reddit](https://www.reddit.com/r/BasicAI)

Learn the development trends of Xtreme1 project in time and give your opinions on the topics you are concerned about.

## Xtreme1's code and documentation

As you can see from [Xtreme1 GitHub](https://github.com/xtreme1-io/xtreme1), Xtreme1 code base mainly consists of two parts: Frontend (FE) and Backend (BE). Documents are also maintained on [GitHub](https://github.com/xtreme1-io/docs), and deployed on [GitBook](https://www.gitbook.com/). Details of these components can be found in the following table:

| Component Name | Component Description | Related Language |
|----------------|-----------------------|------------------|
| [Frontend (FE)](https://github.com/xtreme1-io/xtreme1) | Xtreme1 web ui | Java |
| [Backend (BE)](https://github.com/xtreme1-io/xtreme1) | Xtreme1 api service | JavaScript, TypeScript, HTML, CSS |
| [Docs](https://github.com/xtreme1-io/docs) | Xtreme1 documents | Markdown |

## Improving documentation

Documentation is the most important way for you to understand Xtreme1, and it's where we need help most!

Browse the document, you can deepen your understanding of Xtreme1, can also help you understand Xtreme1's function and technical details, if you find that the document has problems, please contact us in time;

If you are interested in improving the quality of documents, whether it is revising the address of a page, correcting a link, and writing a better introductory document, we are very welcome!

Most of our documents are written in Markdown format, and you can modify and submit document changes directly in [Xtreme1 Docs](https://github.com/xtreme1-io/docs).

## If a Bug or problem is found

If a Bug or problem is found, you can directly raise a new Issue through GitHub's [Issues](https://github.com/xtreme1-io/xtreme1/issues/new/choose), and we will have someone deal with it regularly.

You can also fix it yourself by reading and analyzing the source code (of course, it's better to talk to us before that, maybe someone has fixed the same problem) and submit a [Pull Request](https://github.com/xtreme1-io/xtreme1/compare).

## Modify the code and submit PR (Pull Request)

You can download the code, build and run it for a try (refer to [Frontend README](https://github.com/xtreme1-io/xtreme1/blob/main/frontend/README.md) and [Backend README](https://github.com/xtreme1-io/xtreme1/blob/main/backend/README.md)) to see if it works as you expected. If you have problems, you can contact us directly, ask questions or fix them by reading and analyzing the source code.

Whether it's fixing Bugs or adding Features, we're all very welcome. If you want to submit code to Xtreme1, you need to create a new branch for your submitted code from your forked repository and submit a PR.
File renamed without changes.
24 changes: 1 addition & 23 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
# Security Policy

## Supported Versions

At the moment only the latest release is supported. When you report a security issue,
be sure it can be reproduced in the supported version.

| Version | Supported |
| ------- | ------------------ |
| 0.6.x | :white_check_mark: |
| < 0.6.0 | :x: |

## Reporting a Vulnerability

If you have information about a security issue or vulnerability in the product,
please send an e-mail to [support@basic.ai](mailto:support@basic.ai).

Please provide as much information as possible, including:
- The products and versions affected
- Detailed description of the vulnerability
- Information on known exploits
A member of the xtreme1.io Product Security Team will review your e-mail and contact you to collaborate on resolving the issue.



This is a project of the [The Linux Foundation](https://www.linuxfoundation.org/) and follows the LF [How to report vulnerabilities to LF projects and foundations](https://apache.org/security/#reporting-a-vulnerability).
90 changes: 57 additions & 33 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,69 @@
# Xtreme1 Backend

## Application Architecture and Framework
## Frameworks and packages

![Clean Architecture Optimized](/docs/images/clean-architecture-opt.png?raw=true)
The following frameworks and packages are used.

1. [Spring Boot](https://spring.io/projects/spring-boot) Application framework
1. [MyBatis-Plus](https://baomidou.com/) A powerful enhanced toolkit of MyBatis which is borned to simplify development
1. [Spring Data Redis](https://spring.io/projects/spring-data-redis) Distribute cache
1. [Spring Security](https://spring.io/projects/spring-security) Authenticate and authorize

This application uses an optimized clean architecture inspiration from [The Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html), it's simpler than the original one. The most important rule of clean architecture is that only outter layer can dependent on inner layer, the reverse does not allowed. To achieve this goal, we need to create interfaces for all outside dependencies used in usecase layer, and implement all these interfaces in adapter layer.
## Code architecture

We use the following main frameworks and packages.
![Clean Architecture Optimized](/docs/images/clean-architecture-opt.png?raw=true)

1. [Spring Boot](https://spring.io/projects/spring-boot) Web framework and server
1. [MyBatis](https://mybatis.org/) SQL Mapping Framework
1. [MyBatis-Plus](https://baomidou.com/) An powerful enhanced toolkit of MyBatis for simplify development
1. [Spring Data Redis](https://spring.io/projects/spring-data-redis) Cache data
1. [Spring Security](https://spring.io/projects/spring-security) Authenticate and authrorize
This application uses an optimized clean architecture inspired from [The Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html), it's simpler than the original one. The most important rule of clean architecture is that only outter layer can dependent on inner layer, the reverse does not allowed. To achieve this goal, we need to create interfaces for all outside dependencies used in usecase layer, and implement all these interfaces in adapter layer.

## Directory Structure
## Directory structure

```
.
├── adapter // Adapter layer
│   ├── Application.java // Application entry
│   ├── api // Apis for frontend
│   ├── api // API for frontend
│   ├── dto // Data transfer objects
│   ├── exception // Exceptions occur in adapter layer
│   └── port // Outside dependencies used in adapter layer, including implementations of interfaces defined in usecase layer
├── entity // Entity layer
├── usecase // Usecase layer
│   ├── ...
│   ├── UserUseCase.java // Usecase for user module
│   ├── UserUseCase.java // Usecases for user module
│   ├── exception // Exceptions occur in usecase layer
│   └── port // Interfaces of outside dependencies used in usecase layer, such as persistence data, sending email, etc.
│   └── port // Interfaces of outside dependencies used in usecase layer, such as persisting data, sending email, etc.
└── util // Business irrelevant tools
```

> For database access, as we are not intend to replace mysql database and mybatis framework, and there are too many interfaces to define, so we let usecase layer to directly call daos (Data Access Objects) in adapter layer.
> For database access, as we are not intend to replace mysql database or mybatis framework, and there are too many interfaces to define, so we let usecase layer to directly call DAO (Data Access Object) in adapter layer.
## Local development

To build and run this application, you need to have Java 11 and Maven 3.8 installed first, or the newer but not tested.
To build and run this application, you need to install Java 11+ and Maven 3.8+.

### Clone repository

```bash
git clone https://github.com/basicai/xtreme1.git
git clone https://github.com/xtreme1-io/xtreme1.git
cd xtreme1
```

### Prepare base services
### Prepare base services

This application need base services, including MySQL, Redis and MinIO. You can use your existing base services, or start these base services using Docker Compose. To start base services by Docker Compose, you can use the following commands, refrence the top level README to get more. You can skip this step if you decide to using your existing base services.
This application need some base services, including MySQL, Redis and MinIO. You can start these base services using the included Docker Compose file `docker-compose.yml`, or use your existing base services.

Run the following command to start base services by Docker Compose.

```bash
docker compose up
```

### Prepare local configuration
### Prepare local configuration file

For using base services started by Docker Compose, you can save the following content in a local configuration file to path `backend/src/main/resources/application-local.yml`. You can change the address, username and password of any base service as your need, such as using an existing one.
The default configuration file `backend/src/main/resources/application.yml` is just for running by Docker Compose, the addresses of all base services are only accessible in Docker Compose's internal network. For local development, you need to change all these addresses to `localhost` and corresponding mapping port, or the addresses of your existing base services. It's recommend to create a new local configuration file `backend/src/main/resources/application-local.yml` to override the default one.

```yaml
debug: false
Following is an example local configuration file, you can change the address, username and password as your need.

```yaml
spring:
datasource:
url: jdbc:mysql://localhost:8191/xtreme1
Expand All @@ -70,33 +73,54 @@ spring:
host: localhost
port: 8192
password:
database: 0

minio:
internalEndpoint: http://localhost:8193/
# Also change the proxy_pass address for location /minio/ in nginx configuration file if you not use the Docker Compose MinIO service.
endpoint: http://localhost:8193/
accessKey: admin
secretKey: 1tQB970y

bucketName: xtreme1
```
If you choose to use your existing services, be sure to init these services, for MySQL you need to create tables and init data, for MinIO you need to create the default bucket. For more infomation you can reference the top level Docker Compose file, it will auto do these jobs when starting these services by Docker Compose.
If you choose to use your existing services, you should init these services manually. For mysql, execute sql files under directory `deploy/mysql/migration` to create tables and insert initial data. For nginx, you should configure a virtual server like `deploy/nginx/conf.d/default.conf`. For more infomation, you can reference the Docker Compose file.

### Build and run

You can build and run this application in your favorite IDE, such as Intellij IDEA, or exetute the following commands in terminal.
You can build and run this application in your favorite IDE, such as Intellij IDEA, make sure to enable `local` profile.

![Run in IDEA](/docs/backend/images/idea-run-local.png)

Or run in terminal.

```bash
cd backend

# Bulding jar package.
# Build jar package.
mvn package

# Using local configuration to start application.
java -Dspring.profiles.active=local -jar target/xtreme1-backend-0.9.1-SNAPSHOT.jar
# Run application with local configuration.
java -Dspring.profiles.active=local -jar target/xtreme1-backend-x.y.z-SNAPSHOT.jar
```

Now you can access the backend service at `http://localhost:8080/`.

## Coding Standards
## Coding standards

### Auto format

Recommend to use IDEA's auto format function, go to `Settings->Editor->Code Style->Java`, click `Configure Icon->Import Scheme->IntelliJ IDEA code style XML`, and select code style file `backend/coding-standards/intellij-code-format.xml`.

Configure auto format on save as following, check `Reformat code`, `Optimize imports` and `Rearrange code`.

![Actions on Save](/docs/backend/images/idea-save-actions.png)

### Check style

Xtreme1 backend use [Checktyle](https://github.com/checkstyle/checkstyle) to check code style, for IDEA please install `Checkstyle-IDEA` plugin first, go to `Settings->Tools->Checkstyle`, and create a new configuration file by using the local checkstyle file `backend/coding-standards/checkstyle.xml`.

![Configure Checkstyle](/docs/backend/images/idea-checkstyle-configure.png)

Then you can run Checkstyle to check code style.

![Run Checkstyle](/docs/backend/images/idea-checkstyle-run.png)

The code you contribute should follow the guidelines of [Alibaba Java Coding Guidelines](https://github.com/alibaba/Alibaba-Java-Coding-Guidelines). There also have checking plugins for most popular IDEs, such as Intellij IDEA, VS Code etc., you can search "Alibaba Java Coding Guidelines" in each's IDE's plugin repository. There should be no `BLOCKER` and `CRITICAL` error in the code you contribute, excepting for naming error like `DTO`, `BO` etc.
> Right now the code style is not forced, but in the future it will be forced by using GitHub's CI pipeline.
Loading

0 comments on commit 221ec56

Please sign in to comment.