How hitusss/cs-grenade works
Project type and purpose
• This is a full‐stack, server‐rendered React web application built on a Remix-style framework.
• Purpose: allow Counter-Strike 2 players to browse interactive maps, view and submit grenade guides, manage content via an admin dashboard, and handle user authentication/authorization.
File structure
• app/components, app/hooks, app/utils, app/models: React UI, custom hooks, utilities, and data-access logic.
• app/routes & routes.ts: file-based routing (loaders/actions serve data, React components render pages).
• server/index.ts + server/dev-server.js: custom Node server entry points for production and development.
• prisma/: database schema, migrations, and seed scripts using Prisma ORM.
• other/: Docker and LiteFS configuration for Fly.io deployment.
• Vite, Tailwind CSS, and TypeScript config files.
• .github/workflows/deploy.yml: CI/CD pipeline.
README
• Confirms core features: interactive map navigation, guides, user submissions, and an admin dashboard.
• Instructs local development with pnpm, environment variables, and dev server.
Main components & interactions
a. Frontend (Browser + React/Remix)
• entry.client.tsx hydrates on the client.
• React components under app/components drive the UI.
• Tailwind CSS handles styling.
b. Server (Node/Remix runtime)
• entry.server.tsx + server/index.ts run all route loaders/actions.
• app/routes/* define URL endpoints, server logic, and rendering.
c. Database (Prisma + SQLite or Postgres + LiteFS)
• prisma/schema.prisma defines all models (maps, grenades, users, sessions, permissions, reports, etc.).
• LiteFS (in other/litefs.yml) ensures SQLite durability on Fly.io.
d. Authentication & Authorization
• OAuth providers (Discord, GitHub) via app/utils/providers.
• Session management in app/utils/session.server.ts.
• Role/permission checks in app/utils/permissions.server.ts.
e. File & Media Storage
• Static assets served from public/.
• Dynamic images and other resources via routes/resources/*.tsx endpoints.
f. External Services
• Email server (via app/utils/email.server.ts).
• Monitoring/analytics (app/utils/monitoring.client.ts, server/utils/monitoring.ts).
• CI/CD: GitHub Actions → Docker build → Fly.io deployment.
g. Testing
• Playwright E2E (tests/e2e) and unit tests (tests).
Architectural patterns & design principles
• File-based routing (Remix convention).
• SSR with client hydration for interactivity.
• MVC-like separation: routes (controllers), models (Prisma ORM), views (React components).
• Feature modularization: group by domain (maps, grenades, admin, auth).
• Use of middleware utilities (auth.server, cache.server, honeypot.server).