Skip to content

Commit db4de2f

Browse files
author
Richard Capraro
committed
feat: Add Address and two types of persons
1 parent f39aeea commit db4de2f

22 files changed

Lines changed: 1746 additions & 729 deletions

README.md

Lines changed: 226 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ This project follows Domain-Driven Design (DDD) principles and Clean Architectur
1414
## Features
1515

1616
- CRUD operations for Person entities
17-
- Search functionality
1817
- Address management
1918
- Domain events for tracking changes
2019
- Data generation utility for creating test data
@@ -35,15 +34,16 @@ This project follows Domain-Driven Design (DDD) principles and Clean Architectur
3534
```
3635

3736
This will start:
38-
- PostgreSQL 17.5 on port 5432 with database name "person", username "postgres", and password "postgres"
39-
- Meilisearch 1.14.0 on port 7700 with master key "masterKey"
37+
- PostgreSQL 17.5 on port 5432 with database name "person", username "postgres", and password "postgres"
38+
- Meilisearch 1.14.0 on port 7700 with master key "masterKey"
4039

4140
2. Build and run the application:
4241
```
4342
./gradlew run
4443
```
4544

46-
Note: If you're using the Meilisearch integration, you'll need to configure the application to use the master key "masterKey" when connecting to Meilisearch.
45+
Note: If you're using the Meilisearch integration, you'll need to configure the application to use the master key "
46+
masterKey" when connecting to Meilisearch.
4747

4848
### Using Individual Docker Containers
4949

@@ -70,108 +70,250 @@ The API will be available at `http://localhost:8080`.
7070

7171
### Person Endpoints
7272

73-
- `GET /api/persons` - Get all persons
74-
- `GET /api/persons/search?q={query}` - Search for persons
73+
- `GET /api/persons` - Get all persons (both individuals and legal entities)
7574
- `GET /api/persons/{id}` - Get a person by ID
76-
- `POST /api/persons` - Create a new person
77-
- `PUT /api/persons/{id}` - Update a person
7875
- `DELETE /api/persons/{id}` - Delete a person
7976

77+
### Individual Endpoints
78+
79+
- `POST /api/individuals` - Create a new individual
80+
- `PUT /api/individuals/{id}` - Update an individual
81+
82+
### Legal Entity Endpoints
83+
84+
- `POST /api/legal-entities` - Create a new legal entity
85+
- `PUT /api/legal-entities/{id}` - Update a legal entity
86+
8087
### Address Endpoints
8188

8289
- `POST /api/persons/{id}/addresses` - Add an address to a person
8390
- `DELETE /api/persons/{personId}/addresses/{addressId}` - Remove an address from a person
8491

8592
## Data Model
8693

87-
### Person
88-
89-
A person is composed of the following fields:
94+
The API supports two types of persons: Individuals and Legal Entities.
95+
96+
### Person (Base)
97+
98+
Both Individual and Legal Entity types share the following common structure:
99+
100+
- ID (UUID)
101+
- Type (INDIVIDUAL or LEGAL_ENTITY)
102+
- Addresses (list)
103+
104+
### Individual
105+
106+
An individual person has the following specific fields:
107+
108+
- **Personal Info**:
109+
- First Name
110+
- Last Name
111+
- Birth Date
112+
- Birth City
113+
- Birth Country
114+
- Nationality
115+
- Marital Status
116+
- Under Guardianship (boolean field)
117+
118+
- **Additional Information**:
119+
- Matrimonial Regime
120+
- Social Security Number
121+
122+
### Legal Entity
123+
124+
A legal entity has the following specific fields:
125+
126+
- **General Information**:
127+
- Company Name
128+
- Commercial ID
129+
- Identifier
130+
- Mail Reference
131+
- SIREN
132+
- SIRET
133+
- Legal Form
134+
- Creation Date
135+
136+
- **Legal Information**:
137+
- Commerce Register Number
138+
- Registration Date
139+
- Registration Country
140+
- Registration Place
141+
- Fiscal Year End Date
142+
- Employee Count
143+
- APE Code
144+
- Activity Sector
145+
- Share Capital
146+
147+
- **Legal Representative**:
148+
- Name
149+
- Position
150+
- Email
151+
- Phone
152+
- Start Date
153+
- End Date (optional)
154+
155+
### Address
156+
157+
Both person types can have multiple addresses with the following fields:
158+
159+
- Type (enum: COMMUNICATION, DOMICILE, TRAVAIL, AUTRE)
160+
- Number
161+
- Street
162+
- City
163+
- Postal Code
164+
- Phone (optional)
165+
- Email (optional)
166+
- Is Secondary (boolean)
167+
- Is Undeliverable (boolean)
90168

