{"id":27129211,"url":"https://github.com/gotz1480/minimal-api-in-memory-db","last_synced_at":"2025-04-07T19:22:27.324Z","repository":{"id":125834392,"uuid":"525450926","full_name":"gotz1480/minimal-api-in-memory-db","owner":"gotz1480","description":"A minimal RESTful API with in-memory database","archived":false,"fork":false,"pushed_at":"2022-08-20T21:14:17.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T13:13:19.796Z","etag":null,"topics":["in-memory-database","in-memory-db","in-memory-http-server","in-memory-web-api","rest-api","restful-api"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotz1480.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-16T16:02:47.000Z","updated_at":"2022-08-20T05:55:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef53f5ef-9ebf-4515-aacb-619c98906fa2","html_url":"https://github.com/gotz1480/minimal-api-in-memory-db","commit_stats":null,"previous_names":["gotz1480/minimal-api-in-memory-db"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fminimal-api-in-memory-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fminimal-api-in-memory-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fminimal-api-in-memory-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fminimal-api-in-memory-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotz1480","download_url":"https://codeload.github.com/gotz1480/minimal-api-in-memory-db/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713455,"owners_count":20983717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["in-memory-database","in-memory-db","in-memory-http-server","in-memory-web-api","rest-api","restful-api"],"created_at":"2025-04-07T19:22:26.485Z","updated_at":"2025-04-07T19:22:27.284Z","avatar_url":"https://github.com/gotz1480.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minimal-api-in-memory-db\n\nA minimal RESTful API with in-memory database implemented via linked lists. Coded in C language using Unix websockets for networking and POSIX for multithreading.\n\n## Running on Docker\n\n### Requirements\n\n`docker` \u003cbr\u003e\n`docker compose`\n\n### Running\n\n`docker compose up --build`\n\n## Running locally (Linux)\n\n### Requirements\n\n`make` \u003cbr\u003e\n`gcc`\n\n### Running\n\n`make clean` \u003cbr\u003e\n`make`\n\n## Usage\n\nA simple \"User\" model (`models.h`) with fields \"name\" and \"surname\" is implemented in a in-memory database using linked lists. The first user starts with id = 0 and then is incremented when a new user is created. The user data in .json format can then be retrieved via its id.\n\n### Endpoints\n\nThe endpoints are defined in the `routes.h` file. The default port is 8001.\n\n`GET /` - root with \"Hello world\" message \u003cbr\u003e\n`GET /users` - lists all users in .json format \u003cbr\u003e\n`GET /users/\u003cid\u003e` - list user data by its id \u003cbr\u003e\n`PUT /users/\u003cid\u003e` - update user data by its id \u003cbr\u003e\n`DELETE /users/\u003cid\u003e` delete user by its id \u003cbr\u003e\n`POST /users` - creates a new user \u003cbr\u003e\n\n### Tests\n\nA simple Python file located in `tests/tests.py` can be used to test each endpoint.\n\n## Project structure overview\n\n### settings.h\n\nContains the server settings. Currently, the only setting is ALLOWED_HOSTS, which contains an array of strings corresponding to the accepted client IP addresses.\n\n### models.h\n\nContains the database model. On this example, the model consists of a simple \"user\" table with fields \"name\" and \"surname\". Example of an user entry in .json format:\n\n`{\"name\": \"Giga\", \"surname\": \"Chad\"}`\n\n### routes.h\n\nContains all the accepted routes and a respective accepted HTTP methods.\n\n### linked_list.h\n\nContains all functions related to the implementation of single linked lists in C, including creating a node, inserting, deleting, etc.\n\n### database.h\n\nIntegrates the requests from the HTTP methods to the linked list module, wrapping its functions and serving as a high level module.\n\n### views.h\n\nThe views related to each route and its respective HTTP methods.\n\n### server.h\n\nThis module contains functions that implement a multi-threaded server using Unix sockets.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotz1480%2Fminimal-api-in-memory-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotz1480%2Fminimal-api-in-memory-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotz1480%2Fminimal-api-in-memory-db/lists"}