feat: microservice architecture

This commit is contained in:
2025-11-05 09:12:34 +01:00
parent 54a047f5dc
commit 65a428534c
354 changed files with 5544 additions and 13141 deletions

View File

@@ -0,0 +1,169 @@
# Story 4.1: Complete Blog Module
## Metadata
- **Story ID**: 4.1
- **Title**: Complete Blog Module
- **Phase**: 4 - Sample Feature Module (Blog)
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: 10-12 hours
- **Dependencies**: 3.1, 3.2, 3.3, 2.3
## Goal
Create a complete sample blog module to demonstrate the framework, showing how to add routes, permissions, database entities, and services. This serves as a reference implementation for future developers.
## Description
This story implements a complete blog module with blog posts, CRUD operations, proper authorization, and integration with the core platform. The module demonstrates all aspects of module development including domain models, repositories, services, API handlers, and module registration.
## Deliverables
### 1. Blog Module Structure
- Create `modules/blog/` directory with proper structure:
```
modules/blog/
├── go.mod
├── module.yaml
├── internal/
│ ├── api/
│ │ └── handler.go
│ ├── domain/
│ │ ├── post.go
│ │ └── post_repo.go
│ ├── service/
│ │ └── post_service.go
│ └── ent/
│ └── schema/
│ └── post.go
└── pkg/
└── module.go
```
- Initialize `go.mod` for blog module
### 2. Module Manifest (`modules/blog/module.yaml`)
- Define module metadata (name, version, dependencies)
- Define permissions (blog.post.create, read, update, delete)
- Define routes with permission requirements
### 3. Blog Domain Model
- `Post` domain entity in `modules/blog/internal/domain/post.go`
- Ent schema in `modules/blog/internal/ent/schema/post.go`:
- Fields: title, content, author_id (FK to user)
- Indexes: author_id, created_at
- Timestamps: created_at, updated_at
- Generate Ent code for blog module
### 4. Blog Repository
- `PostRepository` interface in `modules/blog/internal/domain/post_repo.go`
- Implementation using Ent client (shared from core)
- CRUD operations: Create, FindByID, FindByAuthor, Update, Delete
- Pagination support
### 5. Blog Service
- `PostService` in `modules/blog/internal/service/post_service.go`
- Business logic for creating/updating posts
- Validation (title length, content requirements)
- Authorization checks (author can only update own posts)
- Uses service clients for inter-service communication:
- `IdentityServiceClient` - to get user information
- `AuthzServiceClient` - for authorization checks
- `AuditServiceClient` - for audit logging
### 6. Blog API Handlers
- API handlers in `modules/blog/internal/api/handler.go`:
- `POST /api/v1/blog/posts` - Create post
- `GET /api/v1/blog/posts/:id` - Get post
- `GET /api/v1/blog/posts` - List posts (with pagination)
- `PUT /api/v1/blog/posts/:id` - Update post
- `DELETE /api/v1/blog/posts/:id` - Delete post
- Use authorization middleware for all endpoints
- Register handlers in module's `Init()`
### 7. Blog Module Implementation
- Module implementation in `modules/blog/pkg/module.go`:
- Implement IModule interface
- Define Init() fx.Option
- Define Migrations()
- Register module in init()
### 8. Integration
- Update main `go.mod` to include blog module
- Import blog module in `cmd/platform/main.go`
- Run permission generation: `make generate`
- Verify blog permissions are generated
### 9. Tests
- Integration test in `modules/blog/internal/api/handler_test.go`:
- Test creating post with valid permission
- Test creating post without permission (403)
- Test updating own post vs other's post
- Test pagination
- Unit tests for service and repository
## Implementation Steps
1. **Create Module Structure**
- Create directory structure
- Initialize go.mod
2. **Create Module Manifest**
- Create module.yaml
- Define permissions and routes
3. **Create Domain Model**
- Create Post entity
- Create Ent schema
- Generate Ent code
4. **Create Repository**
- Create repository interface
- Implement using Ent
5. **Create Service**
- Create service with business logic
- Add validation and authorization
6. **Create API Handlers**
- Create handlers
- Add authorization middleware
- Register routes
7. **Create Module Implementation**
- Implement IModule interface
- Register module
8. **Integrate with Platform**
- Import module in main
- Generate permissions
- Test integration
9. **Add Tests**
- Create integration tests
- Create unit tests
## Acceptance Criteria
- [ ] Blog module loads on platform startup
- [ ] `POST /api/v1/blog/posts` requires `blog.post.create` permission
- [ ] User can create, read, update, delete posts
- [ ] Authorization enforced (users can only edit own posts)
- [ ] Integration test: full CRUD flow works
- [ ] Audit logs record all blog actions
- [ ] Permissions are generated correctly
- [ ] Module migrations run on startup
## Related ADRs
- [ADR-0029: Microservices Architecture](../../adr/0029-microservices-architecture.md)
- [ADR-0030: Service Communication Strategy](../../adr/0030-service-communication-strategy.md)
- See module framework ADRs
## Files to Create/Modify
- `modules/blog/module.yaml` - Module manifest
- `modules/blog/go.mod` - Module dependencies
- `modules/blog/internal/domain/post.go` - Domain model
- `modules/blog/internal/ent/schema/post.go` - Ent schema
- `modules/blog/internal/domain/post_repo.go` - Repository
- `modules/blog/internal/service/post_service.go` - Service
- `modules/blog/internal/api/handler.go` - API handlers
- `modules/blog/pkg/module.go` - Module implementation
- `go.mod` - Add blog module
- `cmd/platform/main.go` - Import blog module

