How wjsoj/phybench-website works
Main Components
• User Interface (UI) / Frontend:
• Represented by the Next.js “app” directory (src/app), which includes pages for various functions such as admin actions (e.g., calculate score, download problem, examine control), chat, problem views, submissions, and profiles.
• The “components” directory (src/components) houses reusable UI components (cards, buttons, modals) and feature-specific components (e.g., chat components, markdown editors, and admin panels).
• Server/API Layer:
• The API routes are under src/app/api. They cover authentication (using NextAuth, as indicated by the auth folder), chat (completions and standard routes), and various data retrieval endpoints (like getproblem, getexamineproblems, getuser, and others).
• This layer is responsible for handling business logic, authentication, and interfacing between the frontend and the database.
• Database:
• The Prisma folder contains the schema file (prisma/schema.prisma) and numerous migration directories that detail changes to the database over time.
• The connection is likely managed through a Prisma client (see src/prisma.ts).
• Supporting Infrastructure:
• Containerization: Dockerfile and docker-compose.yml indicate that the app can be containerized for consistent deployments.
• CI/CD: The .github/workflows directory contains build, test, and deploy configuration files.
• Testing: The __tests__ directory and Vitest configuration files (vitest.config.ts, vitest.setup.ts) show that unit and integration tests are in place.
• Configuration & Tooling: Files like next.config.ts, tailwind.config.mjs, eslint.config.mjs, and various TypeScript config files set up the development environment.
• Database connectivity:
• Integration with CI/CD and Deployment:
Architectural Patterns and Design Principles
• Next.js approach that merges frontend and backend logic (co-located API routes and page components).
• Design patterns such as:
• Component-based UI (React components).
• API Gateway-like behavior for handling various routes (authentication, chat, data).
• Modularization in the codebase (distinct directories for app pages, components, lib functions, and mocks for testing).
• That the API endpoints are arranged by functionality (e.g., auth, data, chat), making the architecture clear and maintainable.
Relevant Technologies and Tools
• Next.js: for both server-side rendering and API route handling.
• React: along with functional components and hooks (visible in src/components and src/lib/hooks.tsx).
• Prisma: for ORM and database migrations.
• Docker & docker-compose: containerization and local environment simulation.
• GitHub Workflows and testing tools (Vitest) for streamlined CI/CD and quality assurance.
• Tailwind CSS (configured via tailwind.config.mjs) for styling.