How natanius18/university-api works
This project is a Spring Boot-based REST API designed as a university platform where teachers can create tests, and students can take these tests and view their results. The platform uses a clear layered architecture with controllers, services, repositories, entities, security configurations, and scheduled tasks. The system also interacts with external microservices (for notifications and logging) and uses both a relational database (PostgreSQL, managed by Flyway) and MongoDB (for statistics).
Main Components
• Application Entry Point: Mark the UniversityApplication class as the starting point.
• Controllers: Represent all the API endpoints (e.g., ApproveController, AuthenticationController, ConfirmationController, ResponseController, StudentController, TeacherController, TestController, TestStatisticsController). Display them as the “API Layer” handling inbound HTTP requests.
• Service Layer: Include service interfaces and their implementations (e.g., PersonService, TestService, TeacherService, StudentService, ResponseService, TestStatisticsService, and the testing strategies in the test package). Show that the controllers delegate business logic to these services.
• Data Access Layer: Illustrate the repositories (AnswerRepository, PersonRepository, etc.) that abstract database operations.
• Domain Model: Show the entity classes (Person, Teacher, Student, Test, Question, Answer, Response, TestStatistics) and the DTOs which help in data transportation between layers.
• Security Components: Highlight the Spring Security configuration including SecurityConfig, JwtTokenProvider, JwtTokenFilter, JwtConfigurer, and UserDetailsServiceImpl. Indicate that these modules intercept requests for authentication and authorization through JWT.
• MongoDB for Statistics: Since the project stores test statistics in MongoDB, include a separate component indicating its role to capture test attempts, results, and filtering (via mongo filters).
• Scheduled Tasks: Include ScheduledTasks that may trigger periodic jobs (e.g., for cleanup, reminders, etc.).
• External Microservices:
• Notification Microservice: Represented as an external system that handles email notifications (for account confirmation and daily test statistics).
• Logs Microservice: Represented as a separate component managing logging functionality and user activity logs.
• Messaging and Integration: Illustrate the use of Kafka and ZooKeeper for inter-service communication between this API and other microservices.
Relationships and Interactions
• From Controllers, show data flowing to the Service layer, which encapsulates business logic and calls repository methods.
• That the Repository layer interacts with the PostgreSQL database for CRUD operations.
• That security filters (JWT filters) intercept API calls before reaching the controllers.
• Flow where Flyway migrations initialize or update the database schema at application start-up.
Architectural Patterns and Design Principles
• Adhere to a layered architecture (presentation, business, persistence) which clearly demarcates your controllers, services, and repositories.
• Use Dependency Injection and Inversion of Control principles as provided by Spring Boot.
• How the security configuration “wraps” the system to enforce authentication/authorization via JWT.
• That the testing modules (unit and Cucumber tests) validate functionality across different layers.
Relevant Technologies and Frameworks
• Java 11 along with Spring Boot 2.7.0, Spring Security, and Spring Data (Hibernate-Core).
• Flyway for database migration and PostgreSQL as the primary relational database.
• MongoDB for storing test statistics.
• Swagger UI is used for API documentation.
• Kafka (with ZooKeeper) is used for integration with external services.
• Logging and Notification microservices are integrated via external REST API calls.
• Entry point and main application container (UniversityApplication).
• API Controllers, depicted in a grouped “Web/API layer”.
• Service components that manage business logic and orchestrate flow.
• Repository classes that manage data persistence to PostgreSQL.
• Entity and DTO models.
• Security module: SecurityConfig, JwtTokenFilter, etc., intercepting requests.
• Database components:
• PostgreSQL (with Flyway migrations) for core test data.
• MongoDB for handling statistics.
• External integrations:
• Notification Microservice.
• Logs Microservice.
• Kafka (message queues).
• Scheduled Tasks for periodic operations.