View File

@@ -1,58 +0,0 @@
# Task 4.1.1: Create `modules/blog/` directory:
## Metadata
- **Task ID**: 4.1.1
- **Title**: Create `modules/blog/` directory:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.1
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create `modules/blog/` directory:
## Requirements
- Create `modules/blog/` directory:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.1.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
modules/blog/
├── go.mod
├── module.yaml
├── internal/
├── api/
└── handler.go
├── domain/
├── post.go
└── post_repo.go
└── service/
└── post_service.go
└── pkg/
└── module.go
```

View File

@@ -1,47 +0,0 @@
# Task 4.1.2: Initialize `go.mod`:
## Metadata
- **Task ID**: 4.1.2
- **Title**: Initialize `go.mod`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.1
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Initialize `go.mod`:
## Requirements
- Initialize `go.mod`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.1.2 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
cd modules/blog
go mod init github.com/yourorg/blog
```

View File

@@ -1,70 +0,0 @@
# Task 4.2.1: Create `modules/blog/module.yaml`:
## Metadata
- **Task ID**: 4.2.1
- **Title**: Create `modules/blog/module.yaml`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.2
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create `modules/blog/module.yaml`:
## Requirements
- Create `modules/blog/module.yaml`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.2.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
name: blog
version: 0.1.0
dependencies:
- core >= 1.0.0
permissions:
- blog.post.create
- blog.post.read
- blog.post.update
- blog.post.delete
routes:
- method: POST
path: /api/v1/blog/posts
permission: blog.post.create
- method: GET
path: /api/v1/blog/posts/:id
permission: blog.post.read
- method: PUT
path: /api/v1/blog/posts/:id
permission: blog.post.update
- method: DELETE
path: /api/v1/blog/posts/:id
permission: blog.post.delete
- method: GET
path: /api/v1/blog/posts
permission: blog.post.read
```

View File

@@ -1,53 +0,0 @@
# Task 4.3.1: Create `modules/blog/internal/domain/post.go`:
## Metadata
- **Task ID**: 4.3.1
- **Title**: Create `modules/blog/internal/domain/post.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.3
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create `modules/blog/internal/domain/post.go`:
## Requirements
- Create `modules/blog/internal/domain/post.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.3.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
type Post struct {
ID string
Title string
Content string
AuthorID string
CreatedAt time.Time
UpdatedAt time.Time
}
```

View File

