Modelos de Dados
Documentação dos principais modelos do banco de dados do Módulo Empreendedorismo.
Diagrama de Relacionamentos
┌─────────────┐ ┌─────────────────────┐ ┌─────────────────┐
│ User │────▶│ Entrepreneur │────▶│ BusinessPlan │
└─────────────┘ └─────────────────────┘ └─────────────────┘
│ │ │
│ ▼ ▼
│ ┌─────────────────┐ ┌─────────────────┐
│ │ Entrepreneur │ │ BusinessPlan │
│ │ Document │ │ Document │
│ └─────────────────┘ └─────────────────┘
│ │
│ ▼
│ ┌─────────────────┐
├────────────────────────────────────────│ Mentorship │
│ └─────────────────┘
│ │
▼ │
┌─────────────────────┐ │
│ StructuringAgent │◀───────────────────────────────
└─────────────────────┘
│
▼
┌─────────────────────┐ ┌─────────────────┐
│ ApprovalRequest │────▶│ Manager │
└─────────────────────┘ └─────────────────┘
▲
│
┌─────────────────────┐ │
│FinancialInstitution │───────────┘
└─────────────────────┘
│
▼
┌─────────────────────┐ ┌─────────────────┐
│ Affiliation │ │ CreditLine │
│ Document │ │ │
└─────────────────────┘ └─────────────────┘
User (accounts.User)
Modelo de usuário customizado do sistema.
class User(AbstractBaseUser, PermissionsMixin):
id = AutoField(primary_key=True)
email = EmailField(unique=True, max_length=255)
first_name = CharField(max_length=150)
last_name = CharField(max_length=150)
is_staff = BooleanField(default=False)
is_active = BooleanField(default=True)
email_verified = BooleanField(default=False)
is_first_login = BooleanField(default=True)
date_joined = DateTimeField(auto_now_add=True)
deleted_at = DateTimeField(null=True, blank=True)
USERNAME_FIELD = 'email'
| Campo | Tipo | Descrição |
|---|---|---|
id | Integer | Chave primária |
email | String | Email único (login) |
first_name | String | Primeiro nome |
last_name | String | Sobrenome |
is_staff | Boolean | Acesso ao admin |
is_active | Boolean | Conta ativa |
email_verified | Boolean | Email verificado |
is_first_login | Boolean | Primeiro acesso |
date_joined | DateTime | Data de criação |
deleted_at | DateTime | Data do soft delete |
Métodos
soft_delete()- Desativa conta sem deletar dadosreactivate()- Reativa conta após soft deleteis_deleted(property) - Verifica se conta foi deletada
Entrepreneur (entrepreneurs.Entrepreneur)
Perfil do empreendedor.
class Entrepreneur(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
user = OneToOneField(User, on_delete=CASCADE)
full_name = CharField(max_length=255)
cpf = CharField(max_length=11, unique=True)
phone = CharField(max_length=20)
proof_of_residence = FileField(upload_to='entrepreneurs/proof_of_residence/')
needs_help = BooleanField(default=False)
created_at = DateTimeField(auto_now_add=True)
updated_at = DateTimeField(auto_now=True)
| Campo | Tipo | Descrição |
|---|---|---|
id | UUID | Chave primária |
user | FK → User | Usuário vinculado |
full_name | String | Nome completo |
cpf | String(11) | CPF (único) |
phone | String | Telefone |
proof_of_residence | File | Comprovante de residência |
needs_help | Boolean | Precisa de ajuda |
created_at | DateTime | Data de criação |
updated_at | DateTime | Última atualização |
StructuringAgent (structuring_agents.StructuringAgent)
Perfil do agente estruturador (mentor).
class StructuringAgent(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
user = OneToOneField(User, on_delete=CASCADE)
full_name = CharField(max_length=255)
cpf = CharField(max_length=11, unique=True)
phone = CharField(max_length=20)
position = CharField(max_length=100)
institution = CharField(max_length=255)
cnpj = CharField(max_length=14)
proof_of_residence = FileField(upload_to='structuring_agents/proof/')
is_approved = BooleanField(default=False)
created_at = DateTimeField(auto_now_add=True)
updated_at = DateTimeField(auto_now=True)
| Campo | Tipo | Descrição |
|---|---|---|
id | UUID | Chave primária |
user | FK → User | Usuário vinculado |
full_name | String | Nome completo |
cpf | String(11) | CPF (único) |
phone | String | Telefone |
position | String | Cargo/função |
institution | String | Instituição |
cnpj | String(14) | CNPJ da instituição |
proof_of_residence | File | Comprovante |
is_approved | Boolean | Aprovado pelo gestor |
BusinessPlan (business_plans.BusinessPlan)
Plano de negócio do empreendedor.
class BusinessPlan(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
entrepreneur = ForeignKey(Entrepreneur, on_delete=CASCADE)
number = PositiveIntegerField()
business_name = CharField(max_length=255)
activity_sector = CharField(max_length=50, choices=ACTIVITY_SECTOR_CHOICES)
description = CharField(max_length=200)
stage = CharField(max_length=50, choices=STAGE_CHOICES)
target_audience = JSONField(default=list)
problem_solved = TextField()
competitors = TextField()
differentiator = TextField()
sales_strategy = TextField()
current_resources = TextField()
needed_resources = TextField()
current_structure = TextField()
initial_investment = DecimalField(max_digits=12, decimal_places=2)
recurring_expenses = DecimalField(max_digits=12, decimal_places=2)
expected_revenue = DecimalField(max_digits=12, decimal_places=2)
financing_options = JSONField(default=list)
status = CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
needs_mentorship = BooleanField(default=False)
mentorship = OneToOneField(Mentorship, null=True, blank=True)
review_feedback = TextField(blank=True)
submitted_at = DateTimeField(null=True)
created_at = DateTimeField(auto_now_add=True)
updated_at = DateTimeField(auto_now=True)
Status do Plano
| Status | Descrição |
|---|---|
pending | Rascunho, em preenchimento |
under_review | Aguardando revisão |
corrections | Correções solicitadas |
approved | Aprovado |
rejected | Rejeitado |
in_mentorship | Em mentoria |
Setores de Atividade (42 opções)
Exemplos: retail_food, retail_clothing, service_beauty, industry_food, agribusiness_production, etc.
Público Alvo
Array JSON com valores como: teenagers, adults, seniors, women, men, high_income, b2b, rural, etc.
Opções de Financiamento (21 opções)
Exemplos: own_resources, bndes, pronampe, fintech, angel_investor, venture_capital, etc.
Mentorship (business_plans.Mentorship)
Mentoria vinculada a um plano.
class Mentorship(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
mentor = ForeignKey(StructuringAgent, null=True, on_delete=SET_NULL)
idea_summary = TextField()
current_difficulties = TextField()
mentor_notes = TextField(blank=True)
created_at = DateTimeField(auto_now_add=True)
updated_at = DateTimeField(auto_now=True)
| Campo | Tipo | Descrição |
|---|---|---|
id | UUID | Chave primária |
mentor | FK → StructuringAgent | Mentor (null se não atribuído) |
idea_summary | Text | Resumo da ideia |
current_difficulties | Text | Dificuldades atuais |
mentor_notes | Text | Notas do mentor |
CorrectionRequest (business_plans.CorrectionRequest)
Solicitação de correção em um plano.
class CorrectionRequest(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
business_plan = ForeignKey(BusinessPlan, on_delete=CASCADE)
requested_by = ForeignKey(StructuringAgent, on_delete=CASCADE)
description = TextField()
reference_file = FileField(null=True, blank=True)
original_filename = CharField(max_length=255, blank=True)
status = CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
created_at = DateTimeField(auto_now_add=True)
updated_at = DateTimeField(auto_now=True)
resolved_at = DateTimeField(null=True)
Status da Correção
| Status | Descrição |
|---|---|
pending | Pendente |
in_progress | Em andamento |
resolved | Resolvida |
cancelled | Cancelada |
Manager (managers.Manager)
Perfil do gestor.
class Manager(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
user = OneToOneField(User, on_delete=CASCADE)
full_name = CharField(max_length=255)
position = CharField(max_length=100)
phone = CharField(max_length=20)
created_at = DateTimeField(auto_now_add=True)
updated_at = DateTimeField(auto_now=True)
ApprovalRequest (structuring_agents)
Solicitação de aprovação de agente.
class StructuringAgentApprovalRequest(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
structuring_agent = ForeignKey(StructuringAgent, on_delete=CASCADE)
status = CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
reviewed_by = ForeignKey(User, null=True, on_delete=SET_NULL)
review_notes = TextField(blank=True)
created_at = DateTimeField(auto_now_add=True)
reviewed_at = DateTimeField(null=True)
Status da Aprovação
| Status | Descrição |
|---|---|
pending | Pendente |
approved | Aprovado |
rejected | Rejeitado |
FinancialInstitution (financial_institutions.FinancialInstitution)
Perfil da instituição financeira.
class FinancialInstitution(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
user = OneToOneField(User, on_delete=CASCADE)
institution_name = CharField(max_length=255)
cnpj = CharField(max_length=14, unique=True)
phone = CharField(max_length=20)
responsible_name = CharField(max_length=255)
responsible_position = CharField(max_length=255)
is_approved = BooleanField(default=False)
created_at = DateTimeField(auto_now_add=True)
updated_at = DateTimeField(auto_now=True)
| Campo | Tipo | Descrição |
|---|---|---|
id | UUID | Chave primária |
user | FK → User | Usuário vinculado |
institution_name | String | Nome da instituição |
cnpj | String(14) | CNPJ (único) |
phone | String | Telefone |
responsible_name | String | Nome do responsável |
responsible_position | String | Cargo do responsável |
is_approved | Boolean | Aprovado pelo gestor |
created_at | DateTime | Data de criação |
updated_at | DateTime | Última atualização |
FinancialInstitutionAffiliationDocument
Documentos de vínculo institucional.
class FinancialInstitutionAffiliationDocument(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
financial_institution = ForeignKey(FinancialInstitution, on_delete=CASCADE)
file = FileField(upload_to='financial_institutions/{id}/affiliation_documents/')
uploaded_at = DateTimeField(auto_now_add=True)
| Campo | Tipo | Descrição |
|---|---|---|
id | UUID | Chave primária |
financial_institution | FK → FinancialInstitution | Instituição vinculada |
file | File | Arquivo do documento |
uploaded_at | DateTime | Data de upload |
FinancialInstitutionApprovalRequest
Solicitação de aprovação de instituição financeira.
class FinancialInstitutionApprovalRequest(models.Model):
id = UUIDField(primary_key=True, default=uuid.uuid4)
financial_institution = ForeignKey(FinancialInstitution, on_delete=CASCADE)
status = CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
reviewed_by = ForeignKey(User, null=True, on_delete=SET_NULL)
review_notes = TextField(blank=True)
created_at = DateTimeField(auto_now_add=True)
reviewed_at = DateTimeField(null=True)
Status da Aprovação
| Status | Descrição |
|---|---|
pending | Pendente |
approved | Aprovado |
rejected | Rejeitado |