How ashwin492/journallapp works
Project Type and Purpose
• This is a monolithic, back-end web application built with Spring Boot.
• Purpose: provide a secure, role-based journal API with features such as JWT authentication, CRUD on journal entries, weekly sentiment reporting (via Kafka), real-time weather lookups, Redis caching, and email notifications.
File Structure
• Top-level: Maven wrapper, pom.xml, README.md, CI workflow.
• src/main/java/net/engineeringdigest/journalApp:
• api/response – DTOs for external API responses (e.g., weather).
• cache – application-level caching abstractions.
• config – SpringSecurity, RedisConfig, SwaggerConfig.
• controller – REST controllers (JournalEntryController, UserController, PublicController, AdminController, GoogleAuthController).
• service – business logic (JournalEntryService, UserService, WeatherService, EmailService, RedisService, SentimentConsumerService, UserDetailsServiceImpl).
• repository – data access (Spring Data MongoRepository interfaces + custom impl).
• entity/dto/enums/model – domain objects and supporting types.
• filter – JwtFilter for incoming request authentication.
• scheduler – periodic tasks (UserScheduler).
• util – JwtUtil, other helpers.
• Configuration files: application.yml, logback.xml.
• Test tree mirrors main packages.
Key Insights from README
• Underlying database: MongoDB (user & journal entries).
• Caching: Redis for external API responses.
• Messaging: Kafka consumer on “weekly-sentiments” topic, triggers email digests.
• Security: Spring Security + JWT + BCrypt + role-based access (USER vs ADMIN).
• External integrations: Weather REST API, JavaMailSender, Google OAuth.
Main Components
• API Layer (Controllers + JwtFilter)
• Business Layer (Services)
• Data Layer (Repositories + MongoDB)
• Infrastructure Components:
• Redis Cache
• Kafka Consumer / Broker
• External Weather REST API
• Email SMTP Server (JavaMailSender)
• Google OAuth Provider
• Supporting Components:
• Scheduler
• Swagger UI (for API docs)
Relationships and Data Flows
• Incoming HTTP requests → JwtFilter → Controllers → Services → Repositories → MongoDB
• WeatherService checks Redis first; on cache miss calls external Weather REST API → caches result in Redis → returns to controller → client.
• SentimentConsumerService listens to Kafka → on message arrival invokes EmailService → sends via SMTP.
• User registration / login flows interact with UserService → save/find in MongoDB. JWT generated by JwtUtil.
• Scheduler triggers periodic tasks via UserScheduler → may enqueue Kafka messages or perform cron-driven operations.
Architectural Patterns and Principles
• Layered (Controller → Service → Repository)
• Dependency Injection (Spring)
• Separation of Concerns (security, caching, scheduling, messaging)
• Single Deployable Unit (monolith)
• Event-driven integration with Kafka
Elements
• Application code (light blue)
• Infrastructure (light green)
• External services (light orange)
• Cloud/stack symbols for external APIs (Weather, Google OAuth)
Final Advice
• Be exhaustive: represent every package group or external dependency as a distinct component.
• Keep labels concise but precise.
• Iterate with the team to refine clarity and completeness.