|
1 | | -> Warning: You should probably not use this in production or with any data that is sensitive as the authentication |
2 | | -> system |
3 | | -> is made very amateurish. |
| 1 | +Absolutely! Below is an enhanced version of your documentation, incorporating your additional requests: |
4 | 2 |
|
5 | | -# Cira - a minimalistic ticket system backend |
| 3 | +--- |
6 | 4 |
|
7 | | -Cira is a minimalistic ticket system backend for small and simple projects. |
8 | | -You could even use it as an overcomplicated todo app. |
| 5 | +# Cira - A Minimalistic Ticket System Backend |
9 | 6 |
|
10 | | -The only thing it does is to provide an api. |
11 | | -The rest is up to you. |
12 | | -Create a native desktop or smartphone app, or keep in the web as most ticket boards to. |
13 | | -You decide, the possibilities are endless. |
| 7 | +Cira is a minimalistic backend for managing tickets in small projects. It provides essential APIs to handle ticket creation, updates, deletion, labeling, assignment, and filtering. |
14 | 8 |
|
15 | | -## Features |
| 9 | +## Overview |
| 10 | +Cira offers foundational API functionalities for managing tickets including: |
| 11 | +- Creation and deletion of tickets |
| 12 | +- Updating existing tickets |
| 13 | +- Grouping tickets by labels |
| 14 | +- Assigning tickets to users |
| 15 | +- Filtering tickets by various criteria |
| 16 | +- User authentication via bearer tokens |
16 | 17 |
|
17 | | -Cira gives you the foundation to: |
| 18 | +## Setup & Usage |
18 | 19 |
|
19 | | -- create and delete tickets |
20 | | -- update tickets after creation |
21 | | -- group tickets by labels |
22 | | -- assign tickets to users |
23 | | -- filter tickets by labels, assignee, status and labels |
24 | | -- authentication with bearer tokens |
| 20 | +### Prerequisites |
| 21 | +Ensure you have installed the following tools: |
| 22 | +- [Rust](https://rust-lang.org) |
| 23 | +- [Git](https://git-scm.com/) |
| 24 | +- [Diesel](https://diesel.rs) |
| 25 | +- [SQLite](https://www.sqlite.org/) |
25 | 26 |
|
26 | | -## Run Locally |
| 27 | +### Running Locally |
27 | 28 |
|
28 | | -Simply clone the repository, set up the database and compile the application locally. |
29 | | -Then start it. |
30 | | -You are required to have installed: [the rust programming language](https://rust-lang.org), |
31 | | -[git](https://git-scm.com/), [diesel](https://diesel.rs), [sqlite](https://www.sqlite.org/) |
| 29 | +1. **Clone the repository**: |
| 30 | + ```bash |
| 31 | + git clone https://github.com/CodeF0x/cira.git |
| 32 | + cd cira |
| 33 | + ``` |
| 34 | +2. **Install Diesel CLI for SQLite** and set up database: |
| 35 | + ```bash |
| 36 | + cargo install diesel_cli --no-default-features --features "sqlite" |
| 37 | + diesel setup |
| 38 | + ``` |
| 39 | +3. **Build and run**: |
| 40 | + ```bash |
| 41 | + cargo build --release |
| 42 | + ./target/release/cira |
| 43 | + ``` |
32 | 44 |
|
33 | | -```bash |
34 | | -git clone https://github.com/CodeF0x/cira.git |
35 | | -cd cira |
36 | | -cargo install diesel_cli --no-default-features --features "sqlite" |
37 | | -diesel setup |
38 | | -cargo build --release |
39 | | -./target/release/cira |
40 | | -``` |
41 | | - |
42 | | -If you're on Debian and get `error: linking with 'cc' failed: exit status: 1`, make sure to have `build-essential` |
43 | | -installed. Same goes for other distros (build-essential might be called different / have an equivalent). |
44 | | - |
45 | | -If this error accours while installing `diesel_cli`, try `sudo apt install -y libsqlite3-dev libpq-dev libmysqlclient-dev`. |
| 45 | +**Note**: Make sure to update both `HASH_SECRET` and `JWT_SECRET` in the `.env` file with cryptographically secure values! |
46 | 46 |
|
47 | | -There are some default values set in the .env file, you can adjust them as you wish. |
48 | | -Keep in mind to change the code as well. |
49 | | -> ⚠️ Be sure to update both `HASH_SECRET` and `JWT_SECRET` to something cryptographically safe! |
| 47 | +### Troubleshooting |
50 | 48 |
|
51 | | -If everything went well and there is no output after running the last command, cira is listening on port `8080`. |
| 49 | +If you encounter errors during installation or setup: |
| 50 | +- On Debian, if you get a `linking with 'cc' failed: exit status: 1` error, ensure `build-essential` is installed. |
| 51 | +- For issues while installing Diesel CLI, try running: `sudo apt install -y libsqlite3-dev libpq-dev libmysqlclient-dev`. |
52 | 52 |
|
53 | | -You can also launch it in a screen or in a container, so it runs without an active shell session. |
| 53 | +--- |
54 | 54 |
|
55 | | -## Running Tests |
| 55 | +## API Documentation |
56 | 56 |
|
57 | | -To run tests, set up a fake database that is independent of the actual production database. |
58 | | -You need to have installed [diesel](https://diesel.rs), [sqlite](https://www.sqlite.org/) and [rust](https://rust-lang.org). |
| 57 | +### General Information |
| 58 | +- **Authorization**: Every endpoint requires a Bearer Token for authentication except the endpoints related to user login and signup (`/api/login` and `/api/signup`). |
59 | 59 |
|
60 | | -```bash |
61 | | -diesel migration run --database-url test-backend.sqlite |
62 | | -cargo test |
63 | | -``` |
64 | | - |
65 | | -## API Reference |
| 60 | +### Ticket Management |
66 | 61 |
|
67 | | -#### Create a new ticket |
| 62 | +#### Create a New Ticket |
68 | 63 |
|
69 | 64 | ```http |
70 | | - POST /api/tickets |
| 65 | +POST /api/tickets |
71 | 66 | ``` |
72 | 67 |
|
73 | | -Your payload must be valid JSON and contain the following properties: |
| 68 | +**Payload**: |
74 | 69 |
|
75 | 70 | | Property | Type | Description | |
76 | 71 | |:----------------|:----------------|:------------------------------------------------------------------------------| |
77 | | -| `title` | `string` | **Required**. The title of your ticket | |
78 | | -| `body` | `string` | **Required**. The body of your ticket | |
79 | | -| `labels` | `Array<string>` | **Required**. Labels of your ticket | |
80 | | -| `status` | `string` | **Required**. The status of your ticket (set it to "Open") | |
81 | | -| `assigned_user` | `id \| null` | **Optional**. A user the ticket should be assigned to. Can be omitted or null | |
| 72 | +| `title` | `string` | **Required**. Title of the ticket | |
| 73 | +| `body` | `string` | **Required**. Body content of the ticket | |
| 74 | +| `labels` | `Array<string>` | **Required**. Labels for categorizing the ticket | |
| 75 | +| `status` | `string` | **Required**. Status (e.g., 'Open') | |
| 76 | +| `assigned_user` | `id \| null` | **Optional**. ID of user assigned to this ticket or `null`. | |
82 | 77 |
|
83 | | -Possible Status options: |
| 78 | +**Status Options**: |
84 | 79 |
|
85 | | -- `Open` |
86 | | -- `Closed` |
| 80 | +- Open |
| 81 | +- Closed |
87 | 82 |
|
88 | | -Possible Label options: |
| 83 | +**Label Options**: |
89 | 84 |
|
90 | | -- `Feature` |
91 | | -- `Bug` |
92 | | -- `WontFix` |
93 | | -- `Done` |
94 | | -- `InProgress` |
| 85 | +- Feature |
| 86 | +- Bug |
| 87 | +- WontFix |
| 88 | +- Done |
| 89 | +- InProgress |
95 | 90 |
|
96 | | -Creates a new ticket and returns it. |
| 91 | +#### Get All Tickets |
97 | 92 |
|
98 | | -#### Get tickets |
| 93 | +```http |
| 94 | +GET /api/tickets |
| 95 | +``` |
| 96 | + |
| 97 | +Retrieves all tickets. |
| 98 | + |
| 99 | +#### Delete a Ticket |
99 | 100 |
|
100 | 101 | ```http |
101 | | - GET /api/tickets |
| 102 | +DELETE /api/tickets/{id} |
102 | 103 | ``` |
103 | 104 |
|
104 | | -Get all tickets. |
| 105 | +**Path Parameters**: |
105 | 106 |
|
106 | | -#### Delete ticket |
| 107 | +| Parameter | Type | Description | |
| 108 | +|:----------|:-------|:-----------------------------------| |
| 109 | +| `id` | number | **Required**. ID of the ticket | |
| 110 | + |
| 111 | +#### Edit a Ticket |
107 | 112 |
|
108 | 113 | ```http |
109 | | - DELETE /api/tickets/{id} |
| 114 | +PUT /api/tickets/{id} |
110 | 115 | ``` |
111 | 116 |
|
112 | | -URL parameters: |
| 117 | +**Path Parameters**: (Same as Delete Ticket) |
113 | 118 |
|
114 | | -| Property | Type | Description | |
115 | | -|:---------|:---------|:-----------------------------------| |
116 | | -| `id` | `number` | **Required**. The id of the ticket | |
| 119 | +**Payload**: (Same structure as Create a New Ticket) |
117 | 120 |
|
118 | | -Deletes a ticket and returns it. |
| 121 | +### User Authentication |
119 | 122 |
|
120 | | -#### Edit a ticket |
| 123 | +#### Sign Up |
121 | 124 |
|
122 | 125 | ```http |
123 | | - PUT /api/tickets/{id} |
| 126 | +POST /api/signup |
124 | 127 | ``` |
125 | 128 |
|
126 | | -URL parameters: |
| 129 | +**Payload**: |
127 | 130 |
|
128 | | -| Property | Type | Description | |
129 | | -|:---------|:---------|:-----------------------------------| |
130 | | -| `id` | `number` | **Required**. The id of the ticket | |
| 131 | +| Property | Type | Description | |
| 132 | +|:---------------|:-------|:---------------------------------------| |
| 133 | +| `display_name` | string | **Required**. Display name | |
| 134 | +| `email` | string | **Required**. Email address | |
| 135 | +| `password` | string | **Required**. Password | |
131 | 136 |
|
132 | | -Your payload must be valid JSON and contain the following properties: |
| 137 | +#### Login |
133 | 138 |
|
134 | | -| Property | Type | Description | |
135 | | -|:----------------|:----------------|:------------------------------------------------------------------------------| |
136 | | -| `title` | `string` | **Required**. The title of your ticket | |
137 | | -| `body` | `string` | **Required**. The body of your ticket | |
138 | | -| `labels` | `Array<string>` | **Required**. Labels of your ticket | |
139 | | -| `status` | `string` | **Required**. The status of your ticket (set it to "Open") | |
140 | | -| `assigned_user` | `id \| null` | **Optional**. A user the ticket should be assigned to. Can be omitted or null | |
| 139 | +```http |
| 140 | +POST /api/login |
| 141 | +``` |
141 | 142 |
|
142 | | -Possible Status options: |
| 143 | +**Payload**: |
143 | 144 |
|
144 | | -- `Open` |
145 | | -- `Closed` |
| 145 | +| Property | Type | Description | |
| 146 | +|:----------|:-------|:---------------------------------------| |
| 147 | +| `email` | string | **Required**. Email address | |
| 148 | +| `password` | string | **Required**. Password | |
146 | 149 |
|
147 | | -Possible Label options: |
| 150 | +Returns a bearer token upon successful login. |
148 | 151 |
|
149 | | -- `Feature` |
150 | | -- `Bug` |
151 | | -- `WontFix` |
152 | | -- `Done` |
153 | | -- `InProgress` |
| 152 | +#### Logout |
154 | 153 |
|
155 | | -Updates a ticket and returns it. |
| 154 | +```http |
| 155 | +POST /api/logout |
| 156 | +``` |
156 | 157 |
|
157 | | -#### Sign up |
| 158 | +Logs out the user by invalidating their current token. |
158 | 159 |
|
159 | | -``` |
160 | | - POST /api/signup |
161 | | -``` |
| 160 | +### User Management |
162 | 161 |
|
163 | | -Your payload must be valid JSON and contain the following properties: |
| 162 | +#### Get All Users |
164 | 163 |
|
165 | | -| Property | Type | Description | |
166 | | -|:---------------|:---------|:---------------------------------------| |
167 | | -| `display_name` | `string` | **Required**. The user's display name | |
168 | | -| `email` | `string` | **Required**. The user's email address | |
169 | | -| `password` | `string` | **Required**. The user's password | |
| 164 | +```http |
| 165 | +GET /api/users |
| 166 | +``` |
170 | 167 |
|
171 | | -Create a new user and return it. |
| 168 | +Retrieves all users in a simplified format (`id`, `email`, `display_name`). |
172 | 169 |
|
173 | | -#### Filter tickets |
| 170 | +### Filter Tickets |
174 | 171 |
|
175 | 172 | ```http |
176 | | - POST /api/filter |
| 173 | +POST /api/filter |
177 | 174 | ``` |
178 | 175 |
|
179 | | -Your payload must be valid JSON and contain the following properties: |
| 176 | +**Payload**: |
180 | 177 |
|
181 | 178 | | Property | Type | Description | |
182 | 179 | |:----------------|:------------------------|:----------------------------------------------------------------| |
183 | 180 | | `title` | `string \| null` | **Optional**. Title to search for. Can be omitted or null | |
184 | 181 | | `labels` | `Array<string> \| null` | **Optional**. Labels to search for. Can be omitted or null | |
185 | 182 | | `status` | `string \| null` | **Optional**. Status to search for. Can be omitted or null | |
186 | | -| `assigned_user` | `id \| null` | **Optional**. Assignee id to search for. Can be omitted or null | |
| 183 | +| `assigned_user` | `id \| null` | **Optional**. Assignee ID to search for. Can be omitted or null | |
187 | 184 |
|
188 | | -Lets you filter for tickets and return results. |
| 185 | +Returns filtered results. |
| 186 | + |
| 187 | +--- |
189 | 188 |
|
190 | 189 | ## Contributing |
191 | 190 |
|
192 | | -Contributions are always welcome! |
| 191 | +Contributions in any form (issues, PRs, feedback) are welcome! |
193 | 192 |
|
194 | | -Either by submitting issues, pull requests or just general constructive feedback in the form of issues, |
195 | | -emails or direct messages on Telegram. |
| 193 | +--- |
196 | 194 |
|
197 | 195 | ## License |
198 | 196 |
|
199 | 197 | [MIT](https://choosealicense.com/licenses/mit/) |
200 | | - |
201 | | -MIT or "I do not care what you do with this as long as you don't claim it to be your own"-license. |
0 commit comments