Lionic is a robust Java application for managing person data with a focus on high-performance PostgreSQL database operations. It implements a professional-grade data access layer with connection pooling, comprehensive error handling, and an intuitive command-line interface.
- Efficient Database Connectivity: Uses HikariCP connection pooling for optimized database performance
- Repository Pattern: Clean separation of concerns with a repository-based architecture
- Flexible API: Simple CRUD operations and search functionality for person management
- Robust Error Handling: Comprehensive exception handling with detailed error classification
- Type-Safe Data Access: Strongly-typed operations with proper object mapping
- Command Line Interface: Interactive terminal for managing people records
- Extensible Design: Modular architecture that can be easily expanded
- Java Development Kit (JDK) 21 or higher
- PostgreSQL database server 13+
- Maven 3.8+ for building the project
git clone https://github.com/RedNetty/Lionic.git
cd Lionic- Install and start PostgreSQL (if not already running)
- Create a database for Lionic:
CREATE DATABASE lionic; CREATE USER lionic_user WITH ENCRYPTED PASSWORD 'your_password'; GRANT ALL PRIVILEGES ON DATABASE lionic TO lionic_user;
Create a configuration file at ./config/database.json with the following content:
{
"dbType": "postgresql",
"hostName": "localhost",
"dbName": "lionic",
"username": "lionic_user",
"password": "your_password",
"port": 5432,
"connectionPoolSize": 10,
"connectionTimeout": 30000,
"idleTimeout": 600000
}Alternatively, you can set these configuration values as environment variables:
export DB_TYPE=postgresql
export DB_HOST=localhost
export DB_NAME=lionic
export DB_USERNAME=lionic_user
export DB_PASSWORD=your_password
export DB_PORT=5432mvn clean packagejava -jar target/lionic.jarThe application provides an interactive CLI with the following commands:
| Command | Description | Example |
|---|---|---|
-add |
Add a new person | -add 50000,John Doe,30,1994 |
-remove |
Remove person by name or ID | -remove John or -remove 1 |
-list |
List all people | -list |
-find |
Search for people by name | -find Doe |
-save |
Save all changes to database | -save |
-exit |
Exit the application | -exit |
// Initialize database service
DatabaseService dbService = new DatabaseService();
// Create a new person
Person person = new Person(1, "John", "Doe", 30, "[email protected]");
person.addAttribute("networth", 50000.0);
person.addAttribute("birthYear", 1994);
// Save to database
dbService.savePerson(person);
// Find people by name
List<Person> results = dbService.findPeopleByName("Doe");
// Close resources when done
dbService.close();- DatabaseService: Main entry point for database operations
- ConnectionManager: Manages database connections with HikariCP
- Repository: Base class for data access operations
- PersonRepository: Implements CRUD operations for Person entities
- PersonManager: Handles user interaction and business logic
- User interacts with PersonManager via CLI
- PersonManager delegates operations to DatabaseService
- DatabaseService uses PersonRepository for data access
- PersonRepository uses ConnectionManager for database connections
- Data is stored in PostgreSQL and returned as domain objects
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please adhere to:
- Clean code principles
- Proper error handling
- Unit testing for new features
- Documentation for public APIs
This project is licensed under the MIT License - see the LICENSE file for details.