docs: update README files to enhance development setup instructions and add frontend documentation
All checks were successful
Frontend CI / build (push) Successful in 1m37s
Auto Comment On PR / add_improve_comment (pull_request) Successful in 17s
PR Title Check / pr-title-check (pull_request) Successful in 17s

This commit is contained in:
SquidSpirit 2025-10-15 12:49:55 +08:00
parent 2df96e966d
commit 60e608001c
3 changed files with 173 additions and 15 deletions

View File

@ -1,6 +1,6 @@
# Blog # Blog
## Development ## Description
- Frontend: SvelteKit with Tailwind CSS - Frontend: SvelteKit with Tailwind CSS
- Backend: Rust actix-web - 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). 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 ## 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. 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.

View File

@ -2,40 +2,71 @@
## Development ## 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 ```bash
cargo install sqlx-cli cargo install sqlx-cli
``` ```
2. Run migration 2. Run database migrations:
```bash ```bash
sqlx migrate run sqlx migrate run
``` ```
### Run Project 3. Prepare SQL schema:
1. Prepare for sql schema setup
```bash ```bash
cargo sqlx prepare --workspace cargo sqlx prepare --workspace
``` ```
2. Run the server 4. Run the server:
```bash ```bash
RUST_LOG=debug cargo run 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 The backend follows Clean Architecture principles with a modular structure:
RUST_LOG=debug watchexec -e rs -r 'cargo run'
``` - `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

65
frontend/README.md Normal file
View File

@ -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