# Micro-SaaS - Tasks

## Fase 1: Setup do Projeto

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T001 | Criar solution e projetos | - | S |
| T002 | Configurar packages NuGet | T001 | S |
| T003 | Criar estrutura de pastas | T001 | S |
| T004 | Configurar appsettings.json | T001 | S |

## Fase 2: Domain Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T005 | Criar BaseEntity | T001 | S |
| T006 | Criar Tenant entity | T005 | M |
| T007 | Criar TenantUser entity | T005 | M |
| T008 | Criar Plan entity | T005 | S |
| T009 | Criar Subscription entity | T005 | M |
| T010 | Criar SubscriptionPayment entity | T005 | M |
| T011 | Definir enums | T005 | S |

## Fase 3: Infrastructure Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T012 | Criar AppDbContext | T006-T011 | M |
| T013 | Configurar EF Core mappings | T012 | M |
| T014 | Criar TenantRepository | T012 | M |
| T015 | Criar TenantUserRepository | T012 | M |
| T016 | Criar SubscriptionRepository | T012 | M |
| T017 | Criar PlanRepository | T012 | S |
| T018 | Criar PaymentRepository | T012 | M |
| T019 | Implementar AsaasClient | T002 | L |
| T020 | Implementar AsaasWebhookHandler | T019 | M |

## Fase 4: Application Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T021 | Criar TenantService | T014, T015 | M |
| T022 | Criar TenantUserService | T015 | M |
| T023 | Criar SubscriptionService | T016, T019 | L |
| T024 | Criar PlanService | T017 | S |
| T025 | Criar DashboardService | T014-T018 | M |
| T026 | Criar WebhookService | T020, T016, T018 | M |

## Fase 5: Web Layer - Auth

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T027 | Configurar Clerk authentication | T002 | M |
| T028 | Implementar TenantContext | T014 | M |
| T029 | Criar middleware de tenant resolution | T028 | M |
| T030 | Configurar policies de autorização | T027 | S |

## Fase 6: Web Layer - Components

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T031 | Criar MainLayout | T027 | M |
| T032 | Criar NavMenu | T031 | S |
| T033 | Criar componentes shared (DataGrid, Card, etc) | T031 | M |

## Fase 7: Web Layer - Pages

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T034 | Criar página Dashboard | T025, T031 | M |
| T035 | Criar página Users | T022, T033 | M |
| T036 | Criar página Settings | T021, T033 | M |
| T037 | Criar página Billing | T023, T033 | L |
| T038 | Criar página Plans | T024, T033 | M |

## Fase 8: Web Layer - APIs

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T039 | Criar endpoints Tenant | T021 | M |
| T040 | Criar endpoints Users | T022 | M |
| T041 | Criar endpoints Subscription | T023 | M |
| T042 | Criar endpoint Webhook | T026 | M |

## Fase 9: Infrastructure (IaC)

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T043 | Criar main.bicep | - | M |
| T044 | Configurar Container App | T043 | M |
| T045 | Configurar SQL Database | T043 | M |
| T046 | Configurar Key Vault | T043 | S |
| T047 | Configurar App Insights | T043 | S |

## Fase 10: Testes e Documentação

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T048 | Criar testes unitários Domain | T006-T011 | M |
| T049 | Criar testes integração Services | T021-T026 | L |
| T050 | Criar testes E2E | T034-T042 | L |
| T051 | Documentar APIs (OpenAPI) | T039-T042 | M |

## Checkpoints

| Checkpoint | Após Tasks | Validação |
|------------|------------|-----------|
| CP1 | T004 | Projeto compila |
| CP2 | T011 | Domain layer completo |
| CP3 | T020 | Infrastructure layer completo |
| CP4 | T026 | Application layer completo |
| CP5 | T033 | Layout e componentes prontos |
| CP6 | T038 | Todas as páginas funcionando |
| CP7 | T042 | APIs funcionando |
| CP8 | T047 | IaC pronto para deploy |
| CP9 | T051 | Projeto completo |

## Legenda

- **S** = Small (< 1h)
- **M** = Medium (1-3h)
- **L** = Large (3-8h)

## Ordem de Execução Recomendada

```
T001 → T002 → T003 → T004 (CP1)
  ↓
T005 → T006-T011 (CP2)
  ↓
T012 → T013 → T014-T020 (CP3)
  ↓
T021-T026 (CP4)
  ↓
T027 → T028 → T029 → T030
  ↓
T031 → T032 → T033 (CP5)
  ↓
T034-T038 (CP6)
  ↓
T039-T042 (CP7)
  ↓
T043-T047 (CP8)
  ↓
T048-T051 (CP9)
```

---

*MORPH-SPEC by Polymorphism Tech*
