|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides context and guidance for AI coding assistants working with the Mifos Self Service Plugin repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +The **Mifos Self Service Plugin** is a Spring Boot plugin that extends Apache Fineract to provide self-service banking capabilities to end users. It enables customers to manage their own accounts, view transactions, and perform banking operations without requiring staff intervention. |
| 8 | + |
| 9 | +### Architecture |
| 10 | + |
| 11 | +- **Framework**: Spring Boot 3 with Java 21 |
| 12 | +- **Integration**: Apache Fineract 1.15.0-SNAPSHOT |
| 13 | +- **Security**: Spring Security with Basic Auth and OAuth2 support |
| 14 | +- **Database**: PostgreSQL/MySQL with JPA/EclipseLink |
| 15 | +- **API**: RESTful endpoints under `/v1/self` |
| 16 | + |
| 17 | +### Key Components |
| 18 | + |
| 19 | +- **Authentication & Security**: User authentication, permission enforcement, multi-tenant support |
| 20 | +- **User Management**: Self-service user registration, profile management |
| 21 | +- **Account Management**: Savings accounts, loan accounts, share accounts |
| 22 | +- **Product Discovery**: Browse available banking products |
| 23 | +- **Reporting**: Financial statements and transaction reports |
| 24 | + |
| 25 | +## Development Environment Setup |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | +- Java 21 |
| 29 | +- Maven 3.6+ |
| 30 | +- PostgreSQL or MySQL database |
| 31 | +- Apache Fineract instance |
| 32 | + |
| 33 | +### Build Commands |
| 34 | +```bash |
| 35 | +# Build the plugin |
| 36 | +./mvnw clean package -Dmaven.test.skip=true |
| 37 | + |
| 38 | +# Run tests |
| 39 | +./mvnw test |
| 40 | + |
| 41 | +# Run integration tests |
| 42 | +./mvnw verify |
| 43 | +``` |
| 44 | + |
| 45 | +### Database Setup |
| 46 | +The plugin uses Liquibase for database migrations. Scripts are located in `src/main/resources/db/changelog/`. |
| 47 | + |
| 48 | +### Running the Plugin |
| 49 | +This is a library/plugin that extends Apache Fineract. It runs as part of the Fineract application, not as a standalone service. |
| 50 | + |
| 51 | +#### Deployment Options: |
| 52 | +```bash |
| 53 | +# With Apache Fineract (Docker) |
| 54 | +java -Dloader.path=$PLUGIN_HOME/libs/ -jar fineract-provider.jar |
| 55 | + |
| 56 | +# With Apache Fineract (Tomcat) |
| 57 | +Copy JAR to $TOMCAT_HOME/webapps/fineract-provider/WEB-INF/lib/ |
| 58 | +``` |
| 59 | + |
| 60 | +## Coding Standards |
| 61 | + |
| 62 | +### File Structure |
| 63 | +```text |
| 64 | +src/main/java/org/apache/fineract/selfservice/ |
| 65 | + - security/ # Authentication and authorization |
| 66 | + - useradministration/ # User management |
| 67 | + - client/ # Client operations |
| 68 | + - savings/ # Savings account operations |
| 69 | + - loanaccount/ # Loan account operations |
| 70 | + - products/ # Product browsing |
| 71 | + - registration/ # User registration |
| 72 | + - config/ # Configuration classes |
| 73 | +``` |
| 74 | + |
| 75 | +### Code Style |
| 76 | +- Follow Google Java Format (enforced by Spotless Maven plugin) |
| 77 | +- Use Lombok for boilerplate reduction |
| 78 | +- RequiredArgsConstructor for dependency injection |
| 79 | +- Proper Javadoc for public APIs |
| 80 | + |
| 81 | +### Security Guidelines |
| 82 | +- All endpoints must be secured with appropriate permissions |
| 83 | +- Use `@PreAuthorize` annotations for method-level security |
| 84 | +- Validate all input data using DataValidators |
| 85 | +- Never expose sensitive information in API responses |
| 86 | + |
| 87 | +### API Design |
| 88 | +- Use JAX-RS annotations (`@Path`, `@GET`, `@POST`, etc.) |
| 89 | +- Return proper HTTP status codes |
| 90 | +- Use OpenAPI tags for documentation |
| 91 | +- Follow RESTful conventions |
| 92 | + |
| 93 | +### Testing |
| 94 | +- Unit tests for all service classes |
| 95 | +- Integration tests for API endpoints |
| 96 | +- Use TestContainers for database tests |
| 97 | +- Mock external dependencies |
| 98 | + |
| 99 | +## Common Patterns |
| 100 | + |
| 101 | +### Service Layer |
| 102 | +```java |
| 103 | +@Service |
| 104 | +@RequiredArgsConstructor |
| 105 | +public class ExampleServiceImpl implements ExampleService { |
| 106 | + private final ExampleRepository repository; |
| 107 | + |
| 108 | + @Override |
| 109 | + @Transactional |
| 110 | + public Result performOperation(Command command) { |
| 111 | + // Implementation |
| 112 | + } |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | +### API Resource |
| 117 | +```java |
| 118 | +@Path("/v1/self/example") |
| 119 | +@Component |
| 120 | +@Tag(name = "Self Example", description = "Example operations") |
| 121 | +@RequiredArgsConstructor |
| 122 | +public class SelfExampleApiResource { |
| 123 | + private final ExampleService service; |
| 124 | + |
| 125 | + @GET |
| 126 | + @Path("/{id}") |
| 127 | + public Response getExample(@PathParam("id") Long id) { |
| 128 | + // Implementation |
| 129 | + } |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +### Data Validation |
| 134 | +```java |
| 135 | +@Component |
| 136 | +public class ExampleDataValidator { |
| 137 | + private final FromJsonHelper fromJsonHelper; |
| 138 | + |
| 139 | + public void validate(String json) { |
| 140 | + // Validation logic |
| 141 | + } |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +## Important Notes |
| 146 | + |
| 147 | +- This is a plugin, not a standalone application |
| 148 | +- Depends on Apache Fineract core modules |
| 149 | +- Uses multi-tenant architecture |
| 150 | +- Security is critical - handle with care |
| 151 | +- Follow Fineract coding conventions |
| 152 | + |
| 153 | +## Debugging Tips |
| 154 | + |
| 155 | +- Enable debug logging: `logging.level.org.apache.fineract.selfservice=DEBUG` |
| 156 | +- Use Spring Boot Actuator endpoints for monitoring |
| 157 | +- Check application logs for security-related issues |
| 158 | +- Verify database migrations in development |
| 159 | + |
| 160 | +## References |
| 161 | + |
| 162 | +- [Apache Fineract Documentation](https://fineract.apache.org/) |
| 163 | +- [Spring Boot Documentation](https://spring.io/projects/spring-boot) |
| 164 | +- [JAX-RS Specification](https://jakarta.ee/specifications/restful-ws/) |
| 165 | +- [Spring Security Reference](https://spring.io/projects/spring-security) |
| 166 | + |
| 167 | +## Contact |
| 168 | + |
| 169 | +For questions about this repository: |
| 170 | +- Create an issue on GitHub |
| 171 | +- Check the Mifos community forums |
| 172 | +- Review existing documentation and code comments |
0 commit comments