This app is divided in multiple packages :
backend
is responsible for the user authentication, pdf generation and some static data servingfrontend
contains the main app logicelectric-client
is responsible for generating typescript clients listed down belowThis package exports .ts files, this means each app using this package will build it using its own rules
erDiagram
chip {
text key PK
text text
text udap_id PK
text value PK
}
clause {
text id PK
text label
text value
}
delegation {
text createdBy PK,FK
text delegatedTo PK,FK
}
report {
text applicantAddress
text applicantName
text contacts
timestamp_without_time_zone createdAt
text createdByEmail FK
text decision
text furtherInformation
text id PK
timestamp_without_time_zone meetDate
text precisions
text projectCadastralRef
text projectDescription
text projectSpaceType
text redactedBy
text serviceInstructeur
text title
}
report_to_clause {
text clauseId FK
text id PK
text reportId FK
}
udap {
text address
text city
text completeCoords
text department
text email
text id PK
text name
text phone
boolean visible
text zipCode
}
user {
text email PK
text name
text password
text temporaryLink
text temporaryLinkExpiresAt
text udap_id FK
}
report_to_clause }o--|| clause : "clauseId"
delegation }o--|| user : "createdBy"
delegation }o--|| user : "delegatedTo"
report }o--|| user : "createdByEmail"
report_to_clause }o--|| report : "reportId"
user }o--|| udap : "udap_id"
To achieve this, every table containing "live" values must be created through the ElectricSQL proxy, with
ALTER TABLE table ENABLE ELECTRIC;
- Write migrations in
db/migrations/
and electrify tables usingALTER TABLE table ENABLE ELECTRIC;
pnpm electric:migrate
applys migrations to the proxy db and generate the clients described below
Multiple clients are needed for this app to work :
They all are generated automatically when applying migrations
-
An electric db client used by frontend to query from indexedDB and sync.
You can generate it using
pnpm electric-client generate:front
-
A Prisma db client used by backend to query from Postgres
You can generate it using
pnpm electric-client generate:back
-
An API client generated using
@fastify/swagger
andtyped-openapi
, used by the frontend to query the backendYou can generate it using
pnpm client:generate