How cylab-africa/rri_backend works
Main Components of the System
• Backend Application:
• Entry point (index.js) that initializes the Node.js server.
• Controllers (located under src/controllers) that handle various request routes (e.g., authController.js, evaluationControllers.js, testController.js).
• Middleware (under src/middleware) to manage pre-processing of requests, such as authorization.
• Utility functions (under src/utilities), e.g., for generating tokens, adding questions, or calculating scores.
• An “auth” module (the separate auth directory) that likely provides additional authentication logic.
• Database:
• Postgres database as described in the README (with a database named “test”).
• Prisma configuration (located under src/db/configs/prisma), providing schema definitions and migrations that set up your database structure.
• Testing Infrastructure:
• Jest configuration and test files (e.g., src/jest.config.js, src/jest.setup.js, and tests in src/utilities/tests).
• Deployment & DevOps:
• Dockerfile and .dockerignore indicate containerization.
• Kubernetes-deployment.yml and files under .github/workflows suggest automated CI/CD and orchestration.
Relationships and Interactions
• The Node.js server (index.js) receives HTTP requests which are routed to the appropriate controllers.
• Controllers call middleware functions (such as authorization) before proceeding to process requests.
• After processing, the controllers interact with the database through Prisma (using the schema defined under src/db/configs/prisma).
• Utility functions support all these layers with shared functionality (e.g., token generation for auth or question initialization for database seeding).
• External setup scripts like init.sql and addQuestions.js indicate methods to initialize the database.
• On the deployment side, Docker and Kubernetes components ensure the service can be containerized and orchestrated in production.
Architectural Patterns & Key Technologies
• The project reflects a modular Node.js backend (likely using an MVC-like structure, where controllers, middleware, and utilities are separated).
• Use of Prisma ORM bridges the interaction with the PostgreSQL database.
• Testing and configuration files denote adherence to modern development practices (Jest for testing; CI/CD with GitHub Actions).
• Containerization (Docker) and orchestration (Kubernetes) are used to manage deployment and scalability.