Skip to content

Commit fb7c88c

Browse files
Merge pull request #17 from C216-Distribuid-System-Project/develop
Filters and Relationship Routes Integration
2 parents c0c6f02 + 93ab98f commit fb7c88c

18 files changed

+856
-75
lines changed

docs/en/api_project_architecture_en.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ It includes schemas, routes, modules, and utility functions to ensure a clear se
1919
- [schemas](#schemas)
2020
- [utils](#utils)
2121
- [database](#database)
22+
- [tests](#tests)
2223
- [main.py](#mainpy)
2324

2425
---
@@ -68,6 +69,21 @@ graph TD;
6869
end
6970
end
7071
72+
subgraph tests
73+
T1[__init__.py]
74+
75+
subgraph tests/routes
76+
TR1[__init__.py]
77+
TR2[test_auth.py]
78+
end
79+
80+
subgraph tests/utils
81+
TU1[__init__.py]
82+
TU2[test_utils.py]
83+
end
84+
85+
end
86+
7187
subgraph utils
7288
U1[__init__.py]
7389
U2[utils.py]
@@ -154,6 +170,23 @@ Contains SQL files used to initialize and populate the MySQL database.
154170
- **`02_seed.sql`** → Provides initial test data (users, projects, and tasks) to quickly validate the API endpoints.
155171

156172

173+
---
174+
175+
### `tests`
176+
Contains all **unit and integration tests** implemented with **Pytest**.
177+
The folder is organized into submodules to keep the test cases modular and easy to maintain.
178+
179+
- **`__init__.py`** → Initializes the test package.
180+
181+
#### `tests/routes/`
182+
- **`__init__.py`** → Initializes the test routes subpackage.
183+
- **`test_auth.py`** → Tests for authentication endpoints (`/auth/register`, `/auth/login`), including success and failure scenarios.
184+
185+
#### `tests/utils/`
186+
- **`__init__.py`** → Initializes the test utils subpackage.
187+
- **`test_utils.py`** → Tests for helper functions defined in `utils/utils.py`.
188+
189+
157190
---
158191

159192
### `main.py`

docs/en/backend_proposal_todo_list_en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ Authentication will use JWT (JSON Web Token) to protect routes and allow access
166166
| Group | Method | Path | Implemented | Tested |
167167
|-------|--------|--------------------------------------|-------------|--------|
168168
| **Auth** ||||
169-
| | POST | `/auth/register` | | |
170-
| | POST | `/auth/login` | ||
169+
| | POST | `/auth/register` | | |
170+
| | POST | `/auth/login` | ||
171171
| **Users** ||||
172-
| | GET | `/users/me` | ||
172+
| | GET | `/users/me` | ||
173173
| **Projects** ||||
174174
| | GET | `/projects` |||
175175
| | POST | `/projects` |||

docs/en/docker_compose_documentation_en.md

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Docker Compose for the Project
1+
# Docker Compose of the Project
22

33
## How the `docker-compose.yaml` Works
44

5-
The file [`docker/docker-compose.yaml`](../../docker/docker-compose.yaml) is responsible for orchestrating the execution of the **MySQL database** and the **FastAPI API** using Docker Compose.
6-
It defines how services interact, their dependencies, and how data is persisted.
5+
The file [`docker/docker-compose.yaml`](../../docker/docker-compose.yaml) is responsible for orchestrating the execution of **MySQL databases** (production and test) and the **FastAPI API** using Docker Compose.
6+
It defines how the services interact, their dependencies, and how data is persisted.
77

88
---
99

10-
### Step by step of what it does:
10+
### Step by Step of What It Does:
1111

12-
1. **MySQL Service**
12+
1. **MySQL Service (Production)**
1313
```yaml
1414
mysql:
1515
build:
@@ -26,13 +26,36 @@ It defines how services interact, their dependencies, and how data is persisted.
2626
- "3307:3306"
2727
volumes:
2828
- mysql_data:/var/lib/mysql
29-
```
30-
- Builds a custom MySQL 8 image with schema preloaded.
31-
- Creates database `todolist` with user `app`.
29+
```
30+
- Builds a custom MySQL 8 image with the schema already loaded.
31+
- Creates the database `todolist` with user `app`.
3232
- Exposes port **3307** on the host.
33-
- Uses a **named volume** (`mysql_data`) to persist data.
33+
- Uses a **named volume** (`mysql_data`) for data persistence.
3434

35-
2. **API Service**
35+
2. **MySQL Service (Tests)**
36+
```yaml
37+
mysql-test:
38+
build:
39+
context: ..
40+
dockerfile: docker/MySQL/dockerfile
41+
image: todolist-mysql
42+
container_name: todolist-mysql-test
43+
environment:
44+
MYSQL_ROOT_PASSWORD: root_pass
45+
MYSQL_DATABASE: todolist
46+
MYSQL_USER: app_test
47+
MYSQL_PASSWORD: app_pass_test
48+
ports:
49+
- "3308:3306"
50+
volumes:
51+
- mysql_data_test:/var/lib/mysql
52+
```
53+
- Creates a separate container for **automated testing**.
54+
- Independent `todolist` database with user `app_test`.
55+
- Uses port **3308** to avoid conflicts with the production database.
56+
- Separate volume (`mysql_data_test`) to keep test data isolated from production.
57+
58+
3. **API Service**
3659
```yaml
3760
api:
3861
build:
@@ -46,38 +69,39 @@ It defines how services interact, their dependencies, and how data is persisted.
4669
- "8000:8000"
4770
environment:
4871
DATABASE_URL: "mysql+pymysql://app:app_pass@mysql:3306/todolist"
49-
```
50-
- Builds a custom FastAPI image from Python 3.11 slim.
51-
- Runs on port **8000** (`http://localhost:8000`).
52-
- Waits for the **MySQL service** to be up before starting (`depends_on`).
53-
- Connects to MySQL using the `DATABASE_URL` variable, pointing to the service name `mysql`.
72+
```
73+
- Builds the FastAPI image based on Python 3.11 slim.
74+
- Exposes the API on port **8000** → [http://localhost:8000](http://localhost:8000).
75+
- Waits for the `mysql` service to start (`depends_on`).
76+
- Uses the `DATABASE_URL` environment variable to connect to the production database.
5477

55-
3. **Volumes**
78+
4. **Volumes**
5679
```yaml
5780
volumes:
5881
mysql_data:
82+
mysql_data_test:
5983
```
60-
- Ensures MySQL data persists across container restarts.
84+
- `mysql_data` → persistence of the production database.
85+
- `mysql_data_test` → isolated persistence for the test database.
6186

6287
---
6388

6489
## How to Run with Docker Compose
6590

66-
1. From the project root, run:
91+
1. Start the environment:
6792
```bash
6893
docker compose -f docker/docker-compose.yaml -p todolist up --build
6994
```
70-
Explanation:
7195
- `-f docker/docker-compose.yaml` → specifies the file location
72-
- `-p todolist` sets the project name (instead of default `docker`)
73-
- `up --build` → builds images and starts containers
96+
- `-p todolist` defines the project name
97+
- `up --build` → builds the images and starts the containers
7498

75-
2. To stop the environment:
99+
2. Stop the environment:
76100
```bash
77101
docker compose -f docker/docker-compose.yaml -p todolist down
78102
```
79103

80-
3. To stop and also remove volumes (reset database):
104+
3. Stop and remove volumes (reset databases):
81105
```bash
82106
docker compose -f docker/docker-compose.yaml -p todolist down -v
83107
```
@@ -88,23 +112,26 @@ It defines how services interact, their dependencies, and how data is persisted.
88112

89113
- **API** → [http://localhost:8000](http://localhost:8000)
90114
- **API Docs (Swagger)** → [http://localhost:8000/docs](http://localhost:8000/docs)
91-
- **MySQL** →
115+
116+
- **MySQL (Production)**
92117
- Host: `localhost`
93118
- Port: `3307`
94119
- User: `app`
95120
- Password: `app_pass`
96121
- Database: `todolist`
97122

98-
Connection string example:
99-
```
100-
mysql+pymysql://app:app_pass@localhost:3307/todolist
101-
```
123+
- **MySQL (Tests)**
124+
- Host: `localhost`
125+
- Port: `3308`
126+
- User: `app_test`
127+
- Password: `app_pass_test`
128+
- Database: `todolist`
102129

103130
---
104131

105132
## Useful Commands
106133

107-
- View logs of all services:
134+
- View logs:
108135
```bash
109136
docker compose -p todolist logs -f
110137
```
@@ -114,11 +141,16 @@ mysql+pymysql://app:app_pass@localhost:3307/todolist
114141
docker compose -p todolist restart api
115142
```
116143

117-
- Access MySQL container:
144+
- Access production MySQL container:
118145
```bash
119146
docker exec -it todolist-mysql bash
120147
```
121148

149+
- Access test MySQL container:
150+
```bash
151+
docker exec -it todolist-mysql-test bash
152+
```
153+
122154
- Access API container:
123155
```bash
124156
docker exec -it api-container bash

docs/pt-br/api_project_architecture.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Inclui schemas, rotas, módulos e funções utilitárias para garantir uma clara
1919
- [schemas](#schemas)
2020
- [utils](#utils)
2121
- [database](#database)
22+
- [tests](#tests)
2223
- [main.py](#mainpy)
2324

2425
---
@@ -27,7 +28,7 @@ Inclui schemas, rotas, módulos e funções utilitárias para garantir uma clara
2728

2829
```mermaid
2930
graph TD;
30-
subgraph Projeto-API
31+
subgraph API-Project
3132
A1[main.py]
3233
A2[__init__.py]
3334
@@ -68,6 +69,21 @@ graph TD;
6869
end
6970
end
7071
72+
subgraph tests
73+
T1[__init__.py]
74+
75+
subgraph tests/routes
76+
TR1[__init__.py]
77+
TR2[test_auth.py]
78+
end
79+
80+
subgraph tests/utils
81+
TU1[__init__.py]
82+
TU2[test_utils.py]
83+
end
84+
85+
end
86+
7187
subgraph utils
7288
U1[__init__.py]
7389
U2[utils.py]
@@ -145,6 +161,8 @@ Contém funções auxiliares e scripts utilitários.
145161
- **`utils.py`** → Funções gerais utilizadas em diferentes partes do projeto.
146162
- **`__init__.py`** → Inicializa o pacote de utilitários.
147163

164+
---
165+
148166
### `database`
149167
Contém arquivos SQL usados para inicializar e popular o banco de dados MySQL.
150168

@@ -153,6 +171,23 @@ Contém arquivos SQL usados para inicializar e popular o banco de dados MySQL.
153171

154172
---
155173

174+
### `tests/`
175+
Contém todos os **testes unitários e de integração** implementados com **Pytest**.
176+
A pasta é organizada em submódulos para manter os casos de teste modulares e de fácil manutenção.
177+
178+
- **`__init__.py`**
179+
Inicializa o pacote de testes.
180+
181+
#### `tests/routes/`
182+
- **`__init__.py`** → Inicializa o subpacote de testes de rotas.
183+
- **`test_auth.py`** → Testes dos endpoints de autenticação (`/auth/register`, `/auth/login`), incluindo cenários de sucesso e falha.
184+
185+
#### `tests/utils/`
186+
- **`__init__.py`** → Inicializa o subpacote de testes de utilitários.
187+
- **`test_utils.py`** → Testes das funções auxiliares definidas em `utils/utils.py`.
188+
189+
---
190+
156191
### `main.py`
157192
O **ponto de entrada** da aplicação.
158193
Responsável por inicializar o FastAPI, incluindo rotas, módulos e configurações.

docs/pt-br/backend_proposal_todo_list.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ Será utilizada autenticação com JWT (JSON Web Token) para proteger as rotas e
165165
| Grupo | Método | Caminho | Implementado | Testado |
166166
|-------------|--------|----------------------------------------|--------------|---------|
167167
| **Autenticação** ||||
168-
| | POST | `/auth/register` | | |
169-
| | POST | `/auth/login` | ||
168+
| | POST | `/auth/register` | | |
169+
| | POST | `/auth/login` | ||
170170
| **Usuários** ||||
171-
| | GET | `/users/me` | ||
171+
| | GET | `/users/me` | ||
172172
| **Projetos** ||||
173173
| | GET | `/projects` |||
174174
| | POST | `/projects` |||

0 commit comments

Comments
 (0)