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