Here's a comprehensive architecture layout, technology stack, and a clear prompt for Cursor, tailored to your specific requirements:
Application Architecture Overview
The application will follow a modern Client-Server Architecture, leveraging a RESTful API for communication between the frontend and backend. Given the focus on mobile (especially iPhone) and user experience for the target persona, a Progressive Web App (PWA) approach will be considered for future enhancements, providing a native-like feel without the need for app store distribution.
1. Architectural Design:
- Frontend (Client-side): A Single-Page Application (SPA) responsible for rendering the user interface, handling user interactions, and making API calls to the backend. It will be built with a "mobile-first" and "responsive" design philosophy, ensuring an optimal experience on various screen sizes, especially iPhones.
- Backend (Server-side): An API server responsible for handling business logic, user authentication/authorization, data validation, and persistent storage management. It will expose a set of RESTful endpoints.
- Database: A relational database for structured data storage, ensuring data integrity and relationships between different entities (users, pain entries, food entries).
- Security: Robust security measures will be implemented across all layers, including secure authentication (e.g., JWT), password hashing, and encrypted communication (HTTPS). Data privacy is paramount.
2. Basic Functionalities (MVP):
- User Management:
- Registration: New user sign-up with email and password.
- Login: Secure user authentication.
- Profile Management: Basic user profile viewing (future: editing).
- Password Management: Secure password hashing and potential reset (future: forgot password).
- Pain Logging:
- Add Pain Entry: Users can log a new pain entry including: date/time, pain level (e.g., 1-10 scale), pain location(s), description of pain, activities hindered, mood, and any additional notes.
- View Pain Entries: Display a chronological list of all pain entries.
- Edit/Delete Pain Entry: Modify or remove existing pain entries.
- Basic Visualization: Simple charts/graphs to show pain trends over time (e.g., daily average, weekly peaks).
- Food Logging:
- Add Food Entry: Users can log food items including: date/time, food item name, description/details, quantity, meal type (breakfast, lunch, dinner, snack), and notes.
- View Food Entries: Display a chronological list of all food entries.
- Edit/Delete Food Entry: Modify or remove existing food entries.
- Dashboard:
- A personalized landing page upon login showing recent logs and quick entry options.
- Mobile Responsiveness: All UI elements must be large, clear, and easy to interact with on touchscreens, considering the target persona's potential dexterity challenges (e.g., from RA).
Frameworks and Programming Languages to Use
- Frontend:
- Language: JavaScript (with an eye towards TypeScript for future type safety).
- Framework/Library: React.js (well-suited for SPAs, strong community, component-based, and good for PWA integration).
- Build Tool: Vite (for fast development and build performance with React).
- Styling: Tailwind CSS (utility-first CSS framework, excellent for rapid responsive design and fine-grained control over styling, crucial for mobile-first approach).
- Routing:
react-router-dom.
- Backend:
- Language: JavaScript/Node.js.
- Framework: Express.js (a minimalist and flexible Node.js web application framework, ideal for building RESTful APIs).
- Authentication:
jsonwebtoken (for JWTs) and bcrypt.js (for secure password hashing).
- Database ORM/Client:
pg (Node.js PostgreSQL client) or a lightweight ORM like Knex.js for query building.
- Database:
- Type: PostgreSQL (a powerful, open-source, and highly reliable relational database, ideal for structured data and scalability).
Database Schema (Core MVP Tables)
Users Table:
id (PRIMARY KEY, UUID or Serial)
email (UNIQUE, VARCHAR)
password_hash (VARCHAR, for bcrypt output)
created_at (TIMESTAMP WITH TIME ZONE, DEFAULT CURRENT_TIMESTAMP)
updated_at (TIMESTAMP WITH TIME ZONE)
PainEntries Table:
id (PRIMARY KEY, UUID or Serial)
user_id (FOREIGN KEY to Users.id)
date_time (TIMESTAMP WITH TIME ZONE)
pain_level (INTEGER, e.g., 1-10)
pain_location (TEXT)
pain_description (TEXT, optional)
activities_hindered (TEXT, e.g., comma-separated list or JSONB for multiple values)
mood (TEXT, e.g., 'happy', 'neutral', 'sad', 'tired')
notes (TEXT, optional)
created_at (TIMESTAMP WITH TIME ZONE, DEFAULT CURRENT_TIMESTAMP)
updated_at (TIMESTAMP WITH TIME ZONE)
FoodEntries Table:
id (PRIMARY KEY, UUID or Serial)
user_id (FOREIGN KEY to Users.id)
date_time (TIMESTAMP WITH TIME ZONE)
food_item_name (VARCHAR)
food_description (TEXT, optional, e.g., ingredients)
quantity (VARCHAR, e.g., "1 cup", "2 slices")
meal_type (VARCHAR, e.g., 'Breakfast', 'Lunch', 'Dinner', 'Snack')
notes (TEXT, optional)
created_at (TIMESTAMP WITH TIME ZONE, DEFAULT CURRENT_TIMESTAMP)
updated_at (TIMESTAMP WITH TIME ZONE)
Clear Ask for Cursor IDE to Build the App
"Cursor, I need your immediate assistance to scaffold and set up the foundational architecture for a pain and food logging web application. The target audience is women over 40 with Rheumatoid Arthritis, so mobile-first design, intuitive UX, and large, easy-to-tap elements are crucial for the frontend. We aim for a Progressive Web App (PWA) potential in the future, but for now, focus on a robust, responsive web app.
Here's the detailed request for project setup:
-
Project Goal: Build a web-based pain and food logging application for women with Rheumatoid Arthritis, prioritizing mobile (iPhone) user experience.
-
Target Architecture:
- Frontend: React.js SPA, built with Vite, styled with Tailwind CSS.
- Backend: Node.js with Express.js for a RESTful API.
- Database: PostgreSQL.
- Authentication: JWT-based.
-
Initial Project Setup & Files:
- Root Directory: Create a project root.
frontend Directory:
- Initialize a new React project using Vite.
- Configure Tailwind CSS for the React project.
- Set up
react-router-dom for basic client-side routing.
- Create placeholder React components/pages:
src/App.jsx (main component)
src/components/Layout.jsx (for shared header/footer/navigation)
src/pages/HomePage.jsx (placeholder for dashboard after login)
src/pages/LoginPage.jsx (with a basic login form structure)
src/pages/RegisterPage.jsx (with a basic registration form structure)
src/pages/PainLogPage.jsx (placeholder for adding/viewing pain entries)
src/pages/FoodLogPage.jsx (placeholder for adding/viewing food entries)
- Ensure the
index.css or equivalent is set up for Tailwind imports and basic global styles.
- Add a basic
fetch or axios setup to interact with the backend API.
backend Directory:
- Initialize a new Node.js project (
package.json).
- Install Express, dotenv, pg, bcryptjs, and jsonwebtoken.
- Create
server.js (or app.js) as the main entry point for the Express server.
- Set up basic CORS configuration for frontend interaction.
- Create a
config directory with db.js for PostgreSQL connection pooling (using pg library), reading credentials from environment variables.
- Create
routes directory with:
Expected Output:
Please generate the file structure, boilerplate code for each component/file, and the initial setup instructions in the README.md. Focus on getting the core project runnable with placeholders for the actual logic."