{"id":29633792,"url":"https://github.com/pramodbharti/cashcard","last_synced_at":"2026-05-07T13:38:01.089Z","repository":{"id":304917019,"uuid":"989655303","full_name":"pramodbharti/cashcard","owner":"pramodbharti","description":"A RESTful API for managing cash cards built with Spring Boot and Kotlin. This application demonstrates Test-Driven Development (TDD) principles and implements a secure API for creating, reading, updating, and deleting cash cards.","archived":false,"fork":false,"pushed_at":"2025-07-16T02:27:00.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-17T04:56:53.083Z","etag":null,"topics":["assert","junit","kotlin","monolith","rest-api","restful-api","spring-boot","spring-data-jpa","spring-mvc","spring-security","tdd","test"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/pramodbharti.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":"2025-05-24T14:51:22.000Z","updated_at":"2025-07-16T02:27:03.000Z","dependencies_parsed_at":"2025-07-17T09:54:37.822Z","dependency_job_id":"57be62c8-3850-427f-ad40-0c150336cc62","html_url":"https://github.com/pramodbharti/cashcard","commit_stats":null,"previous_names":["pramodbharti/cashcard"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pramodbharti/cashcard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pramodbharti%2Fcashcard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pramodbharti%2Fcashcard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pramodbharti%2Fcashcard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pramodbharti%2Fcashcard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pramodbharti","download_url":"https://codeload.github.com/pramodbharti/cashcard/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pramodbharti%2Fcashcard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32740657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["assert","junit","kotlin","monolith","rest-api","restful-api","spring-boot","spring-data-jpa","spring-mvc","spring-security","tdd","test"],"created_at":"2025-07-21T15:00:17.162Z","updated_at":"2026-05-07T13:38:01.083Z","avatar_url":"https://github.com/pramodbharti.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cash Card API\n\nA RESTful API for managing cash cards built with Spring Boot and Kotlin. This application demonstrates Test-Driven Development (TDD) principles and implements a secure API for creating, reading, updating, and deleting cash cards.\n\n## Features\n\n- CRUD operations for cash cards (Create, Read, Update, Delete)\n- Role-based access control\n- User-specific data isolation (users can only access their own cards)\n- Pagination and sorting for listing cash cards\n- RESTful API design\n- Comprehensive test coverage\n\n## Prerequisites\n\n- Java 21 or higher\n- Gradle 8.x or higher\n- An IDE that supports Kotlin and Spring Boot (IntelliJ IDEA recommended)\n\n## Technologies Used\n\n- **Kotlin 1.9.25**: Modern, concise JVM language\n- **Spring Boot 3.4.5**: Framework for building production-ready applications\n- **Spring Security**: Authentication and authorization\n- **Spring Data JDBC**: Simplified data access layer\n- **H2 Database**: In-memory database for development and testing\n- **JUnit 5**: Testing framework\n- **AssertJ**: Fluent assertions for testing\n- **Jackson**: JSON serialization/deserialization\n\n## Architecture\n\nThe application follows a layered architecture:\n\n1. **Controller Layer**: Handles HTTP requests and responses\n2. **Service Layer**: Contains business logic and coordinates between controllers and repositories\n3. **Repository Layer**: Manages data access\n4. **Model Layer**: Defines the data structure\n\nThe application uses Spring Security for authentication and authorization, ensuring that users can only access their own cash cards.\n\n## Folder Structure\n\n```\nsrc\n├── main\n│   ├── kotlin\n│   │   └── com\n│   │       └── db\n│   │           └── cashcard\n│   │               ├── CashCard.kt                 # Data model\n│   │               ├── CashCardApplication.kt      # Application entry point\n│   │               ├── CashCardController.kt       # REST controller\n│   │               ├── CashCardRepository.kt       # Data repository\n│   │               ├── CashCardService.kt          # Service interface\n│   │               ├── CashCardServiceImpl.kt      # Service implementation\n│   │               └── SecurityConfig.kt           # Security configuration\n│   └── resources\n│       ├── application.properties                  # Application configuration\n│       └── schema.sql                              # Database schema\n└── test\n    ├── kotlin\n    │   └── com\n    │       └── db\n    │           └── cashcard\n    │               ├── CashCardJsonTest.kt         # JSON serialization tests\n    │               └── CashcardApplicationTests.kt  # Integration tests\n    └── resources\n        ├── com\n        │   └── db\n        │       └── cashcard\n        │           ├── list.json                   # Test data\n        │           └── single.json                 # Test data\n        └── data.sql                                # Test data initialization\n```\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/yourusername/cashcard.git\n   cd cashcard\n   ```\n\n2. Build the project:\n   ```bash\n   ./gradlew build\n   ```\n\n3. Run the application:\n   ```bash\n   ./gradlew bootRun\n   ```\n\n## Usage\n\nThe application exposes a RESTful API for managing cash cards. Here are some example commands using curl:\n\n### Get a Cash Card\n\n```bash\ncurl -X GET http://localhost:8080/cashcards/99 -u sarah1:abc123\n```\n\n### Create a Cash Card\n\n```bash\ncurl -X POST http://localhost:8080/cashcards -H \"Content-Type: application/json\" -d '{\"amount\": 250.00}' -u sarah1:abc123\n```\n\n### Update a Cash Card\n\n```bash\ncurl -X PUT http://localhost:8080/cashcards/99 -H \"Content-Type: application/json\" -d '{\"amount\": 300.00}' -u sarah1:abc123\n```\n\n### Delete a Cash Card\n\n```bash\ncurl -X DELETE http://localhost:8080/cashcards/99 -u sarah1:abc123\n```\n\n### Get All Cash Cards (with pagination and sorting)\n\n```bash\ncurl -X GET \"http://localhost:8080/cashcards?page=0\u0026size=5\u0026sort=amount,desc\" -u sarah1:abc123\n```\n\n## API Endpoints\n\n| Method | URL                   | Description                                      | Auth Required |\n|--------|------------------------|--------------------------------------------------|---------------|\n| GET    | /cashcards/{id}        | Get a cash card by ID                            | Yes           |\n| GET    | /cashcards             | Get all cash cards (supports pagination/sorting) | Yes           |\n| POST   | /cashcards             | Create a new cash card                           | Yes           |\n| PUT    | /cashcards/{id}        | Update an existing cash card                     | Yes           |\n| DELETE | /cashcards/{id}        | Delete a cash card                               | Yes           |\n\n## Configuration\n\nThe application uses Spring Boot's default configuration with minimal customization:\n\n### application.properties\n```properties\nspring.application.name=cashcard\n```\n\n### Database Schema (schema.sql)\n```sql\nCREATE TABLE cash_card\n(\n    ID     BIGINT GENERATED BY DEFAULT AS    IDENTITY PRIMARY KEY,\n    AMOUNT NUMBER NOT NULL DEFAULT 0,\n    OWNER    VARCHAR(256) NOT NULL\n);\n```\n\n## Testing\n\nThe application includes comprehensive tests:\n\n1. **Integration Tests**: Test the entire application flow from HTTP requests to database operations\n2. **JSON Tests**: Test JSON serialization and deserialization\n\nTo run the tests:\n\n```bash\n./gradlew test\n```\n\nThe tests use an in-memory H2 database that is initialized with test data from `src/test/resources/data.sql`.\n\n### Test Users\n\nThe application includes the following test users:\n\n| Username           | Password | Role        |\n|--------------------|----------|-------------|\n| sarah1             | abc123   | CARD-OWNER  |\n| kumar2             | xyz789   | CARD-OWNER  |\n| hank-owns-no-cards | qrs456   | NON-OWNER   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpramodbharti%2Fcashcard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpramodbharti%2Fcashcard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpramodbharti%2Fcashcard/lists"}