Author: ETOUNDI II Eugรจne
Email: etoundisebastien@gmail.com
Location: Lyon, France
Your open platform to explore, access, and discuss free publicโdomain and permissively licensed books. ๐
Discover. Read. Review. Share knowledge.
MF Library aims to deliver a modern, scalable and secure platform where users can:
- ๐ Search and browse a curated catalog of free books
- ๐ View rich book metadata and (future) embedded readers
- โญ Rate and review titles to guide others
- ๐ก๏ธ Benefit from a secure, token-based architecture
- ๐ Experience a cloud-ready microservices foundation
- Vision & Value Proposition
- Core Features
- Architecture Overview
- Service Responsibilities
- Technology Stack
- Quick Start (5 Minutes)
- Running Locally (Detailed)
- Configuration & Environment
- Security Model
- Domain & Use Cases
- API Strategy
- Messaging & Events
- Data & Persistence
- Testing Approach
- Scalability & Performance
- Roadmap
- Diagrams
- Folder Map
- Development Workflow
- Contributing
- FAQ
- Glossary
- License
- Acknowledgements
MF Library is engineered to be an extensible knowledge platform built on a robust microservice foundation. Its design emphasizes:
- Separation of domains (users, books, reviews)
- Cloud and container readiness from day one
- Strong security and future observability
- Event-driven evolution with Kafka
- Developer friendliness and clarity
Current / Planned (MVP Scope):
| Feature | Status | Notes |
|---|---|---|
| User authentication & accounts | ๐ง | Keycloak realm import available; UI integration pending |
| Browse book catalog | ๐ง | Book service scaffold ready |
| Book search (title/author) | ๐ง | Repository queries to implement |
| View book details + aggregated rating | ๐ง | Rating aggregation design TBD |
| Submit & manage reviews | ๐ง | Review service base in place |
| API gateway routing & service discovery | โ | Eureka + Gateway operational |
| Secured endpoints (JWT) | ๐ง | Resource server dependencies present |
| OpenAPI docs per service | ๐ง | springdoc configured (expand aggregation) |
| Event publication (Kafka) | ๐ง | Topics & consumers definition pending |
| Responsive Angular SPA shell | โ | Frontend scaffold running |
Legend: โ = Implemented / working โข ๐ง = In progress / scaffolded โข ๐งช = Experimental โข ๐ฎ = Planned
Future (Post-MVP): reading session, recommendation engine, collection curation, social signals.
Pattern: Microservices + API Gateway + Service Discovery + External Identity Provider + Event Backbone.
Core components:
- Gateway โ single ingress, policy, routing
- Eureka โ discovery registry
- Keycloak โ authentication / OIDC provider
- Domain services โ user, book, review verticals
- Kafka โ asynchronous decoupling & future analytics pipeline
- PostgresSQL โ relational persistence (per bounded context)
- Angular SPA โ user-facing interface
Cross-cutting (implemented or planned): validation, OpenAPI docs, RBAC, future observability & resilience.
Planned Enhancements
- Config server for centralized external configuration
- Distributed tracing via OpenTelemetry
- Resilience4j for circuit breaking
- Rate limiting (Bucket4j / Gateway filters)
| Service | Port | Responsibility | Tech Highlights |
|---|---|---|---|
| Registry (Eureka) | 8761 | Dynamic service discovery | Spring Cloud Netflix Eureka Server |
| API Gateway | 8765 | Edge routing, security delegation, CORS | Spring Cloud Gateway |
| User Service | 8081 | User profiles & identity linkage | Spring Boot, Security, JPA |
| Book Service | 8082 | Catalog, metadata, classification | Spring Boot, JPA, OpenAPI |
| Review Service | 8083 | Ratings & textual reviews | JPA, Kafka-ready, Feign (future) |
| Keycloak | 8085 | OIDC provider & token service | Keycloak 24.x |
| Kafka + Zookeeper | 29092 / 9092 / 2181 | Event messaging backbone | Confluent images |
| PostgreSQL | 5432 | Relational persistence | Separate schemas (strategy) |
| Frontend | 4200 (dev) | SPA UX | Angular 19 |
Backend: Java 21, Spring Boot 3.4.x, Spring Cloud 2024.x, Spring Security, Spring Data JPA, Spring Kafka, OpenFeign, springdoc-openapi, Lombok
Frontend: Angular 19, TypeScript, (future: NgRx / Signals state management)
Infrastructure: Docker Compose, Keycloak, PostgresSQL 17-alpine, Kafka/Zookeeper, Git submodules
Testing: Spring Boot Test, H2, Kafka Test, Security Test, Reactor Test, (planned: Test containers, Contract Tests)
Planned Observability: Micrometer + Prometheus, Grafana, OpenTelemetry, structured logging pipeline.
Clone with submodules and launch the full stack:
git clone --recurse-submodules https://github.com/eugene-seb/MF-Library.git
cd MF-Library
docker compose up --buildThen visit:
- Eureka: http://localhost:8761
- Gateway (edge API): http://localhost:8765
- Keycloak: http://localhost:8085
- (Add Angular dev separately: see below)
Stop & clean:
docker compose down -vBackend (example):
cd services/book-service
./mvnw spring-boot:run # Windows: mvnw.cmd spring-boot:runFrontend:
cd mflibrary-frontend
npm install
ng serve
# http://localhost:4200Run tests:
./mvnw testUpdate submodules:
git submodule update --init --recursiveEnvironment is largely scaffolded via docker-compose.yml.
Key runtime variables (compose-managed):
| Component | Key Variables (non-exhaustive) |
|---|---|
| Zookeeper | ZOOKEEPER_CLIENT_PORT, ZOOKEEPER_TICK_TIME |
| Kafka | KAFKA_BROKER_ID, KAFKA_ZOOKEEPER_CONNECT, KAFKA_LISTENERS, KAFKA_ADVERTISED_LISTENERS |
| Keycloak | KEYCLOAK_ADMIN, KEYCLOAK_ADMIN_PASSWORD |
| Postgres | POSTGRES_USER, POSTGRES_PASSWORD |
| Spring Services | SPRING_PROFILES_ACTIVE=docker |
Suggested future .env (example placeholder):
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
KEYCLOAK_ADMIN=admin
KEYCLOAK_ADMIN_PASSWORD=admin
SPRING_PROFILES_ACTIVE=local
Keycloak realm import JSON files (mounted):
.infra/keycloak/app-mflibrary-realm-export.json.infra/keycloak/master-realm-export.json
- Identity via Keycloak (OIDC): Users authenticate in the browser โ tokens passed to backend
- Resource services validate JWT (Spring Security + OAuth2 Resource Server)
- Planned roles:
ROLE_USER,ROLE_ADMIN - Future: Fine-grained scopes (e.g.
books.read,reviews.write), audit events, rate limiting
Auth Flow (simplified): User โ Browser SPA โ Keycloak Login โ Receives ID + Access Token โ Calls Gateway โ Gateway forwards with token โ Resource service validates & authorizes
Actors: Visitor, Registered User, Administrator.
Primary Flows:
- Browse Catalog โ list books with pagination & filters
- Book Detail โ fetch metadata + aggregated rating
- Register/Login โ delegated to Keycloak (redirect flow)
- Submit Review โ authenticated user posts rating/comment
- Moderate Reviews (admin) โ approve/remove
Planned Event Flow (future): ReviewCreated โ Kafka topic โ Aggregator updates rating snapshot.
Design Principles:
- Versioned base path:
/api/v1/* - Resource-oriented endpoints
- Consistent error contract (planned):
{
"timestamp": "2025-01-01T12:00:00Z",
"path": "/api/v1/books/123",
"error": "NOT_FOUND",
"message": "Book not found",
"requestId": "<trace-id>"
}- OpenAPI auto-generation (per-service) at
/v3/api-docs&/swagger-ui.html - Future aggregation via API gateway or dedicated API portal
Kafka infrastructure is prepared. Topic candidates:
| Topic | Purpose | Status |
|---|---|---|
reviews.created |
Trigger rating aggregation / analytics | ๐ฎ |
reviews.updated |
Recompute rating delta | ๐ฎ |
books.activity |
Track popular titles / future recommendations | ๐ฎ |
Legend: ๐ฎ = Planned โข ๐ง = In Progress โข โ = Active
Future: schema evolution management (Avro/Protobuf + Schema Registry), consumer groups for analytics.
- PostgresSQL as primary store (one DB per service or schema-based isolation strategy)
- JPA/Hibernate with migration tooling (Liquibase/Flyway planned)
- H2 for test isolation
- Future: caching layer (Redis) for book metadata & aggregated ratings
| Layer | Current | Planned |
|---|---|---|
| Unit | Spring Boot Test | More domain-only tests |
| Integration | H2 + MockMVC + embedded Kafka test libs | Test-containers-based infra replication |
| Contract | โ | Spring Cloud Contract |
| E2E | โ | Postman/Cypress pipeline |
| Performance | โ | Gatling / k6 benchmarks |
Prepared Strategies:
- Stateless services โ horizontal scaling
- Independent deployability โ reduced blast radius
- Event-driven async operations (Kafka) to decouple heavy workflows
- Gateway filtering for rate limiting (planned)
- Observability for capacity planning (metrics/tracing planned)
Future: CDN for static assets, query optimization, caching, read replicas.
Short-Term:
- Book search endpoints
- Review submission + retrieval
- OAuth2 flow integration on frontend
- Standard error model & gateway filters
Mid-Term:
- Kafka event flows (rating aggregation)
- Observability stack & tracing
- Admin web module
- Config server adoption
Long-Term:
- Recommendation engine
- Ingestion pipeline (EPUB/PDF parsing)
- Multi-language support
- Kubernetes deployment & autoscaling
| Diagram | File |
|---|---|
| Deployment | doc/images/Deployment-Diagram.png |
| User Request Flow | doc/images/Flow-user-request.png |
| Domain Model | doc/images/Domain-class-diagram.png |
| Components | doc/images/Components-diagram.png |
| Sequence (Review Submit - Placeholder) | (Add) |
| API Interaction Map (Placeholder) | (Add) |
TODO: Add a sequence diagram for Review creation lifecycle.
| Path | Purpose |
|---|---|
docker-compose.yml |
Orchestrates infra + services |
services/ |
Active microservice implementations |
submodules/ |
Mirrored submodule repositories |
mflibrary-frontend/ |
Angular SPA project |
doc/images/ |
Architecture & UML diagrams |
.infra/keycloak/ |
Realm import JSON (mounted in compose) |
README.md |
This documentation |
TODO.md |
Internal task notes |
- Branch:
feat/<topic>orfix/<issue> - Implement + add/update tests
- Validate locally (
./mvnw test+ manual service run) - Commit atomic changes; reference issues when applicable
- Open PR for review (future CI automation)
- Merge โ prepare container publish (future pipeline)
External contribution guidelines will be formalized. For now:
- Use conventional commit style if possible (e.g.
feat: add search endpoint) - Keep PRs focused & small
- Document architectural-impacting changes
- Prefer adding tests with new features
Planned docs: CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md.
Q: Can I add proprietary books?
A: Only if licensing permits. Default positioning is public-domain / permissively licensed content.
Q: Where do I configure Keycloak realms?
A: See .infra/keycloak/*.json imported at container startup.
Q: How do I reset Postgres data?
A: docker compose down -v removes volumes (all data lost). Use with caution.
Q: Does the gateway aggregate OpenAPI yet?
A: Not yetโplanned in roadmap.
Q: Is horizontal scaling supported?
A: Architecture enables it; orchestration (Kubernetes) is a future milestone.
| Term | Meaning |
|---|---|
| Bounded Context | Independently modeled domain service (DDD principle) |
| Resource Server | OAuth2-protected API validating JWT tokens |
| Gateway | Edge service handling routing and cross-cutting concerns |
| Realm | Keycloak logical tenant boundary for users, roles, clients |
| Event | Asynchronous message published to Kafka topic |
This project is licensed under the MIT License.
- Open Source frameworks powering the platform
- Community patterns for microservice design & security
- Inspiration: public knowledge & digital library initiatives
Have an idea or found an issue? Open an issue or start a discussion.
"Access to knowledge empowers everyone. Let's build it right." ๐