@@ -1,40 +0,0 @@
# Task 4.3.2: Create Ent schema `modules/blog/internal/ent/schema/post.go`:
## Metadata
- **Task ID**: 4.3.2
- **Title**: Create Ent schema `modules/blog/internal/ent/schema/post.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.3
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create Ent schema `modules/blog/internal/ent/schema/post.go`:
## Requirements
- Create Ent schema `modules/blog/internal/ent/schema/post.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.3.2 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,40 +0,0 @@
# Task 4.3.3: Generate Ent code for blog module
## Metadata
- **Task ID**: 4.3.3
- **Title**: Generate Ent code for blog module
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.3
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Generate Ent code for blog module
## Requirements
- Generate Ent code for blog module
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.3.3 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,52 +0,0 @@
# Task 4.4.1: Create `modules/blog/internal/domain/post_repo.go`:
## Metadata
- **Task ID**: 4.4.1
- **Title**: Create `modules/blog/internal/domain/post_repo.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.4
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create `modules/blog/internal/domain/post_repo.go`:
## Requirements
- Create `modules/blog/internal/domain/post_repo.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.4.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
type PostRepository interface {
Create(ctx context.Context, p *Post) (*Post, error)
FindByID(ctx context.Context, id string) (*Post, error)
FindByAuthor(ctx context.Context, authorID string) ([]*Post, error)
Update(ctx context.Context, p *Post) error
Delete(ctx context.Context, id string) error
}
```

View File

@@ -1,40 +0,0 @@
# Task 4.4.2: Implement using Ent client (shared from core)
## Metadata
- **Task ID**: 4.4.2
- **Title**: Implement using Ent client (shared from core)
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.4
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Implement using Ent client (shared from core)
## Requirements
- Implement using Ent client (shared from core)
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.4.2 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,40 +0,0 @@
# Task 4.5.1: Create `modules/blog/internal/service/post_service.go`:
## Metadata
- **Task ID**: 4.5.1
- **Title**: Create `modules/blog/internal/service/post_service.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.5
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create `modules/blog/internal/service/post_service.go`:
## Requirements
- Create `modules/blog/internal/service/post_service.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.5.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,40 +0,0 @@
# Task 4.6.1: Create `modules/blog/internal/api/handler.go`:
## Metadata
- **Task ID**: 4.6.1
- **Title**: Create `modules/blog/internal/api/handler.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.6
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create `modules/blog/internal/api/handler.go`:
## Requirements
- Create `modules/blog/internal/api/handler.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.6.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,46 +0,0 @@
# Task 4.6.2: Use authorization middleware:
## Metadata
- **Task ID**: 4.6.2
- **Title**: Use authorization middleware:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.6
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Use authorization middleware:
## Requirements
- Use authorization middleware:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.6.2 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
grp.Use(auth.RequirePermission(perm.BlogPostCreate))
```

View File

@@ -1,40 +0,0 @@
# Task 4.6.3: Register handlers in module's `Init()`
## Metadata
- **Task ID**: 4.6.3
- **Title**: Register handlers in module's `Init()`
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.6
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Register handlers in module's `Init()`
## Requirements
- Register handlers in module's `Init()`
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.6.3 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,70 +0,0 @@
# Task 4.7.1: Create `modules/blog/pkg/module.go`:
## Metadata
- **Task ID**: 4.7.1
- **Title**: Create `modules/blog/pkg/module.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.7
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create `modules/blog/pkg/module.go`:
## Requirements
- Create `modules/blog/pkg/module.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.7.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
type BlogModule struct{}
func (b BlogModule) Name() string { return "blog" }
func (b BlogModule) Version() string { return "0.1.0" }
func (b BlogModule) Dependencies() []string { return nil }
func (b BlogModule) Init() fx.Option {
return fx.Options(
fx.Provide(NewPostRepo),
fx.Provide(NewPostService),
fx.Invoke(RegisterHandlers),
)
}
func (b BlogModule) Migrations() []func(*ent.Client) error {
return []func(*ent.Client) error{
func(c *ent.Client) error {
return c.Schema.Create(context.Background())
},
}
}
var Module BlogModule
func init() {
registry.Register(Module)
}
```

View File

@@ -1,46 +0,0 @@
# Task 4.8.1: Update main `go.mod` to include blog module:
## Metadata
- **Task ID**: 4.8.1
- **Title**: Update main `go.mod` to include blog module:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.8
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Update main `go.mod` to include blog module:
## Requirements
- Update main `go.mod` to include blog module:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.8.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
replace github.com/yourorg/blog => ./modules/blog
```

View File

