# doorman-api The backend API for Doorman. It is resposible for managing Door state, configuring Door options and sending Discord Notifications. ## dependency services The Doorman API has hard dependencies: - DynamoDB - Discord (notify, edit, and onboarding) - Cloudflare (only in Production) - Twilio Functions (deployed compute in staging / prod) It has some soft dependencies on other services, mostly self hosted monitoring solutions: - Pushgateway (prometheus metrics) - Loki (logs) ## running locally First install the necessary dependencies `bun install`. When running locally, Doorman API will use [DynamoDBLocal](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html) You will likely need java installed on your machine and in your path in order for DynamoDBLocal to work. To run the dev server: `bun run start:local-db` On startup, the main "doorman" DDB table is created and seeded with the a test Door. Note: DynamoDBLocal is configured to use in memory store only, so any changes will not persist when you exit the command. The API will run on port 8080 and DynamoDBLocal will use port 5000. You can verify the seeding worked by calling `http://localhost:8080/api/door/info?door=test` If you need to test Discord or against real DDB, you should set those env vars in your environment in a seperate .env file and source it before running ## troubleshooting ### Port 5000 is already in use after restarting server When exiting `bun run start:local-db`, we try to close the previous DDB local run, though this is best efforts it may have failed to close the child process. You can manually find and kill the forked process as follows: ``` ps -ef | grep DynamoDBLocal martin 243091 243061 93 17:57 pts/4 00:00:13 java -Xrs -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -port 5000 -inMemory kill 243091 ``` or if you want to kill all java processes (likely only this DDB local thing) `kill $(pidof java)` ## deployment this project deploys the UI and API to twilio functions https://doorman-6741-prod.twil.io It uses DDB for the backend After the twilio functions I have setup a cloudflare worker at https://doorman.chromart.cc to proxy the requests to the twilio lambda The cloudflare worker just proxies requests so the endpoint is a bit nicer