From 054f0f63ff48ec672f3634c00070aacffe46a4ff Mon Sep 17 00:00:00 2001 From: Maulana Sodiqin Date: Mon, 7 Apr 2025 20:08:26 +0700 Subject: [PATCH] chore: adjust README.md --- Cargo.lock | 4 ++ README.md | 121 ++++++++++++++++++++------------ docker-compose.yml | 8 +++ docs/logo.svg | 9 +++ imphnen-cms-service/Cargo.toml | 24 +++++++ imphnen-cms-service/src/main.rs | 3 + imphnen-core-service/Cargo.toml | 4 +- 7 files changed, 125 insertions(+), 48 deletions(-) create mode 100644 docs/logo.svg create mode 100644 imphnen-cms-service/Cargo.toml create mode 100644 imphnen-cms-service/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 290f06b..25821a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1871,6 +1871,10 @@ dependencies = [ "validator", ] +[[package]] +name = "imphnen-cms-service" +version = "0.1.0" + [[package]] name = "imphnen-dimentorin-service" version = "0.1.0" diff --git a/README.md b/README.md index 615b232..a7664e1 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,107 @@ -# Axum SurrealDB Boilerplate +# IMPHNEN Backend Service -## Features +

+ IMPHNEN +

-- **Authentication Ready**: Preconfigured authentication and middleware for secure API access. -- **Database Integration**: SurrealDB seamlessly integrated as an Axum Extension. -- **CORS Handling**: Fine-tuned CORS management with Tower HTTP `CorsLayer`. -- **API Documentation**: Fully documented with OpenAPI and Swagger UI. -- **Optimized for Performance**: Asynchronous, lightweight, and scalable architecture. +This repository serves as the **monorepo** for all backend services of IMPHNEN. It encompasses several main services: -## Prerequisites +1. **Core Service** - Provides fundamental functionalities and shared resources for other services. +2. **IAM Service** - Handles identity and access management across IMPHNEN applications. +3. **CMS Service** - Supports the cms services by IMPHNEN [Landing Page website](https://imphnen.dev/). +4. **Gacha Service** - Supports the gacha services by IMPHNEN [Gacha website](https://gacha.imphnen.dev/). +5. **Dimentorin Service** - Supports the mentoring services by IMPHNEN [Dimentorin website](https://dimentorin.imphnen.dev/). +6. **Gateway Service** - Acts as the API gateway, routing requests to appropriate services. -- **Rust**: Install Rust from [rust-lang.org](https://www.rust-lang.org/). -- **Database**: Set up a SurrealDB instance and configure connection details. -- **Docker**: Required for containerized deployment, install from [docker.com](https://www.docker.com/). -- **Nix (Optional)**: For reproducible builds, install from [nixos.org](https://nixos.org/). +## How to Install -## Getting Started +1. **Clone the repository**: -1. **Clone the Repository**: + ```sh + git clone https://github.com/IMPHNEN/imphnen-backend-service.git + cd imphnen-backend-service + ``` - - `git clone https://github.com/maulanasdqn/axum-surrealdb-boilerplate` +2. **Set up the environment**: -2. **Set Up Environment Variables**: + - Copy the example environment files: - - Copy `.env.example` and rename it to `.env` + ```sh + cp .env.example .env + ``` - - **Windows**: Run the script: `./apply-env.ps1` - - **Unix-based systems (Linux, macOS, BSD)**: Run the script: `./apply-env.sh` + if you use windows based system -3. **Install Dependencies**: + ```sh + ./apply-env.ps1 + ``` - - `cargo install .` + if you use unix based system -4. **Setup Database**: + ```sh + sh apply-env.sh + ``` - - Install the surrealDB - - **Windows**: `iwr https://windows.surrealdb.com -useb | iex` - - **Unix-based systems (Linux, macOS, BSD)**: `curl -sSf https://install.surrealdb.com | sh` - - Start the database `surreal start --user root --pass root` + - Modify the `.env` files with your specific configuration settings. -5. **Start the Server**: +3. **Install dependencies**: - - Install Cargo Watch `cargo install cargo-watch` - - Run it with cargo watch `cargo watch -x run` + Ensure you have [Rust](https://www.rust-lang.org/) installed. Then, run: - The API will be available at `http://localhost:3000/docs`. + ```sh + cargo build + ``` -## Docker +## How to Run -1. **Build the Docker Image**: +### Development -2. **Run the Docker Container**: +To run the services in development mode: - The API will be accessible at `http://localhost:3000/docs`. +1. **Start the database and other dependencies** using Docker Compose: -## Using Nix as Builder (Optional) + ```sh + docker-compose up -d + ``` -1. **Install Nix**: +2. **Run the desired service**. For example, to run the Core Service: -2. **Enter Nix Shell or Use Nix Flakes**: + ```sh + cargo run -p imphnen-core-service --bin api + ``` -3. **Build the Project**: +### Production -4. **Run the Server**: +For production deployment: -## Contributing +1. **Build the Docker image**: -Contributions are welcome! Fork the repository and create a pull request with your improvements. + ```sh + docker build -t imphnen-backend-service . + ``` -## License +2. **Run the Docker container**: -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. + ```sh + docker run -d --env-file .env -p 8080:8080 imphnen-backend-service + ``` -## Acknowledgements + Adjust the port and environment variables as needed. -- [Axum](https://github.com/tokio-rs/axum) -- [SurrealDB](https://github.com/surrealdb/surrealdb) +## 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)._ diff --git a/docker-compose.yml b/docker-compose.yml index 94dcfc8..a13a103 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,3 +6,11 @@ services: ports: - "${PORT}:${PORT}" env_file: ".env" + depends_on: + - surrealdb + + surrealdb: + image: surrealdb/surrealdb:latest + command: start --log trace --user root --pass root + ports: + - "8000:8000" diff --git a/docs/logo.svg b/docs/logo.svg new file mode 100644 index 0000000..ca0f36e --- /dev/null +++ b/docs/logo.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/imphnen-cms-service/Cargo.toml b/imphnen-cms-service/Cargo.toml new file mode 100644 index 0000000..c2d0734 --- /dev/null +++ b/imphnen-cms-service/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "imphnen-cms-service" +version = "0.1.0" +edition = "2024" + +[dependencies] +imphnen-entities = { version = "0.1.0", path = "../imphnen-entities" } +imphnen-libs = { version = "0.1.0", path = "../imphnen-libs" } +imphnen-utils = { version = "0.1.0", path = "../imphnen-utils" } +axum.workspace = true +serde.workspace = true +serde_json.workspace = true +utoipa.workspace = true +lazy_static.workspace = true +regex.workspace = true +validator.workspace = true +axum-test.workspace = true +surrealdb.workspace = true +rand.workspace = true +tokio.workspace = true +chrono.workspace = true +anyhow.workspace = true +tower-http.workspace = true +utoipa-swagger-ui.workspace = true \ No newline at end of file diff --git a/imphnen-cms-service/src/main.rs b/imphnen-cms-service/src/main.rs new file mode 100644 index 0000000..a30eb95 --- /dev/null +++ b/imphnen-cms-service/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/imphnen-core-service/Cargo.toml b/imphnen-core-service/Cargo.toml index 1b2b0b3..7ec3bb8 100644 --- a/imphnen-core-service/Cargo.toml +++ b/imphnen-core-service/Cargo.toml @@ -4,9 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -imphnen-entities = { version = "0.1.0", path = "../imphnen-entities" } imphnen-libs = { version = "0.1.0", path = "../imphnen-libs" } imphnen-utils = { version = "0.1.0", path = "../imphnen-utils" } +imphnen-entities = { version = "0.1.0", path = "../imphnen-entities" } +imphnen-gateway-service = { version = "0.1.0", path = "../imphnen-gateway-service" } axum.workspace = true serde.workspace = true serde_json.workspace = true @@ -22,4 +23,3 @@ chrono.workspace = true anyhow.workspace = true tower-http.workspace = true utoipa-swagger-ui.workspace = true -imphnen-gateway-service = { version = "0.1.0", path = "../imphnen-gateway-service" }