Minimal Todo Example
Project Structure
Section titled “Project Structure”minimal-todo/├── entities/Todo.ts├── repositories/│ ├── ITodoRepository.ts│ └── InMemoryTodoRepository.ts├── services/│ ├── ITodoService.ts│ └── TodoService.ts├── ioc.config.json└── container.gen.ts
Todo Entity
Section titled “Todo Entity”export interface Todo { id: string; title: string; description: string; completed: boolean; createdAt: Date; updatedAt: Date;}
Repository Interface
Section titled “Repository Interface”export interface ITodoRepository { findById(id: string): Promise<Todo | null>; findAll(): Promise<Todo[]>; create(title: string, description: string): Promise<Todo>; update(id: string, updates: Partial<Todo>): Promise<Todo | null>; delete(id: string): Promise<boolean>;}
Service Layer
Section titled “Service Layer”export class TodoService implements ITodoService { constructor(private todoRepository: ITodoRepository) {}
async createTodo(data: { title: string; description: string }): Promise<Todo> { return await this.todoRepository.create(data.title, data.description); }}
Configuration
Section titled “Configuration”{ "source": ".", "output": "container.gen.ts"}
import { container } from './container.gen';
const todoService = container.coreModule.ITodoService;await todoService.createTodo({ title: 'Learn IoC Arise', description: 'Study dependency injection'});