From 60e608001c8839d9c28b197ce5dc53f75639840d Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Wed, 15 Oct 2025 12:49:55 +0800 Subject: [PATCH] docs: update README files to enhance development setup instructions and add frontend documentation --- README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++- backend/README.md | 59 +++++++++++++++++++++++++++++++---------- frontend/README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+), 15 deletions(-) create mode 100644 frontend/README.md diff --git a/README.md b/README.md index 2529ed8..259d035 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Blog -## Development +## Description - Frontend: SvelteKit with Tailwind CSS - Backend: Rust actix-web @@ -13,6 +13,68 @@ These will allow me to become more proficient in these modern development practi For more information about the development process, you can check out the [project board](https://git.squidspirit.com/squid/blog/projects). As for the details of the architecture and convention, you can find them in the [wiki](https://git.squidspirit.com/squid/blog/wiki). +## Build & Development Setup + +### Prerequisites + +- [Node.js](https://nodejs.org/) (LTS version recommended) +- [pnpm](https://pnpm.io/) - Package manager for frontend +- [Rust](https://rustup.rs/) - For backend development +- [Podman](https://podman.io/) (Optional) - For containerized deployment + +### Pre-commit Setup + +This project uses pre-commit hooks to ensure code quality. To set up pre-commit: + +1. Install pre-commit: + + ```bash + pip install pre-commit + ``` + +2. Install the git hook scripts: + ```bash + pre-commit install + ``` + +The pre-commit configuration will automatically run: + +- Backend Rust code checking and formatting +- Frontend linting and formatting +- SQL schema preparation + +### Backend Setup + +For detailed backend development setup, see [backend/README.md](./backend/README.md). + +Quick start: + +1. Install sqlx CLI: `cargo install sqlx-cli` +2. Run database migrations: `sqlx migrate run` +3. Prepare SQL schema: `cargo sqlx prepare --workspace` +4. Run the server: `RUST_LOG=debug cargo run` + +### Frontend Setup + +For detailed frontend development setup, see [frontend/README.md](./frontend/README.md). + +Quick start: + +1. Navigate to frontend directory: `cd frontend` +2. Install dependencies: `pnpm install` +3. Start development server: `pnpm dev` +4. Build for production: `pnpm build` + +### Full Project Setup + +To set up the entire project: + +1. Clone the repository +2. Set up pre-commit hooks (see above) +3. Set up backend (see backend/README.md) +4. Set up frontend (see above) +5. Start both servers for full-stack development + ## License This project uses a combination of the [MIT License and a custom license](./LICENSE.md). Based on the MIT License, anyone is permitted to use the code. However, before deploying the code, they must first replace any information belonging to "me" or any content that could identify "me," such as logos, names, and "about me" sections. diff --git a/backend/README.md b/backend/README.md index dbc4b51..4b18f6e 100644 --- a/backend/README.md +++ b/backend/README.md @@ -2,40 +2,71 @@ ## Development -### SQL Migration +### Prerequisites -1. Install sqlx +- [Rust](https://rustup.rs/) - Latest stable version +- [sqlx-cli](https://github.com/launchbadge/sqlx/tree/main/sqlx-cli) - Database migration tool +- [watchexec](https://github.com/watchexec/watchexec) (Optional) - For hot reloading + +### Setup + +1. Install sqlx CLI: ```bash cargo install sqlx-cli ``` -2. Run migration +2. Run database migrations: ```bash sqlx migrate run ``` -### Run Project - -1. Prepare for sql schema setup +3. Prepare SQL schema: ```bash cargo sqlx prepare --workspace ``` -2. Run the server - +4. Run the server: ```bash RUST_LOG=debug cargo run ``` -3. (Optional) Hot restart +### Development Commands - 1. Install `watchexec` +- **Run server**: `RUST_LOG=debug cargo run` +- **Hot reload** (optional): `RUST_LOG=debug watchexec -e rs -r 'cargo run'` +- **Database migration**: `sqlx migrate run` +- **Schema preparation**: `cargo sqlx prepare --workspace` +- **Build**: `cargo build` +- **Test**: `cargo test` - 2. Run the server with `watchexec` +### Project Structure - ```bash - RUST_LOG=debug watchexec -e rs -r 'cargo run' - ``` +The backend follows Clean Architecture principles with a modular structure: + +- `server/` - Main server application and configuration +- `feature/` - Feature modules organized by domain + - `auth/` - Authentication and authorization + - `post/` - Blog post management + - `label/` - Label/tag system + - `image/` - Image handling + - `common/` - Shared utilities and types +- `migrations/` - Database migration scripts + +Each feature module follows the Clean Architecture pattern: + +- `domain/` - Business logic and entities +- `application/` - Use cases and application services +- `adapter/` - Interface adapters (controllers, presenters) +- `framework/` - External frameworks (database, HTTP) + +### Technology Stack + +- **Framework**: Actix-web +- **Database**: PostgreSQL with SQLx +- **Authentication**: JWT-based +- **Serialization**: Serde +- **Migration**: SQLx migrations +- **Logging**: env_logger with RUST_LOG diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..8571b46 --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,65 @@ +# Frontend + +## Development + +### Prerequisites + +- [Node.js](https://nodejs.org/) (LTS version recommended) +- [pnpm](https://pnpm.io/) - Package manager + +### Setup + +1. Install dependencies: + + ```bash + pnpm install + ``` + +2. Start development server: + + ```bash + pnpm dev + ``` + +3. Build for production: + + ```bash + pnpm build + ``` + +4. Preview production build: + ```bash + pnpm preview + ``` + +### Development Commands + +- **Type checking**: `pnpm check` +- **Type checking (watch mode)**: `pnpm check:watch` +- **Linting**: `pnpm lint` +- **Formatting**: `pnpm format` + +### Project Structure + +The frontend is built with SvelteKit and Tailwind CSS following Clean Architecture principles: + +- `src/lib/` - Core application modules organized by feature +- `src/routes/` - SvelteKit route pages +- `src/app.html` - Main HTML template +- `src/app.css` - Global styles + +Each feature module in `src/lib/` follows the Clean Architecture pattern: + +- `domain/` - Business logic and entities +- `application/` - Use cases and application services +- `adapter/` - Interface adapters (presenters, view models) +- `framework/` - External frameworks (UI components, API services) + +### Technology Stack + +- **Framework**: SvelteKit 5 +- **Styling**: Tailwind CSS 4 +- **UI Components**: bits-ui, Lucide icons +- **Type Safety**: TypeScript +- **Linting**: ESLint with Prettier +- **Package Manager**: pnpm