91-
- **Civilité**:
92-
- Prénom
93-
- Nom
94-
- Date de naissance
95-
- Ville de naissance
96-
- Pays de naissance
97-
- Nationalité
98-
- Situation familiale
99-
- Tutelle ou curatelle (boolean field)
100-
101-
- **Informations complémentaires**:
102-
- Régime matrimonial
103-
- Numéro de securité sociale
169+
## Example Requests
104170

105-
- **Adresses et communication**:
106-
- Type (enum - example: adresse de communication)
107-
- Numéro
108-
- Voirie (example: Rue de la paix)
109-
- Ville
110-
- Code postal
111-
- Téléphone
112-
- Email
171+
### Create an Individual
113172

114-
The person can have another address ("adresse secondaire"). This secondary address can be flagged as "NPAI".
173+
```http
174+
POST /api/individuals
175+
Content-Type: application/json
115176
116-
## Example Requests
177+
{
178+
"personalInfo": {
179+
"firstName": "Jean",
180+
"lastName": "Dupont",
181+
"birthDate": "1980-01-01",
182+
"birthCity": "Paris",
183+
"birthCountry": "France",
184+
"nationality": "Française",
185+
"maritalStatus": "Marié",
186+
"underGuardianship": false
187+
},
188+
"additionalInformation": {
189+
"matrimonialRegime": "Communauté de biens",
190+
"socialSecurityNumber": "1800175123456"
191+
},
192+
"addresses": [
193+
{
194+
"type": "DOMICILE",
195+
"number": "123",
196+
"street": "Rue de la Paix",
197+
"city": "Paris",
198+
"postalCode": "75001",
199+
"phone": "0123456789",
200+
"email": "jean.dupont@example.com",
201+
"isSecondary": false,
202+
"isUndeliverable": false
203+
}
204+
]
205+
}
206+
```
117207

118-
### Create a Person
208+
### Create a Legal Entity
119209

120210
```http
121-
POST /api/persons
211+
POST /api/legal-entities
122212
Content-Type: application/json
123213
124214
{
125-
"civilite": {
126-
"prenom": "Jean",
127-
"nom": "Dupont",
128-
"dateDeNaissance": "1980-01-01",
129-
"villeDeNaissance": "Paris",
130-
"paysDeNaissance": "France",
131-
"nationalite": "Française",
132-
"situationFamiliale": "Marié",
133-
"tutelleOuCuratelle": false
215+
"generalInformation": {
216+
"companyName": "Acme Corporation",
217+
"commercialId": "ACME123",
218+
"identifier": "ID12345",
219+
"mailReference": "ACME-MAIL",
220+
"siren": "123456789",
221+
"siret": "12345678900012",
222+
"legalForm": "SAS",
223+
"creationDate": "2010-01-01"
134224
},
135-
"informationsComplementaires": {
136-
"regimeMatrimonial": "Communauté de biens",
137-
"numeroSecuriteSociale": "1800175123456"
225+
"legalInformation": {
226+
"commerceRegisterNumber": "RCS PARIS B 123 456 789",
227+
"registrationDate": "2010-01-15",
228+
"registrationCountry": "France",
229+
"registrationPlace": "Paris",
230+
"fiscalYearEndDate": "12-31",
231+
"employeeCount": 250,
232+
"apeCode": "6201Z",
233+
"activitySector": "Software Development",
234+
"shareCapital": "100000€"
138235
},
139-
"adresses": [
236+
"legalRepresentative": {
237+
"name": "Marie Dubois",
238+
"position": "CEO",
239+
"email": "marie.dubois@acme.com",
240+
"phone": "0123456789",
241+
"startDate": "2010-01-01"
242+
},
243+
"addresses": [
140244
{
141245
"type": "DOMICILE",
142-
"numero": "123",
143-
"voirie": "Rue de la Paix",
144-
"ville": "Paris",
145-
"codePostal": "75001",
146-
"telephone": "0123456789",
147-
"email": "jean.dupont@example.com",
148-
"isSecondaire": false,
149-
"isNPAI": false
246+
"number": "1",
247+
"street": "Place de la Défense",
248+
"city": "Paris",
249+
"postalCode": "92400",
250+
"phone": "0123456789",
251+
"email": "contact@acme.com",
252+
"isSecondary": false,
253+
"isUndeliverable": false
150254
}
151255
]
152256
}
153257
```
154258

