COGIP CLI is a command-line interface application for managing companies, contacts, and invoices. It is built with Java and provides an interactive way to perform CRUD operations on your business data.
- List, add, update, and delete companies
- List, add, update, and delete contacts
- List, add, update, and delete invoices
- Interactive command-line menus
- Integration with a backend REST API
- Java 21 or higher
- Maven 3.6 or higher
-
Clone the repository:
git clone <your-repository-url> cd cli
-
Build the project:
mvn clean install
-
Configure the application:
- Edit
src/main/resources/application.propertiesto set your backend API URL and other settings.
- Edit
Run the CLI application with:
mvn spring-boot:runYou will be presented with a menu to manage companies, contacts, and invoices.
company- Manage companies (list, add, update, delete)contact- Manage contacts (list, add, update, delete)invoice- Manage invoices (list, add, update, delete)
Follow the on-screen instructions to navigate through the menus and perform actions.
This project is a REST API developed in Java for managing a fictitious company, COGIP. It allows you to manage companies, contacts, and invoices. The API exposes several routes to perform CRUD (Create, Read, Update, Delete) operations on these entities.
api/
│
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── cogip/
│ │ │ ├── controllers/ # REST controllers (CompanyController, ContactController, InvoiceController)
│ │ │ ├── models/ # JPA entities (Company, Contact, Invoice)
│ │ │ ├── repositories/ # Data access interfaces (CompanyRepository, etc.)
│ │ │ ├── services/ # Business logic (CompanyService, etc.)
│ │ │ └── CogipApiApplication.java # Spring Boot entry point
│ │ └── resources/
│ │ ├── application.properties # Application configuration (DB, port, etc.)
│ │ └── ... # Other resources (data.sql, etc.)
│ └── test/ # Unit and integration tests
│
├── README.md # This file
├── pom.xml # Maven dependencies and project configuration
└── ...
- controllers/: Handles HTTP requests and API routes.
- models/: Defines entities persisted in the database.
- repositories/: Provides methods to interact with the database.
- services/: Contains business logic and specific processing.
- resources/: Configuration files and static resources.
- Company management
- Contact management
- Invoice management
-
GET /companies
Retrieves the list of all companies. -
GET /companies/{id}
Retrieves information about a company by its ID. -
POST /companies
Creates a new company. -
PUT /companies/{id}
Updates an existing company. -
DELETE /companies/{id}
Deletes a company.
-
GET /contacts
Retrieves the list of all contacts. -
GET /contacts/{id}
Retrieves information about a contact by its ID. -
POST /contacts
Creates a new contact. -
PUT /contacts/{id}
Updates an existing contact. -
DELETE /contacts/{id}
Deletes a contact.
-
GET /invoices
Retrieves the list of all invoices. -
GET /invoices/{id}
Retrieves information about an invoice by its ID. -
POST /invoices
Creates a new invoice. -
PUT /invoices/{id}
Updates an existing invoice. -
DELETE /invoices/{id}
Deletes an invoice.
Note: All
idfields are UUIDs and are automatically generated by the system.
- Description: Lists all companies.
- Response:
[ { "id": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f", "name": "Company name", "address": "Address", "vat": "VAT number" }, ... ]
- Description: Details of a company.
- Parameters:
id(path, UUID): company identifier
- Response:
{ "id": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f", "name": "Company name", "address": "Address", "vat": "VAT number" }
- Description: Creates a company.
- Request body:
{ "name": "Company name", "address": "Address", "vat": "VAT number" } - Response: Created company (JSON object, with generated UUID)
- Description: Updates a company.
- Parameters:
id(path, UUID)
- Request body: Same as POST
- Response: Updated company (JSON object)
- Description: Deletes a company.
- Parameters:
id(path, UUID)
- Response:
{ "message": "Company deleted" }
- Description: Lists all contacts.
- Response:
[ { "id": "c1a2b3c4-d5e6-4f3a-9b2e-7b8a1c2e7b8a", "firstname": "First name", "lastname": "Last name", "email": "email@example.com", "companyId": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f" }, ... ]
- Description: Details of a contact.
- Parameters:
id(path, UUID)
- Response:
{ "id": "c1a2b3c4-d5e6-4f3a-9b2e-7b8a1c2e7b8a", "firstname": "First name", "lastname": "Last name", "email": "email@example.com", "companyId": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f" }
- Description: Creates a contact.
- Request body:
{ "firstname": "First name", "lastname": "Last name", "email": "email@example.com", "companyId": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f" } - Response: Created contact (JSON object, with generated UUID)
- Description: Updates a contact.
- Parameters:
id(path, UUID)
- Request body: Same as POST
- Response: Updated contact (JSON object)
- Description: Deletes a contact.
- Parameters:
id(path, UUID)
- Response:
{ "message": "Contact deleted" }
- Description: Lists all invoices.
- Response:
[ { "id": "f3a4c9e9-b2e1-a2b3-c4d5-e6f7b8a1c2e7", "number": "INV-001", "date": "2024-01-01", "companyId": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f", "amount": 1000.0 }, ... ]
- Description: Details of an invoice.
- Parameters:
id(path, UUID)
- Response:
{ "id": "f3a4c9e9-b2e1-a2b3-c4d5-e6f7b8a1c2e7", "number": "INV-001", "date": "2024-01-01", "companyId": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f", "amount": 1000.0 }
- Description: Creates an invoice.
- Request body:
{ "number": "INV-001", "date": "2024-01-01", "companyId": "e7b8a1c2-4f3a-4c9e-9b2e-1a2b3c4d5e6f", "amount": 1000.0 } - Response: Created invoice (JSON object, with generated UUID)
- Description: Updates an invoice.
- Parameters:
id(path, UUID)
- Request body: Same as POST
- Response: Updated invoice (JSON object)
- Description: Deletes an invoice.
- Parameters:
id(path, UUID)
- Response:
{ "message": "Invoice deleted" }
- Clone the repository
- Install dependencies with Maven:
mvn install - Start the application:
mvn spring-boot:run
Project by [Manu-cj].
Feel free to fork the repository and submit pull requests. For major changes, please open an issue first to discuss what you would like to change.