···11-<!-- markdownlint-disable MD013 -->
22-31# 👩🚒 SENAC Brigade
4253## Architecture
6475
8699-## Routes
1010-1111-| Route | Description | Method |
1212-| ------------------------------ | ----------------------------------------------------------- | ------------- |
1313-| /admin/setup | Create the first admin user | POST (JSON) |
1414-| /admin/signup | Register a new user account | POST (Form) |
1515-| /admin/users | List all registred users | GET |
1616-| /admin/users/{{id}} | Delete an user from the DataBase | DELETE |
1717-| /admin/users/{{id}} | Update the user data as an admin | PUT (JSON) |
1818-| /admin/users/{{id}}/status | Update the status of a user account | PUT (JSON) |
1919-| /admin/teams | Register a new brigade, with a leader and all their members | POST (Form) |
2020-| /admin/teams | Query all registered brigades | GET |
2121-| /admin/teams/{{id}}/status | Update the status of a brigade | PUT (JSON) |
2222-| /admin/teams/{{id}} | Remove a brigade | DELETE |
2323-| /user/login | Login with your user account | POST (Form) |
2424-| /user/profile | Retrieve data about the authenticated user | GET |
2525-| /user/profile | Update your profile | PUT(JSON) |
2626-| /user/roles | Get a list of all available roles | GET |
2727-| /user/{{id}}/occurrences | Find all occurrences applied by this user | GET |
2828-| /user/{{id}}/crew_members | List fellow brigade members of this user | GET |
2929-| /user/notification_preferences | Fetch authenticated user notification preferences | GET |
3030-| /user/notification_preferences | Update authenticated user notification preferences | PUT (JSON) |
3131-| /user/password | Update authenticated user password | PUT (JSON) |
3232-| /brigade/{{id}}/members | List brigade members | GET |
3333-| /dashboard/stats | Fetch stats for the dashboard page | GET |
3434-| /analysis/occurrence | Fetch data for analysis about occurrences | GET |
3535-| /occurrence/new | Register a new occurrence | POST (Form) |
3636-| /occurrence/resolve/{{id}} | Update an occurrence `resolved_at` field | POST / DELETE |
3737-3838-## Entity RelationShip Diagram
3939-4040-```mermaid
4141----
4242-title: SENAC Brigade
4343----
4444-4545-erDiagram
4646-4747- user_account {
4848- UUID id PK
4949- USER_ROLE_ENUM user_role
5050- TEXT full_name
5151- TEXT password_hash
5252- TEXT registration
5353- TEXT phone
5454- TEXT email UK
5555- BOOLEAN is_active
5656- TIMESTAMP created_at
5757- TIMESTAMP updated_at
5858- }
5959-6060- notification_preference ||--|{ user_account : preference
6161- notification_preference {
6262- UUID id PK
6363- UUID user_id FK
6464- NOTIFICATION_TYPE_ENUM notification_type
6565- BOOLEAN enabled
6666- TIMESTAMP created_at
6767- TIMESTAMP updated_at
6868- }
6969-7070- brigade }o--|{ user_account : leader_of
7171- brigade {
7272- UUID id PK
7373- UUID leader_id FK
7474- TEXT name
7575- TEXT vehicle_code
7676- TEXT description
7777- BOOLEAN is_active
7878- TIMESTAMP created_at
7979- TIMESTAMP updated_at
8080- }
8181-8282- brigade_membership }|--|{ user_account : is_member_of
8383- brigade_membership }|--|{ brigade : is_part_of
8484- brigade_membership {
8585- UUID id PK
8686- UUID user_id FK
8787- UUID brigade_id FK
8888- }
77+## Docs
8989090- occurrence }o--|{ user_account : submit
9191- occurrence {
9292- UUID id PK
9393- UUID applicant_id FK
9494- OCCURRENCE_CATEGORY_ENUM category
9595- OCCURRENCE_SUBCATEGORY_ENUM subcategory
9696- TEXT description
9797- POINT location
9898- TEXT reference_point
9999- TIMESTAMP created_at
100100- TIMESTAMP updated_at
101101- TIMESTAMP resolved_at
102102- }
103103-104104- occurrence_brigade }|--|{ brigade : assigned_to
105105- occurrence_brigade }|--|{ occurrence : assigned
106106- occurrence_brigade {
107107- UUID id PK
108108- UUID occurrence_id FK
109109- UUID brigade_id FK
110110- }
111111-```
112112-113113-114114-## /user
115115-116116-### POST /user/login
117117-118118-#### Request
119119-120120-```json
121121-{
122122- "matricula": "000",
123123- "senha": "wibble"
124124-}
125125-```
126126-127127-#### Response
128128-129129-`200 OK`
130130-131131-132132-```json
133133-{
134134- "id": "3aedc1d9-79cc-45fe-a294-938351b9f83d",
135135- "role": "bombeiro"
136136-}
137137-```
138138-139139-### PUT /user/password
140140-141141-#### Request
142142-143143-```json
144144-{
145145- "senhaAtual": "wibble",
146146- "novaSenha": "wobble",
147147- "confirmarSenha": "wobble"
148148-}
149149-```
150150-151151-#### Response
152152-153153-`200 OK`
154154-155155-156156-```plaintext
157157- Senha atualizada com sucesso!
158158-```
99+[Entity RelationShip Diagram](docs/db.md)\
1010+[HTTP Endpoints](docs/routes.md)\
+74
docs/db.md
···11+## Entity RelationShip Diagram
22+33+```mermaid
44+---
55+title: SENAC Brigade
66+---
77+88+erDiagram
99+1010+ user_account {
1111+ UUID id PK
1212+ USER_ROLE_ENUM user_role
1313+ TEXT full_name
1414+ TEXT password_hash
1515+ TEXT registration
1616+ TEXT phone
1717+ TEXT email UK
1818+ BOOLEAN is_active
1919+ TIMESTAMP created_at
2020+ TIMESTAMP updated_at
2121+ }
2222+2323+ notification_preference ||--|{ user_account : preference
2424+ notification_preference {
2525+ UUID id PK
2626+ UUID user_id FK
2727+ NOTIFICATION_TYPE_ENUM notification_type
2828+ BOOLEAN enabled
2929+ TIMESTAMP created_at
3030+ TIMESTAMP updated_at
3131+ }
3232+3333+ brigade }o--|{ user_account : leader_of
3434+ brigade {
3535+ UUID id PK
3636+ UUID leader_id FK
3737+ TEXT name
3838+ TEXT vehicle_code
3939+ TEXT description
4040+ BOOLEAN is_active
4141+ TIMESTAMP created_at
4242+ TIMESTAMP updated_at
4343+ }
4444+4545+ brigade_membership }|--|{ user_account : is_member_of
4646+ brigade_membership }|--|{ brigade : is_part_of
4747+ brigade_membership {
4848+ UUID id PK
4949+ UUID user_id FK
5050+ UUID brigade_id FK
5151+ }
5252+5353+ occurrence }o--|{ user_account : submit
5454+ occurrence {
5555+ UUID id PK
5656+ UUID applicant_id FK
5757+ OCCURRENCE_CATEGORY_ENUM category
5858+ OCCURRENCE_SUBCATEGORY_ENUM subcategory
5959+ TEXT description
6060+ POINT location
6161+ TEXT reference_point
6262+ TIMESTAMP created_at
6363+ TIMESTAMP updated_at
6464+ TIMESTAMP resolved_at
6565+ }
6666+6767+ occurrence_brigade }|--|{ brigade : assigned_to
6868+ occurrence_brigade }|--|{ occurrence : assigned
6969+ occurrence_brigade {
7070+ UUID id PK
7171+ UUID occurrence_id FK
7272+ UUID brigade_id FK
7373+ }
7474+```
+32
docs/routes.md
···11+## Table of contents
22+33+[`/user`](routes/user.md)
44+55+## Overview
66+77+| Route | Description | Method |
88+| ------------------------------ | ----------------------------------------------------------- | ------------- |
99+| /admin/setup | Create the first admin user | POST (JSON) |
1010+| /admin/signup | Register a new user account | POST (Form) |
1111+| /admin/users | List all registred users | GET |
1212+| /admin/users/{{id}} | Delete an user from the DataBase | DELETE |
1313+| /admin/users/{{id}} | Update the user data as an admin | PUT (JSON) |
1414+| /admin/users/{{id}}/status | Update the status of a user account | PUT (JSON) |
1515+| /admin/teams | Register a new brigade, with a leader and all their members | POST (Form) |
1616+| /admin/teams | Query all registered brigades | GET |
1717+| /admin/teams/{{id}}/status | Update the status of a brigade | PUT (JSON) |
1818+| /admin/teams/{{id}} | Remove a brigade | DELETE |
1919+| /user/login | Login with your user account | POST (Form) |
2020+| /user/profile | Retrieve data about the authenticated user | GET |
2121+| /user/profile | Update your profile | PUT(JSON) |
2222+| /user/roles | Get a list of all available roles | GET |
2323+| /user/{{id}}/occurrences | Find all occurrences applied by this user | GET |
2424+| /user/{{id}}/crew_members | List fellow brigade members of this user | GET |
2525+| /user/notification_preferences | Fetch authenticated user notification preferences | GET |
2626+| /user/notification_preferences | Update authenticated user notification preferences | PUT (JSON) |
2727+| /user/password | Update authenticated user password | PUT (JSON) |
2828+| /brigade/{{id}}/members | List brigade members | GET |
2929+| /dashboard/stats | Fetch stats for the dashboard page | GET |
3030+| /analysis/occurrence | Fetch data for analysis about occurrences | GET |
3131+| /occurrence/new | Register a new occurrence | POST (Form) |
3232+| /occurrence/resolve/{{id}} | Update an occurrence `resolved_at` field | POST / DELETE |