wip: currently rewriting the project as a full stack application tangled.org/kacaii.dev/sigo
gleam

:memo: add docs directory

+156 -151
+3 -151
README.md
··· 1 - <!-- markdownlint-disable MD013 --> 2 - 3 1 # 👩‍🚒 SENAC Brigade 4 2 5 3 ## Architecture 6 4 7 5 ![Backend Architecture](assets/backend_architecture.png) 8 6 9 - ## Routes 10 - 11 - | Route | Description | Method | 12 - | ------------------------------ | ----------------------------------------------------------- | ------------- | 13 - | /admin/setup | Create the first admin user | POST (JSON) | 14 - | /admin/signup | Register a new user account | POST (Form) | 15 - | /admin/users | List all registred users | GET | 16 - | /admin/users/{{id}} | Delete an user from the DataBase | DELETE | 17 - | /admin/users/{{id}} | Update the user data as an admin | PUT (JSON) | 18 - | /admin/users/{{id}}/status | Update the status of a user account | PUT (JSON) | 19 - | /admin/teams | Register a new brigade, with a leader and all their members | POST (Form) | 20 - | /admin/teams | Query all registered brigades | GET | 21 - | /admin/teams/{{id}}/status | Update the status of a brigade | PUT (JSON) | 22 - | /admin/teams/{{id}} | Remove a brigade | DELETE | 23 - | /user/login | Login with your user account | POST (Form) | 24 - | /user/profile | Retrieve data about the authenticated user | GET | 25 - | /user/profile | Update your profile | PUT(JSON) | 26 - | /user/roles | Get a list of all available roles | GET | 27 - | /user/{{id}}/occurrences | Find all occurrences applied by this user | GET | 28 - | /user/{{id}}/crew_members | List fellow brigade members of this user | GET | 29 - | /user/notification_preferences | Fetch authenticated user notification preferences | GET | 30 - | /user/notification_preferences | Update authenticated user notification preferences | PUT (JSON) | 31 - | /user/password | Update authenticated user password | PUT (JSON) | 32 - | /brigade/{{id}}/members | List brigade members | GET | 33 - | /dashboard/stats | Fetch stats for the dashboard page | GET | 34 - | /analysis/occurrence | Fetch data for analysis about occurrences | GET | 35 - | /occurrence/new | Register a new occurrence | POST (Form) | 36 - | /occurrence/resolve/{{id}} | Update an occurrence `resolved_at` field | POST / DELETE | 37 - 38 - ## Entity RelationShip Diagram 39 - 40 - ```mermaid 41 - --- 42 - title: SENAC Brigade 43 - --- 44 - 45 - erDiagram 46 - 47 - user_account { 48 - UUID id PK 49 - USER_ROLE_ENUM user_role 50 - TEXT full_name 51 - TEXT password_hash 52 - TEXT registration 53 - TEXT phone 54 - TEXT email UK 55 - BOOLEAN is_active 56 - TIMESTAMP created_at 57 - TIMESTAMP updated_at 58 - } 59 - 60 - notification_preference ||--|{ user_account : preference 61 - notification_preference { 62 - UUID id PK 63 - UUID user_id FK 64 - NOTIFICATION_TYPE_ENUM notification_type 65 - BOOLEAN enabled 66 - TIMESTAMP created_at 67 - TIMESTAMP updated_at 68 - } 69 - 70 - brigade }o--|{ user_account : leader_of 71 - brigade { 72 - UUID id PK 73 - UUID leader_id FK 74 - TEXT name 75 - TEXT vehicle_code 76 - TEXT description 77 - BOOLEAN is_active 78 - TIMESTAMP created_at 79 - TIMESTAMP updated_at 80 - } 81 - 82 - brigade_membership }|--|{ user_account : is_member_of 83 - brigade_membership }|--|{ brigade : is_part_of 84 - brigade_membership { 85 - UUID id PK 86 - UUID user_id FK 87 - UUID brigade_id FK 88 - } 7 + ## Docs 89 8 90 - occurrence }o--|{ user_account : submit 91 - occurrence { 92 - UUID id PK 93 - UUID applicant_id FK 94 - OCCURRENCE_CATEGORY_ENUM category 95 - OCCURRENCE_SUBCATEGORY_ENUM subcategory 96 - TEXT description 97 - POINT location 98 - TEXT reference_point 99 - TIMESTAMP created_at 100 - TIMESTAMP updated_at 101 - TIMESTAMP resolved_at 102 - } 103 - 104 - occurrence_brigade }|--|{ brigade : assigned_to 105 - occurrence_brigade }|--|{ occurrence : assigned 106 - occurrence_brigade { 107 - UUID id PK 108 - UUID occurrence_id FK 109 - UUID brigade_id FK 110 - } 111 - ``` 112 - 113 - 114 - ## /user 115 - 116 - ### POST /user/login 117 - 118 - #### Request 119 - 120 - ```json 121 - { 122 - "matricula": "000", 123 - "senha": "wibble" 124 - } 125 - ``` 126 - 127 - #### Response 128 - 129 - `200 OK` 130 - 131 - 132 - ```json 133 - { 134 - "id": "3aedc1d9-79cc-45fe-a294-938351b9f83d", 135 - "role": "bombeiro" 136 - } 137 - ``` 138 - 139 - ### PUT /user/password 140 - 141 - #### Request 142 - 143 - ```json 144 - { 145 - "senhaAtual": "wibble", 146 - "novaSenha": "wobble", 147 - "confirmarSenha": "wobble" 148 - } 149 - ``` 150 - 151 - #### Response 152 - 153 - `200 OK` 154 - 155 - 156 - ```plaintext 157 - Senha atualizada com sucesso! 158 - ``` 9 + [Entity RelationShip Diagram](docs/db.md)\ 10 + [HTTP Endpoints](docs/routes.md)\
+74
docs/db.md
··· 1 + ## Entity RelationShip Diagram 2 + 3 + ```mermaid 4 + --- 5 + title: SENAC Brigade 6 + --- 7 + 8 + erDiagram 9 + 10 + user_account { 11 + UUID id PK 12 + USER_ROLE_ENUM user_role 13 + TEXT full_name 14 + TEXT password_hash 15 + TEXT registration 16 + TEXT phone 17 + TEXT email UK 18 + BOOLEAN is_active 19 + TIMESTAMP created_at 20 + TIMESTAMP updated_at 21 + } 22 + 23 + notification_preference ||--|{ user_account : preference 24 + notification_preference { 25 + UUID id PK 26 + UUID user_id FK 27 + NOTIFICATION_TYPE_ENUM notification_type 28 + BOOLEAN enabled 29 + TIMESTAMP created_at 30 + TIMESTAMP updated_at 31 + } 32 + 33 + brigade }o--|{ user_account : leader_of 34 + brigade { 35 + UUID id PK 36 + UUID leader_id FK 37 + TEXT name 38 + TEXT vehicle_code 39 + TEXT description 40 + BOOLEAN is_active 41 + TIMESTAMP created_at 42 + TIMESTAMP updated_at 43 + } 44 + 45 + brigade_membership }|--|{ user_account : is_member_of 46 + brigade_membership }|--|{ brigade : is_part_of 47 + brigade_membership { 48 + UUID id PK 49 + UUID user_id FK 50 + UUID brigade_id FK 51 + } 52 + 53 + occurrence }o--|{ user_account : submit 54 + occurrence { 55 + UUID id PK 56 + UUID applicant_id FK 57 + OCCURRENCE_CATEGORY_ENUM category 58 + OCCURRENCE_SUBCATEGORY_ENUM subcategory 59 + TEXT description 60 + POINT location 61 + TEXT reference_point 62 + TIMESTAMP created_at 63 + TIMESTAMP updated_at 64 + TIMESTAMP resolved_at 65 + } 66 + 67 + occurrence_brigade }|--|{ brigade : assigned_to 68 + occurrence_brigade }|--|{ occurrence : assigned 69 + occurrence_brigade { 70 + UUID id PK 71 + UUID occurrence_id FK 72 + UUID brigade_id FK 73 + } 74 + ```
+32
docs/routes.md
··· 1 + ## Table of contents 2 + 3 + [`/user`](routes/user.md) 4 + 5 + ## Overview 6 + 7 + | Route | Description | Method | 8 + | ------------------------------ | ----------------------------------------------------------- | ------------- | 9 + | /admin/setup | Create the first admin user | POST (JSON) | 10 + | /admin/signup | Register a new user account | POST (Form) | 11 + | /admin/users | List all registred users | GET | 12 + | /admin/users/{{id}} | Delete an user from the DataBase | DELETE | 13 + | /admin/users/{{id}} | Update the user data as an admin | PUT (JSON) | 14 + | /admin/users/{{id}}/status | Update the status of a user account | PUT (JSON) | 15 + | /admin/teams | Register a new brigade, with a leader and all their members | POST (Form) | 16 + | /admin/teams | Query all registered brigades | GET | 17 + | /admin/teams/{{id}}/status | Update the status of a brigade | PUT (JSON) | 18 + | /admin/teams/{{id}} | Remove a brigade | DELETE | 19 + | /user/login | Login with your user account | POST (Form) | 20 + | /user/profile | Retrieve data about the authenticated user | GET | 21 + | /user/profile | Update your profile | PUT(JSON) | 22 + | /user/roles | Get a list of all available roles | GET | 23 + | /user/{{id}}/occurrences | Find all occurrences applied by this user | GET | 24 + | /user/{{id}}/crew_members | List fellow brigade members of this user | GET | 25 + | /user/notification_preferences | Fetch authenticated user notification preferences | GET | 26 + | /user/notification_preferences | Update authenticated user notification preferences | PUT (JSON) | 27 + | /user/password | Update authenticated user password | PUT (JSON) | 28 + | /brigade/{{id}}/members | List brigade members | GET | 29 + | /dashboard/stats | Fetch stats for the dashboard page | GET | 30 + | /analysis/occurrence | Fetch data for analysis about occurrences | GET | 31 + | /occurrence/new | Register a new occurrence | POST (Form) | 32 + | /occurrence/resolve/{{id}} | Update an occurrence `resolved_at` field | POST / DELETE |
+47
docs/routes/user.md
··· 1 + ## `/user` 2 + 3 + ### `/user/login` 4 + 5 + Method: POST 6 + 7 + #### Request 8 + 9 + ```json 10 + { 11 + "matricula": "000", 12 + "senha": "wibble" 13 + } 14 + ``` 15 + 16 + #### Response 17 + 18 + `200 OK` 19 + 20 + ```json 21 + { 22 + "id": "3aedc1d9-79cc-45fe-a294-938351b9f83d", 23 + "role": "bombeiro" 24 + } 25 + ``` 26 + 27 + ### `/user/password` 28 + 29 + Method: Put 30 + 31 + #### Request 32 + 33 + ```json 34 + { 35 + "senhaAtual": "wibble", 36 + "novaSenha": "wobble", 37 + "confirmarSenha": "wobble" 38 + } 39 + ``` 40 + 41 + #### Response 42 + 43 + `200 OK` 44 + 45 + ```plaintext 46 + Senha atualizada com sucesso! 47 + ```