How olalkeith/personal-journal-app works
Main Components
• Frontend: Represent the Next.js application layer where the browser-based UI is rendered (using pages in src/app and src/pages). Include components for layout, global CSS, and any reusable UI components.
• API Layer (Backend): Split into two parts:
• REST API Routes: Found under src/pages/api (with routes for authentication, journal CRUD operations).
• GraphQL API: Hosted under src/graphql (with schema and resolvers). Indicate how GraphQL integrates and serves client requests.
• Database: PostgreSQL is used for persistent data storage, accessed through Prisma. Show the connection between API handlers and the Prisma ORM.
• Authentication/Authorization: Highlight the user authentication mechanism (JWT-based with helpers in src/lib/auth.ts and permissions in src/lib/permissions.ts) securing the login and registration endpoints.
• Supporting Infrastructure:
• Testing: Display testing infrastructure for automated tests, referencing Jest (unit tests) and Cypress (e2e tests) as separate components.
• Migrations and Seeding: Include the Prisma migrations (prisma/migrations) and seed scripts as part of the database setup.
Relationships and Data Flows
• Data interactions between the API servers and the PostgreSQL database through the Prisma client (located in src/lib/prisma.ts).
• That authentication requests (login, register) interact with the authentication logic (JWT and bcrypt) and then update or query the database.
Architectural Patterns and Design Principles
• Full-Stack Separation: Clearly delineate between the client-side rendered UI (Next.js pages/components) and the server-side API (Next.js API routes).
• Modular Design: Highlight modularization by showing separate components for GraphQL, REST API endpoints, and utility libraries.
• Security: Emphasize authentication and authorization mechanisms ensuring proper validation before database operations.
Relevant Technologies
• Frontend: Next.js with TypeScript (show pages, global styles, and components).
• Backend: Next.js API routes (for REST endpoints) and GraphQL schema/resolvers.
• Database: PostgreSQL with migrations and seeding via Prisma.
• Authentication: JWT with jsonwebtoken and bcrypt.
• Testing: Use Jest for unit testing and Cypress for end-to-end testing.
• Others: ESLint, Husky (for pre-commit hooks), and supporting configuration files.
Final Advice
• Every significant interaction—especially between the UI, API endpoints, and the database.