How pakira-56a/aruaru-game works
Project’s Main Nature and Purpose
• This is a full-stack web application built on Rails 7.1.3, combining a game (memory matching game) with social posting and content sharing features.
• Its primary function is to serve as a communication tool where users post “あるある” (common quirks or typical features associated with various “界隈” or communities) and play a memory (神経衰弱) game based on these posts. It further supports social sharing (e.g., via X/Twitter) and integrates with external APIs like OpenAI.
Primary Components
— User Interface / Frontend:
• Web Pages: Views, layouts, JavaScript controllers, and assets (managed with TailwindCSS, DaisyUI, and Stimulus).
• Responsive design elements for mobile priority.
— Backend / Application Server (Rails):
• Controllers, Models, and Views following the MVC pattern.
• Service objects (e.g., OpenAIService) and custom modules (e.g., ogp_creator, custom_authentication_failure).
• Middleware for authentication (using Devise, OmniAuth for Google sign-in).
• Jobs, mailers, and channels (for real-time communication if used).
— Database:
• PostgreSQL for persistent storage, including tables for users, posts, tags, likes, and the specific columns for “あるある” entries (aruaru_one to aruaru_five).
— External Service Integrations:
• OpenAI API for AI-generated content.
• Google Analytics for tracking.
• AWS S3 (through CarrierWave configuration) for image storage.
• Render.com for deployment infrastructure.
• External sharing via X (Twitter) for social features.
• Cookie-based session management to limit certain features (e.g., one AI generation per day).
— Development & Deployment:
• Docker (Dockerfile, Dockerfile.dev) for containerization.
• Configuration files (Procfile.dev, GitHub workflows, Uptime Robot usage) for deployment and continuous integration.
Relationships and Interactions
• Web clients (browsers on mobile/desktop) interact with the Rails application server via HTTP(S).
• The controllers render views and respond to user interactions (game play, posting, and searching).
• The business logic (models, services) manages data transformations, game rules, and interaction with the OpenAI API.
• Persistent state is maintained in PostgreSQL.
• Uploaded images (for posts, ogp generation) are handled via CarrierWave and stored on AWS S3.
• When a request for AI generation is made, the application invokes the OpenAIService which communicates directly with the OpenAI API. Cookie-based session limits are checked before the API call is allowed.
• External redirects: After game completion or share actions, users are directed to X (Twitter) for social interaction.
Architectural Patterns and Technologies
• The organization follows the MVC design pattern, with clear separation between presentation (views/assets), business logic (controllers/models/services), and persistence (database).
• Frontend enhancements employ modern JavaScript patterns (Stimulus controllers) with TailwindCSS for styling.
• Authentication is managed with Devise and OmniAuth.
• For asynchronous or background tasks, Rails jobs are used.
• Infrastructure and deployment leverage Docker, Render.com, and GitHub Actions workflows for testing.
Detailed Elements
• Annotations for security measures (cookie session management for daily limits, CSRF/XSS protection in the configuration).
Happy diagramming!