You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Folders and Files Description](#folders-and-files-description)
16
+
-[models](#models)
16
17
-[modules](#modules)
17
18
-[routes](#routes)
18
19
-[schemas](#schemas)
@@ -29,13 +30,20 @@ graph TD;
29
30
A1[main.py]
30
31
A2[__init__.py]
31
32
33
+
subgraph models
34
+
B1[__init__.py]
35
+
B2[user_model.py]
36
+
end
37
+
32
38
subgraph modules
33
39
M1[__init__.py]
34
40
M2[modules_api.py]
41
+
M3[database_conection.py]
35
42
end
36
43
37
44
subgraph routes
38
45
R1[__init__.py]
46
+
R2[authentication_routes.py]
39
47
end
40
48
41
49
subgraph schemas
@@ -51,6 +59,11 @@ graph TD;
51
59
subgraph users
52
60
S5[__init__.py]
53
61
S6[users_schema.py]
62
+
subgraph CRUD
63
+
C1[__init__.py]
64
+
C2[create.py]
65
+
C3[read.py]
66
+
end
54
67
end
55
68
end
56
69
@@ -63,51 +76,76 @@ graph TD;
63
76
64
77
---
65
78
66
-
## Folder & File Descriptions
79
+
## Folders and Files Description
80
+
81
+
### `models/`
82
+
Defines ORM models using SQLAlchemy.
83
+
84
+
-**`user_model.py`** → Contains the `User` class, representing the `users` table in the database, with columns such as `id`, `name`, `email`, `password_hash`, `birth_date`, `phone`, `created_at`, etc.
67
85
68
86
### `modules`
69
87
Contains modular functionalities that extend the backend.
70
88
71
-
-**`modules_api.py`** → Defines reusable API components and logic.
72
-
-**`__init__.py`** → Initializes the modules package.
89
+
-**`database_conection.py`** → Responsible for configuring the MySQL database connection using `SQLAlchemy`, and creating the `engine`, `SessionLocal`, and `Base` instances.
90
+
-**`modules_api.py`** → Defines reusable API components and logic.
91
+
-**`__init__.py`** → Initializes the modules package.
73
92
74
93
---
75
94
76
95
### `routes`
77
-
Defines all API endpoints for the application.
96
+
Defines all API endpoints of the application.
78
97
79
98
-**`__init__.py`** → Initializes the routes module.
80
-
(Additional route files will be added here as the project evolves.)
99
+
-**`authentication_routes.py`**
100
+
Contains the endpoints:
101
+
-`POST /auth/register` → Registers a new user.
102
+
-`POST /auth/login` → Authenticates and returns a JWT token.
81
103
82
104
---
83
105
84
106
### `schemas`
85
107
Contains all **Pydantic schemas** used for validation and data modeling.
86
108
109
+
#### `users/`
110
+
-**`users_schema.py`**
111
+
Contains Pydantic models:
112
+
-`UserCreate` (input data for registration)
113
+
-`UserLogin` (input data for login)
114
+
-`UserResponse` (API response)
115
+
- Uses `from_attributes = True` for compatibility with SQLAlchemy (equivalent to the former `orm_mode = True`).
116
+
117
+
-**`CRUD/create.py`**
118
+
Defines functions for:
119
+
-`create_user()` → creates and persists a new user.
120
+
- Uses `bcrypt` with `passlib` to hash passwords.
121
+
122
+
-**`CRUD/read.py`**
123
+
Defines functions for:
124
+
-`authenticate_user()` → validates email and password.
125
+
-`get_user_by_email()` → retrieves a user by email.
126
+
87
127
#### `projects`
88
-
-**`projects_schema.py`** → Defines schemas related to projects.
89
-
-**`__init__.py`** → Initializes the projects schemas package.
128
+
-**`projects_schema.py`** → Defines schemas related to projects.
129
+
-**`__init__.py`** → Initializes the project schemas package.
90
130
91
131
#### `tasks`
92
-
-**`tasks_schema.py`** → Defines schemas related to tasks.
93
-
-**`__init__.py`** → Initializes the tasks schemas package.
132
+
-**`tasks_schema.py`** → Defines schemas related to tasks.
133
+
-**`__init__.py`** → Initializes the task schemas package.
94
134
95
135
#### `users`
96
-
-**`users_schema.py`** → Defines schemas related to users.
97
-
-**`__init__.py`** → Initializes the users schemas package.
136
+
-**`users_schema.py`** → Defines schemas related to users.
137
+
-**`__init__.py`** → Initializes the user schemas package.
98
138
99
139
---
100
140
101
141
### `utils`
102
142
Contains helper functions and utility scripts.
103
143
104
-
-**`utils.py`** → General utility functions used across the project.
105
-
-**`__init__.py`** → Initializes the utils package.
144
+
-**`utils.py`** → General-purpose functions used in different parts of the project.
145
+
-**`__init__.py`** → Initializes the utilities package.
106
146
107
147
---
108
148
109
149
### `main.py`
110
150
The **entry point** of the application.
111
-
Responsible for initializing FastAPI, including routes, modules, and configurations.
112
-
113
-
---
151
+
Responsible for initializing FastAPI, including routes, modules, and configurations.
Copy file name to clipboardExpand all lines: docs/pt-br/api_project_architecture.md
+42-2Lines changed: 42 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ Inclui schemas, rotas, módulos e funções utilitárias para garantir uma clara
13
13
## Índice
14
14
-[Estrutura do Projeto](#estrutura-do-projeto)
15
15
-[Descrição das Pastas e Arquivos](#descrição-das-pastas-e-arquivos)
16
+
-[models](#models)
16
17
-[modules](#modules)
17
18
-[routes](#routes)
18
19
-[schemas](#schemas)
@@ -29,13 +30,20 @@ graph TD;
29
30
A1[main.py]
30
31
A2[__init__.py]
31
32
33
+
subgraph models
34
+
B1[__init__.py]
35
+
B2[user_model.py]
36
+
end
37
+
32
38
subgraph modules
33
39
M1[__init__.py]
34
40
M2[modules_api.py]
41
+
M3[database_conection.py]
35
42
end
36
43
37
44
subgraph routes
38
45
R1[__init__.py]
46
+
R2[authentication_routes.py]
39
47
end
40
48
41
49
subgraph schemas
@@ -51,6 +59,11 @@ graph TD;
51
59
subgraph users
52
60
S5[__init__.py]
53
61
S6[users_schema.py]
62
+
subgraph CRUD
63
+
C1[__init__.py]
64
+
C2[create.py]
65
+
C3[read.py]
66
+
end
54
67
end
55
68
end
56
69
@@ -65,9 +78,15 @@ graph TD;
65
78
66
79
## Descrição das Pastas e Arquivos
67
80
81
+
### `models/`
82
+
Define os modelos ORM com SQLAlchemy.
83
+
84
+
-**`user_model.py`** → Contém a classe `User`, que representa a tabela `users` no banco de dados, com colunas como `id`, `name`, `email`, `password_hash`, `birth_date`, `phone`, `created_at`, etc.
85
+
68
86
### `modules`
69
87
Contém funcionalidades modulares que estendem o backend.
70
88
89
+
-**`database_conection.py`** → Responsável por configurar a conexão com o banco MySQL usando `SQLAlchemy`, e criar a instância `engine`, `SessionLocal`, e `Base`.
71
90
-**`modules_api.py`** → Define componentes e lógicas de API reutilizáveis.
72
91
-**`__init__.py`** → Inicializa o pacote de módulos.
73
92
@@ -77,13 +96,34 @@ Contém funcionalidades modulares que estendem o backend.
77
96
Define todos os endpoints da API da aplicação.
78
97
79
98
-**`__init__.py`** → Inicializa o módulo de rotas.
80
-
(Arquivos adicionais de rotas serão adicionados aqui conforme o projeto evoluir.)
81
-
99
+
-**`authentication_routes.py`**
100
+
Contém os endpoints de:
101
+
-`POST /auth/register` → Cadastra novo usuário.
102
+
-`POST /auth/login` → Autentica e retorna o token JWT.
103
+
82
104
---
83
105
84
106
### `schemas`
85
107
Contém todos os **schemas do Pydantic** usados para validação e modelagem de dados.
86
108
109
+
#### `users/`
110
+
-**`users_schema.py`**
111
+
Contém os modelos Pydantic:
112
+
-`UserCreate` (entrada de dados no cadastro)
113
+
-`UserLogin` (entrada de dados no login)
114
+
-`UserResponse` (resposta da API)
115
+
- Usa `from_attributes = True` para compatibilidade com SQLAlchemy (equivalente ao antigo `orm_mode = True`).
116
+
117
+
-**`CRUD/create.py`**
118
+
Define as funções de:
119
+
-`create_user()` → cria e persiste novo usuário.
120
+
- Usa `bcrypt` com `passlib` para hashear senhas.
121
+
122
+
-**`CRUD/read.py`**
123
+
Define as funções de:
124
+
-`authenticate_user()` → valida email e senha.
125
+
-`get_user_by_email()` → busca usuário por email.
126
+
87
127
#### `projects`
88
128
-**`projects_schema.py`** → Define os schemas relacionados a projetos.
89
129
-**`__init__.py`** → Inicializa o pacote de schemas de projetos.
0 commit comments