projects
Status: implemented (services/projects, contract: docs/dev/phase4-contracts.md, Projects service; specs:
features.md "Project management"). Runs in the apps profile of docker-compose.yml on port 8088 and is
reached through the gateway route /v1/projects. Web screens: /app/projects.
Role: most activity is organised around projects (an order becomes a project). The service owns the project aggregate (lifecycle, details, members list), its needs, products to make and manual cost entries, and aggregates the costs. It bootstraps the default project roles in authz, which stays the source of truth for membership and rights.
Limits: no deadlines, no time tracking. Project roles, assignments and project API keys are managed through
the authz project endpoints (/v1/authz/projects/{id}/roles, /v1/authz/projects/{id}/api-keys), not here.
Files are stored by files; linked events, inventory items and borrowing sheets live in their own
services and only reference the project ID. Finance purchases are an extension point of the cost aggregation.
Model
- Project (event sourced, aggregate
project):name(1–200),description(≤ 5000),site_id(slug, fixed after creation),owner_id(Keycloak ID of the creator),owner_erased,status,customer_id(optional finance customer ULID, ID only),tags(≤ 20, ≤ 32 chars each),member_ids,roles(provisioning state),created_at,updated_at,status_changed_at, soft deletedeleted_at/purge_at. - Lifecycle:
draft → quoted → in_progress → delivered → invoiced → closed, pluscancelledfrom any non-final state.
| From | Allowed targets |
|---|---|
draft | quoted, in_progress, cancelled |
quoted | draft, in_progress, cancelled |
in_progress | delivered, cancelled |
delivered | invoiced, closed, cancelled |
invoiced | closed, cancelled |
closed, cancelled | final |
- Need:
kind(material|tool|consumable|product),description,quantity(> 0),unit(defaultpiece), optionalitem_id(inventory) andpurchase_request_id,status(planned|requested|ordered|available). - Product to make:
name,quantity(≥ 1),done_quantity(≤ quantity),notes. - Manual cost entry:
label,amount_cents(non-zero, negative for refunds),currency(EURonly),date,created_by. - Search: normalised token index (
search_terms, lowercased, accents removed) on the name and tags;qrequires every query word to prefix-match a term.
ARNs: atl:projects:<site>:project/<id> (parent atl:settings:<site>:site/<site>), sub-resources
.../need/<id>, .../product/<id>, .../cost/<id> (audit records).
Project roles and members
On creation the service, acting as a service principal (token signed with PRINCIPAL_SIGNING_KEY), calls the
authz REST API for the project (?site=<site>):
- lists the project roles and reuses those named
Responsable/Participant(idempotent); - creates the missing ones, grants on
atl:projects:<site>:project/<id>/*:Responsable: everyproject-scoped permission of the catalogue;Participant:projects.project.read,projects.file.read,projects.file.write,events.event.create,inventory.issue.report,finance.purchase.request;
- assigns the owner to
Responsable(existing assignments are kept).
While authz is unreachable the project is saved anyway with roles.state = pending (attempts, last_error,
next_attempt_at with exponential backoff); the lease job projects-provision retries every
PROJECTS_PROVISION_INTERVAL, and POST /v1/projects/{id}/provision retries immediately. Once done,
roles.state = ready with manager_role_id / participant_role_id. The owner keeps every project permission
on their project in the meantime (checked locally).
member_ids = the owner (unless erased) plus every user holding an active assignment on a role of the project. It is
kept in sync by the consumer (group projects-sync):
authz.role.v1: project roles are recorded inproject_roles(role → project); a deleted role deactivates its memberships;authz.assignment.v1: user assignments are recorded inmemberships; a role not seen yet is resolved throughGET /v1/authz/roles/{id}with the service principal;- every change of the set publishes
member_added/member_removed.
Authorization
| Action | Rule |
|---|---|
| Read a project, its needs, products, costs | owner, member, projects.project.read on the project, or projects.project.read_all (elevated, admin mode); otherwise 404 |
| Create | projects.project.create on the new project ARN (site parent); the default Membre role has it everywhere |
| Edit details, change status, manual costs, retry provisioning | owner or projects.project.update |
| Delete | owner or projects.project.delete |
| Edit needs and products | any project member or projects.project.update (no dedicated catalogue permission) |
| List | Lookup scope of projects.project.read (+ read_all in admin mode), always including the caller's projects; mine=true keeps only them |
GET /v1/projects/{id} returns capabilities (update, delete, manage_roles, manage_api_keys,
files_read, files_write, edit_needs) so that the web app hides forbidden actions.
Files: owner atl:projects:<site>:project/<id> (projects.file.read / projects.file.write). The service is
a files delegate (FILES_DELEGATES entry projects=http://projects:8088): POST /internal/v1/attachments/authorize allows reading to the owner and members and writing to the owner, so access
works while roles are being provisioned.
HTTP API
OpenAPI: API reference (services/projects/openapi.yaml). Lists are cursor paginated.
| Method | Path | Notes |
|---|---|---|
| GET | /v1/projects?site&status&mine&q&tag&customer | visible projects |
| POST | /v1/projects | creates (draft) and provisions roles |
| GET, PATCH, DELETE | /v1/projects/{id} | detail with capabilities; patch name, description, customer, tags; soft delete |
| POST | /v1/projects/{id}/status | validated transition |
| POST | /v1/projects/{id}/provision | retry role provisioning |
| GET, POST | /v1/projects/{id}/needs | filters status, kind |
| PATCH, DELETE | /v1/projects/{id}/needs/{sub} | |
| GET, POST | /v1/projects/{id}/products | |
| PATCH, DELETE | /v1/projects/{id}/products/{sub} | |
| GET | /v1/projects/{id}/costs | manual + inventory consumption (+ purchases later) in cents |
| GET, POST | /v1/projects/{id}/costs/entries | manual entries |
| PATCH, DELETE | /v1/projects/{id}/costs/entries/{sub} | |
| POST | /internal/v1/attachments/authorize | files delegate, not routed by the gateway |
Costs: inventory consumption comes from GET /v1/inventory/projects/{id}/costs called with the caller
principal (euros converted to cents); when inventory is down or denies the caller, the section is returned with
available: false and excluded from the total.
Kafka
| Kind | Name | Notes |
|---|---|---|
| out | projects.project.v1 | created, updated (field names), status_changed (from, to), member_added, member_removed (user ID), deleted |
| out | audit.records.v1 | every write (projects.project.*, projects.need.*, projects.product.*, projects.cost.*), IDs only |
| in | authz.role.v1, authz.assignment.v1 | members sync (group projects-sync) |
| in | members.member.v1 | members.member.erased: memberships removed, user removed from member_ids, owner flagged owner_erased |
Data (MongoDB projects)
| Collection | Content |
|---|---|
projects | project state (indexes on site_id, status, member_ids, owner_id, tags, search_terms, customer_id with _id; provisioning and purge) |
events | event log (eventstore) |
needs, products, cost_entries | sub-resources (project_id, _id) |
project_roles | role ID → project ID |
memberships | assignment ID → project, role, user, active |
outbox, leases | pending Kafka messages, lease jobs |
Jobs
projects-provision(everyPROJECTS_PROVISION_INTERVAL): retries pending role provisioning.projects-purge(everyPROJECTS_PURGE_INTERVAL): afterPROJECTS_PURGE_DELAY, deletes the project roles in authz, then the state, needs, products and cost entries (the event log is kept). A failing authz call postpones the purge to the next run.
Configuration
| Variable | Default | Description |
|---|---|---|
HTTP_ADDR | :8088 | Listen address |
METRICS_ADDR | :9188 | Prometheus listener |
MONGO_URI, MONGO_DATABASE | mongodb://localhost:27017/?directConnection=true, projects | MongoDB |
KAFKA_BROKERS | localhost:19092 | Outbox relay and consumer |
PRINCIPAL_PUBLIC_KEY | required | Verifies X-Atl-Principal |
PRINCIPAL_SIGNING_KEY | required | Service identity for authz calls |
AUTHZ_URL | http://localhost:8081 | authz REST and ConnectRPC |
INVENTORY_URL | http://localhost:8085 | inventory costs |
PROJECTS_PROVISION_INTERVAL | 30s | provisioning retry job period |
PROJECTS_PURGE_DELAY | 720h | soft delete → purge delay |
PROJECTS_PURGE_INTERVAL | 1h | purge job period |
Plus the common APP_ENV, LOG_LEVEL, OTEL_EXPORTER_OTLP_ENDPOINT (see
environment variables).