155-
### Update a Person
259+
### Update an Individual
156260

157261
```http
158-
PUT /api/persons/{id}
262+
PUT /api/individuals/{id}
159263
Content-Type: application/json
160264
161265
{
162-
"civilite": {
163-
"prenom": "Jean",
164-
"nom": "Dupont",
165-
"dateDeNaissance": "1980-01-01",
166-
"villeDeNaissance": "Lyon",
167-
"paysDeNaissance": "France",
168-
"nationalite": "Française",
169-
"situationFamiliale": "Divorcé",
170-
"tutelleOuCuratelle": false
266+
"personalInfo": {
267+
"firstName": "Jean",
268+
"lastName": "Dupont",
269+
"birthDate": "1980-01-01",
270+
"birthCity": "Lyon",
271+
"birthCountry": "France",
272+
"nationality": "Française",
273+
"maritalStatus": "Divorcé",
274+
"underGuardianship": false
171275
},
172-
"informationsComplementaires": {
173-
"regimeMatrimonial": "Séparation de biens",
174-
"numeroSecuriteSociale": "1800175123456"
276+
"additionalInformation": {
277+
"matrimonialRegime": "Séparation de biens",
278+
"socialSecurityNumber": "1800175123456"
279+
}
280+
}
281+
```
282+
283+
### Update a Legal Entity
284+
285+
```http
286+
PUT /api/legal-entities/{id}
287+
Content-Type: application/json
288+
289+
{
290+
"generalInformation": {
291+
"companyName": "Acme Corporation",
292+
"commercialId": "ACME123",
293+
"identifier": "ID12345",
294+
"mailReference": "ACME-MAIL",
295+
"siren": "123456789",
296+
"siret": "12345678900012",
297+
"legalForm": "SA",
298+
"creationDate": "2010-01-01"
299+
},
300+
"legalInformation": {
301+
"commerceRegisterNumber": "RCS PARIS B 123 456 789",
302+
"registrationDate": "2010-01-15",
303+
"registrationCountry": "France",
304+
"registrationPlace": "Paris",
305+
"fiscalYearEndDate": "12-31",
306+
"employeeCount": 500,
307+
"apeCode": "6201Z",
308+
"activitySector": "Software Development",
309+
"shareCapital": "500000€"
310+
},
311+
"legalRepresentative": {
312+
"name": "Pierre Martin",
313+
"position": "CEO",
314+
"email": "pierre.martin@acme.com",
315+
"phone": "0123456789",
316+
"startDate": "2020-01-01"
175317
}
176318
}
177319
```
@@ -184,20 +326,21 @@ Content-Type: application/json
184326
185327
{
186328
"type": "COMMUNICATION",
187-
"numero": "456",
188-
"voirie": "Avenue des Champs-Élysées",
189-
"ville": "Paris",
190-
"codePostal": "75008",
191-
"telephone": "0987654321",
192-
"email": "jean.dupont.pro@example.com",
193-
"isSecondaire": true,
194-
"isNPAI": false
329+
"number": "456",
330+
"street": "Avenue des Champs-Élysées",
331+
"city": "Paris",
332+
"postalCode": "75008",
333+
"phone": "0987654321",
334+
"email": "contact@example.com",
335+
"isSecondary": true,
336+
"isUndeliverable": false
195337
}
196338
```
197339

198340
## Data Generation
199341

200-
The project includes a data generation utility that can create a large number of random Person records in the database using [datafaker](https://www.datafaker.net/).
342+
The project includes a data generation utility that can create a large number of random Person records in the database
343+
using [datafaker](https://www.datafaker.net/).
201344

202345
### Generating Data
203346

@@ -209,7 +352,9 @@ Before generating data, make sure the PostgreSQL database is running. You can st
209352
docker-compose up -d
210353
```
211354

212-
Or if you have PostgreSQL installed locally, make sure it's running and has a database named "person" with the following credentials:
355+
Or if you have PostgreSQL installed locally, make sure it's running and has a database named "person" with the following
356+
credentials:
357+
213358
- Username: postgres
214359
- Password: postgres
215360

0 commit comments

Comments
 (0)