How tony-stark73/java-assignment works
Project type and purpose
• This is a standalone backend REST API built with Spring Boot (Java).
• It manages stock portfolios: reading/writing a local JSON file, exposing endpoints to get portfolios and stock data, and fetching live stock details from an external API.
File structure
• Top-level build: pom.xml, Maven wrapper files → Java/Maven project.
• Entry point: src/main/java/com/example/demo/DemoApplication.java → Spring Boot application.
• Package breakdown under src/main/java/portfolio:
• controllers (REST endpoints)
• services (business logic, external API calls)
• models (Portfolio & Stock domain objects)
• storage (JSON file persistence)
• Resources: application.properties (Spring config) and data/portfolio.json (persistent store).
• Tests under src/test/java: Spring Boot test harness for application start-up.
README for additional insights
• Minimal README (# java-assignment) – no explicit architecture notes.
• We infer architecture solely from file tree and Spring conventions.
a. Main components
1) Client (e.g., web/mobile or curl)
2) API Layer (Controllers)
– StockController
– TestController
3) Service Layer
– PortfolioService (CRUD on portfolio.json)
– StockApiService (calls external stock quotes API)
4) Storage Layer
– JsonStorage (reads/writes portfolio.json)
5) External Services
– Third-party Stock Data API
b. Relationships & interactions
• Client → HTTP request → Controllers
• Controllers ↔ Service Layer (business orchestration)
• PortfolioService ↔ JsonStorage (read/write file)
• StockApiService → External Stock API (HTTP)
• Service results → Controller → HTTP response → Client
c. Architectural patterns & design principles
• Layered (Presentation → Service → Persistence)
• Separation of concerns (controllers only handle HTTP, services contain business logic, storage deals with persistence)
• Dependency injection (Spring Boot)
d. Key technologies/frameworks
• Spring Boot (embedded Tomcat, DI, MVC)
• Java 8+
• Maven (build)
• JSON file persistence (no RDBMS)
• External HTTP client (e.g., RestTemplate or WebClient in StockApiService)
Key reminders
• Be detailed: represent each layer and component from the package structure.
• Dependencies (e.g., StockController depends on both services).
• Don’t overcomplicate: the goal is a clear, layered overview matching the codebase’s packages and Spring Boot conventions.