{"id":22801744,"url":"https://github.com/pojntfx/chatscape","last_synced_at":"2025-08-10T02:32:00.500Z","repository":{"id":167767453,"uuid":"643383090","full_name":"pojntfx/chatscape","owner":"pojntfx","description":"Scalable serverless chat, a uni project for the HdM cloud course.","archived":true,"fork":false,"pushed_at":"2023-09-07T17:12:34.000Z","size":4590,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T19:45:49.809Z","etag":null,"topics":["aws","chat","hdm-stuttgart","iac","lambda","nextjs","serverless","terraform"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pojntfx.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}},"created_at":"2023-05-21T01:28:47.000Z","updated_at":"2024-07-12T03:20:02.000Z","dependencies_parsed_at":"2023-09-24T02:39:33.695Z","dependency_job_id":null,"html_url":"https://github.com/pojntfx/chatscape","commit_stats":null,"previous_names":["pojntfx/chatscape"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pojntfx/chatscape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pojntfx%2Fchatscape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pojntfx%2Fchatscape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pojntfx%2Fchatscape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pojntfx%2Fchatscape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pojntfx","download_url":"https://codeload.github.com/pojntfx/chatscape/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pojntfx%2Fchatscape/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269666718,"owners_count":24456421,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aws","chat","hdm-stuttgart","iac","lambda","nextjs","serverless","terraform"],"created_at":"2024-12-12T08:12:44.163Z","updated_at":"2025-08-10T02:31:59.858Z","avatar_url":"https://github.com/pojntfx.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChatScape\n\n![Logo](./docs/logo-readme.png)\n\nScalable serverless chat, a uni project for the HdM cloud course.\n\n[![hydrun CI](https://github.com/pojntfx/chatscape/actions/workflows/hydrun.yaml/badge.svg)](https://github.com/pojntfx/chatscape/actions/workflows/hydrun.yaml)\n\n## Overview\n\nChatScape is a chat application, designed as a hands-on approach to dive deep into AWS. You can find out more about the project in the [accompanying blog post](./docs/blogpost.md).\n\n## Reference\n\n### Tables\n\n#### Contacts\n\n- `id`: UUID for the contact.\n- `name`: Name of the contact.\n- `email`: Email of the contact.\n- `avatar`: URL or key to the avatar image.\n- `blocked`: Boolean indicating if the contact is blocked.\n- `namespace`: User namespace.\n- `report`: Text that a user reported for the contact\n\n#### Messages\n\n- `id`: UUID for the contact.\n- `date`: Timestamp of the message.\n- `body`: Content of the message.\n- `compositeNamespace`: Combination Namespace of the message sender and recipent.\n\n### Lambdas\n\n#### addContact\n\n- **Path**: `/add-contact`\n- **Method**: `POST`\n- **Functionality:**\n  - Read namespace from token\n  - Receive `name`, `email` in the request.\n  - Generate a unique ID for the contact.\n  - Insert the contact into the `Contacts` table.\n  - Return the created contact.\n\n#### getContacts\n\n- **Path**: `/contacts`\n- **Method**: `GET`\n- **Functionality:**\n  - Read namespace from token\n  - Query the `Contacts` table for all contacts with the namespace\n  - Return the list of contacts.\n\n#### blockContact\n\n- **Path**: `/block-contact`\n- **Method**: `POST`\n- **Functionality:**\n  - Read namespace from token\n  - Receive `contactID` from the request\n  - Update the `blocked` field for the specified contact in the `Contacts` table to true\n\n#### reportContact\n\n- **Path**: `/report-contact`\n- **Method**: `POST`\n- **Functionality:**\n  - Read namespace from token\n  - Receive `contactID` as a path parameter and `context` in the request body.\n  - Set the report field for the context to the text body received\n\n#### addMessage\n\n- **Path**: `/add-message`\n- **Method**: `POST`\n- **Functionality:**\n  - Read namespace from token\n  - Receive `contactID` and `body` in the request.\n  - Store message in the messages table, with compositeNamespace - a combination of the senderNamespace and the recipientNamespace (sender:::recipent)\n\n#### getMessages\n\n- **Path**: `/get-messages`\n- **Method**: `GET`\n- **Functionality:**\n  - Read namespace from token\n  - Receive `contactID` and `body` in the request.\n  - Fetch all messages from the database where the compositeNamespace matches (both directions: sender:::recipent and recipent:::sender)\n  - Set `them` to true on all of the messages where the senderNamespace is contactID\n  - Return the messages\n\n## Acknowledgements\n\n- [OpenTF](https://opentf.org/) provides the Terraform replacement.\n\n## Contributing\n\nTo contribute, please use the [GitHub flow](https://guides.github.com/introduction/flow/) and follow our [Code of Conduct](./CODE_OF_CONDUCT.md).\n\nTo build and start a development version of ChatScape, run the following:\n\n### 1. Setup and Deployment\n\n```shell\nexport AWS_ACCESS_KEY_ID=\"\"\nexport AWS_SECRET_ACCESS_KEY=\"\"\nexport AWS_SESSION_TOKEN=\"\"\nexport GITHUB_TOKEN=\"\"\n\nterraform -chdir=terraform init --backend-config=\"${GITHUB_TOKEN}\"\n\nmake -j$(nproc) depend\nmake -j$(nproc) test\n\n# export TF_VAR_spa_url=\"http://localhost:3000\" # Uncomment if you want to develop the frontend locally; then `cd fronted \u0026\u0026 npm run dev` to start it\nmake -j$(nproc) run\n\n# Note that if you make changes to the API gateway, you'll need to manually redeploy the API gateway from the AWS console or delete \u0026 recreate it, as Terraform does not apply the changes otherwise.\n```\n\n### 2. Authentication\n\n```shell\nexport REGION=\"eu-north-1\"\n\n# You can get these values from the Terraform outputs\nexport API_URL=\"https://fwohuebd3j.execute-api.eu-north-1.amazonaws.com/test\"\nexport USER_POOL_ID=\"eu-north-1_zqBirZPN9\"\nexport CLIENT_ID=\"b2l5g1ro6ps7akfvjv2pd1tvn\"\n\n# Create first user\nexport USERNAME=\"chatscape-tester-1@example.com\"\nexport PASSWORD=\"Your-password1/\"\n\naws cognito-idp sign-up --region ${REGION} --client-id ${CLIENT_ID} --username ${USERNAME} --password ${PASSWORD}\naws cognito-idp admin-confirm-sign-up --user-pool-id ${USER_POOL_ID} --region ${REGION} --username ${USERNAME}\n\nexport API_TOKEN=$(aws cognito-idp admin-initiate-auth --user-pool-id ${USER_POOL_ID} --client-id ${CLIENT_ID} --auth-flow ADMIN_USER_PASSWORD_AUTH --auth-parameters USERNAME=${USERNAME},PASSWORD=${PASSWORD} | jq -r '.AuthenticationResult.IdToken')\n\n# Create second user\nexport USERNAME=\"chatscape-tester-2@example.com\"\nexport PASSWORD=\"Your-password2/\"\n\naws cognito-idp sign-up --region ${REGION} --client-id ${CLIENT_ID} --username ${USERNAME} --password ${PASSWORD}\naws cognito-idp admin-confirm-sign-up --user-pool-id ${USER_POOL_ID} --region ${REGION} --username ${USERNAME}\n\nexport API_TOKEN=$(aws cognito-idp admin-initiate-auth --user-pool-id ${USER_POOL_ID} --client-id ${CLIENT_ID} --auth-flow ADMIN_USER_PASSWORD_AUTH --auth-parameters USERNAME=${USERNAME},PASSWORD=${PASSWORD} | jq -r '.AuthenticationResult.IdToken')\n```\n\n### 3. Integration Tests\n\n**add-contact**: `{\"email\":\"max@mustermann.de\", \"name\":\"max\"}`\n\n```shell\ncurl -X POST --data '{\"email\":\"max@mustermann.de\", \"name\":\"max\"}' -H \"Authorization: Bearer ${API_TOKEN}\" \"${API_URL}/add-contact\"\n```\n\n**block-contact**: `{\"email\":\"max@mustermann.de\"}`\n\n```shell\ncurl -X POST --data '{\"email\":\"max@mustermann.de\"}' -H \"Authorization: Bearer ${API_TOKEN}\" \"${API_URL}/block-contact\"\n```\n\n**report-contact**: `{\"email\":\"max@mustermann.de\", \"report\":\"Met at a diner\"}`\n\n```shell\ncurl -X POST --data '{\"email\":\"max@mustermann.de\", \"report\":\"Met at a diner\"}' -H \"Authorization: Bearer ${API_TOKEN}\" \"${API_URL}/report-contact\"\n```\n\n**get-contacts**:\n\n```shell\ncurl -H \"Authorization: Bearer ${API_TOKEN}\" \"${API_URL}/get-contacts\"\n```\n\n**add-message**: `{\"recipientNamespace\":\"mate\", \"message\": \"Hi\"}`\n\n```shell\ncurl -X POST --data '{\"recipientNamespace\":\"mate\", \"message\": \"Hi\"}' -H \"Authorization: Bearer ${API_TOKEN}\" \"${API_URL}/add-message\"\n```\n\n**get-messages**: `?recipientNamespace=mate`\n\n```shell\ncurl -H \"Authorization: Bearer ${API_TOKEN}\" \"${API_URL}/get-messages?recipientNamespace=mate\"\n```\n\n## License\n\nChatScape (c) 2023 Felicitas Pojtinger and contributors\n\nSPDX-License-Identifier: AGPL-3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpojntfx%2Fchatscape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpojntfx%2Fchatscape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpojntfx%2Fchatscape/lists"}