You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,7 +14,6 @@ This project follows Domain-Driven Design (DDD) principles and Clean Architectur
14
14
## Features
15
15
16
16
- CRUD operations for Person entities
17
-
- Search functionality
18
17
- Address management
19
18
- Domain events for tracking changes
20
19
- Data generation utility for creating test data
@@ -35,15 +34,16 @@ This project follows Domain-Driven Design (DDD) principles and Clean Architectur
35
34
```
36
35
37
36
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"
40
39
41
40
2. Build and run the application:
42
41
```
43
42
./gradlew run
44
43
```
45
44
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.
47
47
48
48
### Using Individual Docker Containers
49
49
@@ -70,108 +70,250 @@ The API will be available at `http://localhost:8080`.
70
70
71
71
### Person Endpoints
72
72
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)
75
74
-`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
78
75
-`DELETE /api/persons/{id}` - Delete a person
79
76
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
+
80
87
### Address Endpoints
81
88
82
89
-`POST /api/persons/{id}/addresses` - Add an address to a person
83
90
-`DELETE /api/persons/{personId}/addresses/{addressId}` - Remove an address from a person
84
91
85
92
## Data Model
86
93
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)
90
168
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
104
170
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
113
172
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
115
176
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
+
```
117
207
118
-
### Create a Person
208
+
### Create a Legal Entity
119
209
120
210
```http
121
-
POST /api/persons
211
+
POST /api/legal-entities
122
212
Content-Type: application/json
123
213
124
214
{
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"
134
224
},
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€"
138
235
},
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": [
140
244
{
141
245
"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
150
254
}
151
255
]
152
256
}
153
257
```
154
258
155
-
### Update a Person
259
+
### Update an Individual
156
260
157
261
```http
158
-
PUT /api/persons/{id}
262
+
PUT /api/individuals/{id}
159
263
Content-Type: application/json
160
264
161
265
{
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
171
275
},
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",
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/).
201
344
202
345
### Generating Data
203
346
@@ -209,7 +352,9 @@ Before generating data, make sure the PostgreSQL database is running. You can st
209
352
docker-compose up -d
210
353
```
211
354
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
0 commit comments