2025-04-07 20:08:26 +07:00
|
|
|
# IMPHNEN Backend Service
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
<p align="center">
|
|
|
|
|
<img src="docs/logo.svg" alt="IMPHNEN">
|
|
|
|
|
</p>
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
This repository serves as the **monorepo** for all backend services of IMPHNEN. It encompasses several main services:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-05-20 11:54:15 +07:00
|
|
|
1. **IMPHNEN-Backend** - Provides fundamental functionalities and shared resources for other services.
|
|
|
|
|
2. **IMPHNEN-IAM** - Handles identity and access management across IMPHNEN applications.
|
|
|
|
|
3. **IMPHNEN-CMS** - Supports the cms services by IMPHNEN [Landing Page website](https://imphnen.dev/).
|
|
|
|
|
4. **IMPHNEN-Gacha** - Supports the gacha services by IMPHNEN [Gacha website](https://gacha.imphnen.dev/).
|
|
|
|
|
5. **IMPHNEN-Dimentorin** - Supports the mentoring services by IMPHNEN [Dimentorin website](https://dimentorin.imphnen.dev/).
|
|
|
|
|
6. **IMPHNEN-Gateway** - Acts as the API gateway, routing requests to appropriate services.
|
2025-05-22 16:18:15 +07:00
|
|
|
7. **IMPHNEN-Middleware** - Acts as the middleware for the API Gateway, providing authentication and authorization.
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-05-22 16:18:15 +07:00
|
|
|
## How to Install
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
1. **Clone the repository**:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
|
|
|
|
git clone https://github.com/IMPHNEN/imphnen-backend-service.git
|
|
|
|
|
cd imphnen-backend-service
|
|
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
2. **Set up the environment**:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
- Copy the example environment files:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
|
|
|
|
cp .env.example .env
|
|
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
if you use windows based system
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
|
|
|
|
./apply-env.ps1
|
|
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
if you use unix based system
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
2025-05-20 11:54:15 +07:00
|
|
|
source ./apply-env.sh
|
2025-04-07 20:08:26 +07:00
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
- Modify the `.env` files with your specific configuration settings.
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
3. **Install dependencies**:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
Ensure you have [Rust](https://www.rust-lang.org/) installed. Then, run:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
2025-05-22 22:29:28 +07:00
|
|
|
cargo fetch
|
2025-05-20 11:54:15 +07:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
4. **Run the seeders**:
|
|
|
|
|
|
|
|
|
|
to run the seeders, run:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cargo run --bin seeder
|
2025-04-07 20:08:26 +07:00
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
## How to Run
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
### Development
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
To run the services in development mode:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
1. **Start the database and other dependencies** using Docker Compose:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
|
|
|
|
docker-compose up -d
|
|
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-05-20 11:54:15 +07:00
|
|
|
2. **Run using cargo run**. For example, to run the Core Service:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
2025-05-20 11:54:15 +07:00
|
|
|
cargo run --bin api
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. **Run using cargo watch**. For example, to run the Core Service:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cargo watch -x "run --bin api"
|
2025-04-07 20:08:26 +07:00
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
### Production
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
For production deployment:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
1. **Build the Docker image**:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
2025-05-22 22:29:28 +07:00
|
|
|
docker build -t imphnen-backend .
|
2025-04-07 20:08:26 +07:00
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
2. **Run the Docker container**:
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
```sh
|
2025-05-26 23:41:00 +07:00
|
|
|
docker run --name imphnen-backend -d --env-file .env -p 3000:3000 imphnen-backend
|
2025-04-07 20:08:26 +07:00
|
|
|
```
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
Adjust the port and environment variables as needed.
|
2025-02-08 01:16:14 +07:00
|
|
|
|
2025-05-20 16:57:45 +07:00
|
|
|
## How to Run the Tests
|
|
|
|
|
|
|
|
|
|
1. **Run the tests**:
|
|
|
|
|
|
|
|
|
|
```sh
|
2025-05-22 16:18:15 +07:00
|
|
|
cargo test -p tests
|
2025-05-20 16:57:45 +07:00
|
|
|
```
|
|
|
|
|
|
2025-04-07 20:08:26 +07:00
|
|
|
## How to Contribute
|
|
|
|
|
|
|
|
|
|
1. **Fork the repository** and clone it locally.
|
|
|
|
|
2. **Create a new branch** for your feature or fix:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
git checkout -b feat/your-feature-name
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. **Make your changes**, commit them, and push to your forked repository.
|
|
|
|
|
4. **Create a pull request** to the `develop` branch of this repository.
|
|
|
|
|
|
|
|
|
|
If you encounter any issues or have questions, feel free to create a new issue in the repository.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
_Note: For detailed API documentation, please refer to our [API Docs](https://api.imphnen.dev/docs)._
|