@@ -1,46 +0,0 @@
# Task 4.8.2: Import blog module in `cmd/platform/main.go`:
## Metadata
- **Task ID**: 4.8.2
- **Title**: Import blog module in `cmd/platform/main.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.8
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Import blog module in `cmd/platform/main.go`:
## Requirements
- Import blog module in `cmd/platform/main.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.8.2 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```
## Code Reference
```go
import _ "github.com/yourorg/blog/pkg"
```

View File

@@ -1,40 +0,0 @@
# Task 4.8.3: Run permission generation: `make generate`
## Metadata
- **Task ID**: 4.8.3
- **Title**: Run permission generation: `make generate`
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.8
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Run permission generation: `make generate`
## Requirements
- Run permission generation: `make generate`
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.8.3 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,40 +0,0 @@
# Task 4.8.4: Verify blog permissions are generated
## Metadata
- **Task ID**: 4.8.4
- **Title**: Verify blog permissions are generated
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.8
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Verify blog permissions are generated
## Requirements
- Verify blog permissions are generated
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.8.4 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,40 +0,0 @@
# Task 4.9.1: Create integration test `modules/blog/internal/api/handler_test.go`:
## Metadata
- **Task ID**: 4.9.1
- **Title**: Create integration test `modules/blog/internal/api/handler_test.go`:
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.9
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Create integration test `modules/blog/internal/api/handler_test.go`:
## Requirements
- Create integration test `modules/blog/internal/api/handler_test.go`:
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.9.1 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,40 +0,0 @@
# Task 4.9.2: Add unit tests for service and repository
## Metadata
- **Task ID**: 4.9.2
- **Title**: Add unit tests for service and repository
- **Phase**: 4 - Sample Feature Module (Blog)
- **Section**: 4.9
- **Status**: Pending
- **Priority**: High
- **Estimated Time**: TBD
- **Dependencies**: TBD
## Description
Add unit tests for service and repository
## Requirements
- Add unit tests for service and repository
## Implementation Steps
1. TODO: Add implementation steps
2. TODO: Add implementation steps
3. TODO: Add implementation steps
## Acceptance Criteria
- [ ] Task 4.9.2 is completed
- [ ] All requirements are met
- [ ] Code compiles and tests pass
## Related ADRs
- See relevant ADRs in `docs/adr/`
## Implementation Notes
- TODO: Add implementation notes
## Testing
```bash
# TODO: Add test commands
go test ./...
```

View File

@@ -1,31 +1,14 @@
# Phase 4: Sample Feature Module (Blog)
## Overview
Create a sample blog module to demonstrate the module framework. This module will implement blog posts with CRUD operations, showing how to build a feature module that integrates with the core platform.
Create a complete sample module (Blog) to demonstrate the framework, showing how to add routes, permissions, database entities, and services. The Blog module is an independent service that uses service clients to communicate with core services. Provide reference implementation for future developers.
## Tasks
## Stories
### 4.1 Module Setup
- [4.1.1 - Create Blog Module Directory](./4.1.1-create-modulesblog-directory.md)
- [4.1.2 - Initialize Go Module](./4.1.2-initialize-gomod.md)
### 4.2 Module Configuration
- [4.2.1 - Create Module Manifest](./4.2.1-create-modulesblogmoduleyaml.md)
### 4.3 Domain Layer
- [4.3.1 - Create Post Domain Model](./4.3.1-create-modulesbloginternaldomainpostgo.md)
- [4.3.2 - Create Ent Schema](./4.3.2-create-modulesbloginternalentschemapost.md)
- [4.3.3 - Generate Ent Code](./4.3.3-generate-ent-code-for-blog-module.md)
### 4.4 Repository Layer
- [4.4.1 - Create Post Repository Interface](./4.4.1-create-modulesbloginternaldomainpost_repogo.md)
- [4.4.2 - Implement Repository](./4.4.2-implement-using-ent-client-shared-from-core.md)
### 4.5 Service Layer
- [4.5.1 - Create Post Service](./4.5.1-create-modulesbloginternalservicepost_servicego.md)
### 4.6 API Layer
- [4.6.1 - Create API Handler](./4.6.1-create-modulesbloginternalapihandlergo.md)
### 4.1 Complete Blog Module
- [Story: 4.1 - Blog Module](./4.1-blog-module.md)
- **Goal:** Create a complete sample blog module to demonstrate the framework.
- **Deliverables:** Complete blog module with CRUD operations, permissions, database entities, services, API handlers, and integration tests
## Deliverables Checklist
- [ ] Blog module directory structure created
@@ -36,6 +19,7 @@ Create a sample blog module to demonstrate the module framework. This module wil
- [ ] Service layer implements business logic
- [ ] API endpoints for blog posts working
- [ ] Module integrated with core platform
- [ ] Integration tests passing
## Acceptance Criteria
- Blog module can be registered with core platform
@@ -44,4 +28,4 @@ Create a sample blog module to demonstrate the module framework. This module wil
- API endpoints require proper authentication
- Module migrations run on startup
- Blog posts are associated with users
- Authorization enforced (users can only edit own posts)