How amano216/minori works
Project Type and Purpose
• This is a full-stack web application composed of a Ruby on Rails 7 API backend and a React/TypeScript SPA frontend.
• It targets home-visit nursing (“訪問看護”) agencies, providing an integrated contract/signature management, user/office administration, and reporting system.
File Structure Analysis
• Top-level services (in docker-compose.yml):
• web (Rails API)
• frontend (esbuild watch)
• css (Tailwind watch)
• Backend
• app/controllers/api/v1: RESTful JWT-protected endpoints
• app/models / app/repositories: ActiveRecord + repository pattern
• app/services: business logic (PDF generation, JWT service, contract workflows)
• app/domains: domain–driven design with events, value objects, domain services
• app/jobs & app/mailers: background processing & emails
• config/storage.yml: ActiveStorage adapters (local/S3)
• config/cable.yml & app/channels: WebSocket (ActionCable) support
• Frontend
• app/javascript: React components, pages, hooks, Zustand stores
• api client modules under app/javascript/api
• Tailwind CSS for styling, esbuild for bundling
• Infrastructure
• PostgreSQL (primary data store)
• Redis (caching, job queue/Siderkiq support, token cleanup)
• Docker Compose orchestrates web, js, css services
• Sidekiq (implied by background jobs/cron docs)
Key Architectural Patterns
• API-First separation: React SPA communicates via /api/v1 over JWT
• Domain-Driven Design: app/domains split by subdomains (office, user, contract), with domain events
• Repository and Service layers to decouple ActiveRecord from business logic
• Background jobs (ActionMailer, cleanup, metrics) via Sidekiq
• Pundit for authorization policies
Components
a. Client Layer
• Browser (React SPA)
• Static assets served by Rails (or separate CDN)
b. API Layer
• Rails API containers:
• Controllers → ApplicationController → Api::V1 namespace
• Authentication: Devise + JWTService → token lifecycle endpoints
• Authorization: Pundit policies
c. Domain & Persistence
• Domain modules (business rules, events)
• Repository layer → ActiveRecord models → PostgreSQL
• ActiveStorage → file/PDF attachments → S3 or local disk
d. Background Processing
• Sidekiq queue (Redis)
• Jobs for email, token cleanup, PDF gen
e. Real-time
• ActionCable WebSocket server → Redis pub/sub
f. Infrastructure
• Docker Compose (web, frontend, css)
• PostgreSQL database
• Redis instance
• External email service (SMTP)
Relationships & Data Flow
1) User in browser loads React SPA
2) SPA calls /api/v1 endpoints (login, contracts, offices, signature requests)
3) Rails API authenticates (JWT), authorizes (Pundit), routes to controllers
4) Controller invokes service/repository/domain layers
5) Data persisted to PostgreSQL; domain events dispatched
6) File uploads → ActiveStorage → bucket
7) Background jobs enqueued in Redis → Sidekiq processes (email, cleanup, metrics)
8) ActionCable pushes real-time updates (e.g. signature completion)