Create a backend service using Node.js that manages data between multiple tables with various relationships. The service should authenticate requests using an API key and optionally include an authentication mechanism using Self-Sovereign Identity (SSI) based on the Aries framework.
-
Setup and Configuration:
- Use Node.js with the NestJS framework.
- Use Prisma as the ORM.
-
Database Design:
- Tables:
Users
Groups
Interests
- Relationships:
Users
&Groups
: Many-to-many relation.Users
&Interests
: One-to-many relation.
- Tables:
-
Endpoints:
- CRUD operations for each table.
- Endpoint to add a user to a group.
- Endpoint to remove a user from a group.
- Endpoint to retrieve all groups for a specific user.
- Endpoint to retrieve all interests for a specific user.
-
Authentication:
- Simple API Key-based authentication:
- Requests should include an
x-api-key
header. - Store a valid API key in an environment variable.
- Requests should include an
- [Bonus] Self-Sovereign Identity (SSI) using the Aries framework:
- Implement a basic connection protocol.
- Store DIDs after verification.
- Simple API Key-based authentication:
-
Testing:
- Unit tests for GET requests:
- Retrieve a user.
- Retrieve groups for a user.
- Retrieve interests for a user.
- Integration test to simulate adding a user to a group.
- Unit tests for GET requests:
-
GitHub Repository:
- Contains the backend code.
- Includes a README with setup instructions.
- Features an
npm start
script for easy testing.
-
Documentation:
- Endpoint descriptions.
- Additional assumptions or decisions.
-
API Collection:
- Postman or equivalent tool setup for testing.
-
Code Quality:
- Clarity and modularity.
- Error handling.
- Proper use of async/await.
-
Database Design:
- Normalization.
- Relationship setup in Prisma.
-
Authentication:
- API key authentication implementation.
- [Bonus] SSI implementation.
-
Testing:
- Scenario coverage.
- Test correctness.
-
Bonus:
- NestJS best practices: modules, decorators, and guards.
- Provide Postman/Insomnia collections for the API.