{"id":40203012,"url":"https://github.com/akashsharma99/passbook-app-backend","last_synced_at":"2026-01-19T20:33:34.111Z","repository":{"id":229512712,"uuid":"776767049","full_name":"akashsharma99/passbook-app-backend","owner":"akashsharma99","description":"contains backend api code for passbook app","archived":false,"fork":false,"pushed_at":"2025-05-21T18:56:46.000Z","size":96,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-21T19:46:55.375Z","etag":null,"topics":["api","backend","golang","pgx","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akashsharma99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-03-24T12:42:00.000Z","updated_at":"2025-05-21T18:56:55.000Z","dependencies_parsed_at":"2024-04-06T13:29:40.663Z","dependency_job_id":"ad70ee09-3443-46a2-8692-02db6123a296","html_url":"https://github.com/akashsharma99/passbook-app-backend","commit_stats":null,"previous_names":["akashsharma99/passbook-app-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/akashsharma99/passbook-app-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akashsharma99%2Fpassbook-app-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akashsharma99%2Fpassbook-app-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akashsharma99%2Fpassbook-app-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akashsharma99%2Fpassbook-app-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akashsharma99","download_url":"https://codeload.github.com/akashsharma99/passbook-app-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akashsharma99%2Fpassbook-app-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28583863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T19:46:29.903Z","status":"ssl_error","status_checked_at":"2026-01-19T19:45:54.560Z","response_time":67,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","backend","golang","pgx","postgresql"],"created_at":"2026-01-19T20:33:34.035Z","updated_at":"2026-01-19T20:33:34.094Z","avatar_url":"https://github.com/akashsharma99.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"` 23-03-2024 `\n\n# Passbook App API\n\nAPI using golang for the passbook app [frontend](https://github.com/akashsharma99/passbook-app-web)\n\nclick [here](NOTES.md) for entity and functional requirement list.\n\nbase URL: `http://api.domain.app/v1/`\n\n## Docker steps\n\nTo run the app in docker container follow the steps below:\n\n1. Build the docker image using multistage dockerfile that will build the go binary and then copy it to a smaller image for running the app.\n```bash\ndocker build -t passbook-app-backend -f Dockerfile.multistage . \n```\n2. Run the image in a docker container and pass the .env file as an environment file.\n```bash\ndocker run -p 8080:8080 -d --env-file dev.env passbook-app-backend\n```\nTo view the logs of the running container use the command below:\n```bash\ndocker logs -f \u003ccontainer_name\u003e\n```\n## Local run without docker\n\nTo run the app locally without docker you need to set PASSBOOK_ENV=DEV so that the code reads the dev.env file for environment variables.\n```bash\nPASSBOOK_ENV=DEV CGO_ENABLED=0 go run cmd/passbook-app/main.go\n```\n\nAll above commands are also present in the makefile. You can run the commands using `make` command.\n\n\n## Authentication\n\n```\nAuthorization: Bearer \u003ctoken\u003e\n```\n\n## Generic Responses\n\n### Success Response\n\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"success message\",\n    \"data\": {},\n    \"meta\": {\n        \"total_pages\": 100,\n        \"page\": 1,\n        \"limit\": 10\n    }\n}\n```\n\n### Error Response\n\n```json\n{\n    \"status\": \"error\",\n    \"message\": \"error message\",\n    \"data\": {},\n    \"meta\": {}\n}\n```\n## Auth Endpoints\n\n\n#### `POST /auth/register` - Register User\n\n**Request**\n\n```json\n{\n    \"username\": \"john_doe\",\n    \"email\": \"john.doe@email.com\",\n    \"password\": \"password\"\n}\n```\n**Responses**\n- 201: User created successfully\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"User created successfully\",\n    \"data\": {\n        \"username\": \"john_doe\",\n        \"email\": \"john_doe@email.com\"\n    }\n}\n```\n- 400: Validation error\n- 409: User already exists\n- 500: Internal failures\n\n#### `POST /auth/login` - Login User\n\n**Request**\n\n```json\n{\n    \"username\": \"john.doe\",\n    \"password\": \"password\"\n}\n```\n**Responses**\n- 401: Unauthorized\n- 200: User logged in successfully\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"User logged in successfully\",\n    \"data\":{\n        \"access_token\": \"jwt_token\",\n        \"user\": {\n            \"username\": \"john_doe\",\n            \"email\": \"john.doe@email.com\"\n        }\n    }\n}\n```\n\u003e Use `access_token` in Authorization header for further requests. The `refresh_token` is part of a secure httpOnly cookie sent by the server. Both tokens are jwt tokens. The `access_token` is short-lived (15 minutes) and the `refresh_token` is long-lived (24 hours).\n\n**jwt token payload**\n```json\n{\n  \"userId\": \"a7437e4e-a898-4c17-b96e-acf32754ae6e\", // uuid\n  \"exp\": 1711901181,// expiry time\n  \"iat\": 1711814781 // issued at\n}\n```\n\n#### `POST /auth/refresh` - Refresh access token\n\nExpected to be called when the access token is expired. The refresh should be present in the http-only cookie of the request headers.\n\n**Responses**\n- 400: Bad request (missing refresh token in cookie)\n- 401: Unauthorized (invalid refresh token)\n- 500: Internal failures\n- 200: Access token refreshed successfully\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"Token refreshed successfully\",\n    \"data\": {\n        \"access_token\": \"jwt_token\"\n    }\n}\n```\nAlso as part of token rotation strategy, the server will send a new refresh token in the http-only cookie.\nFor more info on how refresh tokens work I would suggest reading [this](https://auth0.com/blog/refresh-tokens-what-are-they-and-when-to-use-them/) article by Auth0 team.\n\n## User Endpoints\n\n\u003e All endpoints marked with the 🔒 symbol require you to pass the access_token as a Bearer token in Authorization header.\n\n#### `GET /users/me` 🔒 - Get User Profile\n```bash\ncurl -X GET http://api.domain.app/v1/users/me -H \"Authorization : Bearer \u003ctoken\u003e\"\n```\n\n## Passbook Endpoints\n\n#### `POST /passbooks` 🔒 - Create Passbook\n\n**Request**\n\n```json\n{\n    \"bank_name\": \"Bank of Zelda\",\n    \"account_number\": \"123512\",\n    \"total_balance\": 1024.45,\n    \"nickname\": \"salary\"\n}\n```\n**Responses**\n- 201: Passbook created successfully\n```json\n{\n    \"data\": {\n        \"passbook\": {\n            \"passbook_id\": \"217c0dc1-cd9a-4562-825c-376b0da8a96e\",\n            \"user_id\": \"3aaff7dd-91f3-4eab-8b26-b4ddbe68e5a5\",\n            \"bank_name\": \"Bank of Zelda\",\n            \"account_number\": \"123512\",\n            \"total_balance\": 1024.45,\n            \"nickname\": \"salary\",\n            \"created_at\": \"2024-04-02T00:22:09.134347+05:30\",\n            \"updated_at\": \"2024-04-02T00:22:09.134347+05:30\"\n        }\n    },\n    \"status\": \"success\"\n}\n```\n- 400: Validation errors or account already exists\n- 500: Internal failures\n\n#### `GET /passbooks` 🔒 - Get All Passbooks created by logged in user\n\n**Responses**\n- 200: Passbooks fetched successfully\n```json\n{\n    \"data\": {\n        \"passbooks\": [\n            {\n                \"passbook_id\": \"217c0dc1-cd9a-4562-825c-376b0da8a96e\",\n                \"user_id\": \"3aaff7dd-91f3-4eab-8b26-b4ddbe68e5a5\",\n                \"bank_name\": \"Bank of Zelda\",\n                \"account_number\": \"123512\",\n                \"total_balance\": 1024.45,\n                \"nickname\": \"salary\",\n                \"created_at\": \"2024-04-02T00:22:09.134347+05:30\",\n                \"updated_at\": \"2024-04-02T00:22:09.134347+05:30\"\n            },\n            {\n                \"passbook_id\": \"2aaff5dd-61f3-4eab-8b26-b4ddbe68e5a5\",\n                \"user_id\": \"3aaff7dd-91f3-4eab-8b26-b4ddbe68e5a5\",\n                \"bank_name\": \"Bowser Bank\",\n                \"account_number\": \"900000123512\",\n                \"total_balance\": 1221024.45,\n                \"nickname\": \"savings\",\n                \"created_at\": \"2024-04-02T00:22:09.134347+05:30\",\n                \"updated_at\": \"2024-04-02T00:22:09.134347+05:30\"\n            }\n        ]\n    },\n    \"status\": \"success\"\n}\n```\n#### `GET /passbooks/:passbook_id` 🔒 - Get Passbook\n\n**Responses**\n- 200: Passbook fetched successfully\n```json\n{\n    \"data\": {\n        \"passbook\": {\n            \"passbook_id\": \"217c0dc1-cd9a-4562-825c-376b0da8a96e\",\n            \"user_id\": \"3aaff7dd-91f3-4eab-8b26-b4ddbe68e5a5\",\n            \"bank_name\": \"Bank of Zelda\",\n            \"account_number\": \"123512\",\n            \"total_balance\": 1024.45,\n            \"nickname\": \"salary\",\n            \"created_at\": \"2024-04-02T00:22:09.134347+05:30\",\n            \"updated_at\": \"2024-04-02T00:22:09.134347+05:30\"\n        }\n    },\n    \"status\": \"success\"\n}\n```\n- 404: Passbook not found\n- 500: Internal failures\n\n#### `DELETE /passbooks/:passbook_id` 🔒 - Delete Passbook\n**Responses**\n- 404: Passbook not found\n- 200: Passbook deleted successfully\n```json\n{\n    \"status\": \"success\",\n    \"message\": \"Passbook deleted successfully\"\n}\n```\n#### `PATCH /passbooks/:passbook_id` 🔒 - Update Passbook\n**Request**\n\n```json\n{\n    \"passbook_id\": \"217c0dc1-cd9a-4562-825c-376b0da8a96e\",\n    \"user_id\": \"3aaff7dd-91f3-4eab-8b26-b4ddbe68e5a5\",\n    \"bank_name\": \"Bank of Zelda\",\n    \"account_number\": \"123512\",\n    \"total_balance\": 2024.45,\n    \"nickname\": \"salary old\"\n}\n```\n**Responses**\n\n- 200: Passbook updated successfully\n```json\n{\n    \"passbook_id\": \"217c0dc1-cd9a-4562-825c-376b0da8a96e\",\n    \"user_id\": \"3aaff7dd-91f3-4eab-8b26-b4ddbe68e5a5\",\n    \"bank_name\": \"Bank of Zelda\",\n    \"account_number\": \"123512\",\n    \"total_balance\": 2024.45,\n    \"nickname\": \"salary old\",\n    \"created_at\": \"2024-04-02T00:22:09.134347+05:30\",\n    \"updated_at\": \"2024-05-22T01:02:09.134347+05:30\"\n}\n```\n- 404: Passbook not found\n- 403: Forbidden if user_id on reqeust body and token user_id do not match\n- 500: Internal failures\n\n## Transaction Endpoints\n\n#### `GET /passbooks/:passbook_id/transactions` 🔒 - Get All Transactions paginated\n- Query params\n    - page: 1\n    - limit: 10\n    - party_name: \"Aditya Gupta\"\n    - tags: \"fun,dividend\"\n    - type: \"CREDIT\"\n\n**Responses**\n- 200: Transactions fetched successfully\n```json\n{\n    \"status\": \"success\",\n    \"code\": 200,\n    \"message\": \"Transactions fetched successfully\",\n    \"data\": [\n        {\n            \"amount\": 1500.00,\n            \"transaction_date\": \"2023-12-31T14:48:00.000Z\",\n            \"type\": \"CREDIT\",\n            \"party_name\": \"Aditya Gupta\",\n            \"description\": \"ice cream contribution\",\n            \"tags\": \"vacation,food,fun\"\n        },\n        {\n            \"amount\": 2000.00,\n            \"transaction_date\": \"2023-12-31T15:48:00.000Z\",\n            \"type\": \"DEBIT\",\n            \"party_name\": \"TCS\",\n            \"description\": \"dividend from stocks\",\n            \"tags\": \"stocks,dividend\"\n        }\n    ],\n    \"meta\": {\n        \"total_pages\": 100,\n        \"page\": 1,\n        \"limit\": 10\n    }\n}\n```\n\n#### `POST /passbooks/:passbook_id/transactions` 🔒 - Add Transaction\n\n**Request**\n\n```json\n{\n    \"amount\": 100.00,\n    \"transaction_date\": \"2023-12-31T14:48:00.000Z\",\n    \"transaction_type\": \"CREDIT\",\n    \"party_name\": \"Aditya Gupta\",\n    \"description\": \"ice cream contribution\",\n    \"tags\": \"vacation,food,fun\"\n}\n```\n**Responses**\n- 201: Transaction added successfully\n- 400: Validation error\n\n#### `GET /passbooks/:passbook_id/transactions/:transaction_id` 🔒 - Get Transaction\n#### `PATCH /passbooks/:passbook_id/transactions/:transaction_id` 🔒 - Update Transaction\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakashsharma99%2Fpassbook-app-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakashsharma99%2Fpassbook-app-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakashsharma99%2Fpassbook-app-backend/lists"}