How lgaxd/pathmed-api-java works
Project Type and Purpose
• This is a standalone RESTful backend API written in Java 17 for managing medical appointments and patient records in the PathMed system. It exposes HTTP endpoints, applies business logic, persists data in an Oracle Database, and uses GSON for JSON processing.
File Structure Analysis
• Top-level directories:
• src/br/com/pathmed/controller – HTTP request handlers (API layer)
• src/br/com/pathmed/service – Business logic layer
• src/br/com/pathmed/dao – Data access layer (DAO)
• src/br/com/pathmed/model – Domain/data models
• src/br/com/pathmed/util – Utilities (DB connection, JSON config)
• lib/ – External JAR dependencies (GSON, OracleJDBC)
• bin/, out/ – Compiled class files
• PathmedAPI/ – API documentation scripts
• Configuration/build:
• DatabaseConnection.java holds the JDBC URL/credentials
• Main.java starts the native Java HTTP server (ApiServer)
README Insights
• Confirms Java 17, Oracle DB, GSON, native HTTP server
• Describes core features: authentication, patient management, consultations, specialties, professionals
• Lists all REST endpoints and DB tables
• Specifies project architecture overview
Key Components
a. API Server Layer
• ApiServer (HTTP listener)
• Controllers (AuthController, PacienteController, ConsultaController, etc.)
b. Service Layer
• AuthService, PacienteService, ConsultaService, DisponibilidadeService, EspecialidadeService, ProfissionalService
c. Data Access Layer
• DAOs (AuthDAO, PacienteDAO, ConsultaDAO, DisponibilidadeDAO, EspecialidadeDAO, ProfissionalDAO)
d. Persistence
• Oracle Database (tables: Pacientes, Consultas, Especialidades, Profissionais, Disponibilidade)
• JDBC Driver (ojdbc17.jar)
e. Utilities
• DatabaseConnection
• GsonConfig
f. External Dependencies
• GSON library for JSON serialization/deserialization
Relationships and Data Flow
1. Client (e.g., frontend app or API consumer) sends HTTP request →
2. ApiServer routes it to the appropriate Controller →
3. Controller validates and transforms input, calls Service →
4. Service enforces business rules, calls DAO →
5. DAO executes SQL via DatabaseConnection → Oracle DB → returns data →
6. Service processes results → Controller serializes response with GSON →
7. ApiServer returns HTTP response to client
Architectural Patterns & Principles
• Layered (n-tier) Architecture: clear separation of concerns (API, business logic, persistence)
• MVC-like flow (Controllers as “C”, Services+Models as “M”, though no view)
• Dependency inversion via utility classes (DatabaseConnection, GsonConfig)
• Single responsibility in each package
Technologies and Frameworks
• Java 17 (language/runtime)
• Native Java HTTP server (com.sun.net.httpserver)
• OracleJDBC driver for DB connectivity
• GSON for JSON handling
• Directory structure follows package naming conventions
Essential Elements to Capture
• All Controllers with their main endpoints
• Service classes and the business operations they perform
• DAO classes and the tables they access
• DatabaseConnection as the single source of DB connectivity
• GSONConfig for JSON serialization
• External libraries (GSON, OracleJDBC)