forked from jamesp/sasa-membership
Add member profile questions, admin tooling, legal pages, and fast tests
- Add configurable profile questions with conditional visibility, admin-only fields, user answers, and seeded onboarding/volunteer questions
- Add admin UI for managing profile questions and member profile answers
- Add volunteer level/profile data support across backend schemas, models, API, and migration
- Update dashboard/profile UI, super admin menu, membership service types, and related styling
- Add privacy policy, terms of service, cookie notice, and footer links
- Add frontend Vitest coverage for profile question logic
- Add backend pytest coverage for profile answer normalization and validation
- Update restart.sh to build, run frontend/backend unit tests, and restart only after tests pass
- Refresh README, quickstart, project structure, instructions, and Square docs to match current app features
- Protect feature flag reload behind super-admin access
- Restrict admin-triggered password resets so admins can only reset member accounts
- Replace email template HTML preview rendering with escaped text preview
- Update docs for feature flag reload access, password reset scope, and email template preview safety
-- test user questions are also made by AI and not very useful. but i didn't know what to put there so its good enough for a test
This commit is contained in:
+110
-76
@@ -2,115 +2,149 @@
|
||||
|
||||
```
|
||||
membership/
|
||||
├── .env # Environment configuration (ready to use)
|
||||
├── .env.example # Template for environment variables
|
||||
├── .env # Local environment configuration
|
||||
├── .env.example # Environment variable template
|
||||
├── .gitignore # Git ignore rules
|
||||
├── docker-compose.yml # Docker services configuration
|
||||
├── INSTRUCTIONS.md # Original project requirements
|
||||
├── README.md # Complete documentation
|
||||
├── QUICKSTART.md # Quick start guide
|
||||
├── docker-compose.yml # Backend, frontend, gateway, and prod frontend services
|
||||
├── restart.sh # Build, run fast tests, and restart the app
|
||||
├── INSTRUCTIONS.md # Product requirements and roadmap context
|
||||
├── README.md # Full project documentation
|
||||
├── QUICKSTART.md # Short operator/developer guide
|
||||
│
|
||||
├── backend/ # FastAPI application
|
||||
│ ├── Dockerfile # Backend container configuration
|
||||
│ ├── requirements.txt # Python dependencies
|
||||
│ ├── Dockerfile
|
||||
│ ├── requirements.txt
|
||||
│ ├── alembic.ini
|
||||
│ ├── alembic/ # Database migrations
|
||||
│ └── app/
|
||||
│ ├── __init__.py
|
||||
│ ├── main.py # Application entry point
|
||||
│ │
|
||||
│ ├── api/ # API endpoints
|
||||
│ │ ├── __init__.py
|
||||
│ │ ├── dependencies.py # Auth dependencies
|
||||
│ ├── main.py # App, CORS, health check, router registration
|
||||
│ ├── api/
|
||||
│ │ ├── dependencies.py # Auth dependencies
|
||||
│ │ └── v1/
|
||||
│ │ ├── __init__.py
|
||||
│ │ ├── auth.py # Registration, login
|
||||
│ │ ├── users.py # User management
|
||||
│ │ ├── tiers.py # Membership tiers
|
||||
│ │ ├── memberships.py # Membership management
|
||||
│ │ └── payments.py # Payment processing
|
||||
│ │
|
||||
│ ├── core/ # Core functionality
|
||||
│ │ ├── __init__.py
|
||||
│ │ ├── config.py # Configuration settings
|
||||
│ │ ├── database.py # Database connection
|
||||
│ │ └── security.py # Auth & password hashing
|
||||
│ │
|
||||
│ ├── models/ # Database models
|
||||
│ │ ├── __init__.py
|
||||
│ │ └── models.py # SQLAlchemy models
|
||||
│ │
|
||||
│ ├── schemas/ # Pydantic schemas
|
||||
│ │ ├── __init__.py
|
||||
│ │ └── schemas.py # Request/response schemas
|
||||
│ │
|
||||
│ ├── services/ # Business logic (placeholder)
|
||||
│ └── utils/ # Utilities (placeholder)
|
||||
│ │ ├── auth.py # Register, login, password reset/change
|
||||
│ │ ├── users.py # Users, profile questions, profile answers
|
||||
│ │ ├── tiers.py # Membership tiers
|
||||
│ │ ├── memberships.py
|
||||
│ │ ├── payments.py # Manual, Square, refund, payment history
|
||||
│ │ ├── email.py # SMTP2GO email tests and bounce webhooks
|
||||
│ │ ├── email_templates.py
|
||||
│ │ ├── events.py # Events and RSVPs
|
||||
│ │ └── feature_flags.py
|
||||
│ ├── core/ # Config, database, security, default data
|
||||
│ ├── models/ # SQLAlchemy models
|
||||
│ ├── schemas/ # Pydantic schemas
|
||||
│ ├── services/ # Email, bounce, Square, feature flags
|
||||
│ └── tests/ # Fast backend pytest unit tests
|
||||
│
|
||||
├── database/ # Database initialization
|
||||
│ └── init.sql # Default data & admin user
|
||||
├── docker/
|
||||
│ └── gateway/ # Nginx dev gateway and self-signed TLS setup
|
||||
│
|
||||
└── frontend/ # Frontend (placeholder for future)
|
||||
└── frontend/ # React/Vite frontend
|
||||
├── Dockerfile
|
||||
├── package.json
|
||||
├── vite.config.ts
|
||||
└── src/
|
||||
├── App.tsx # Routes, footer links, cookie notice
|
||||
├── components/ # Dashboard, admin, payment, email, profile UI
|
||||
├── contexts/ # Feature flag context/provider
|
||||
├── pages/ # Login, register, dashboard, policy pages
|
||||
├── services/ # API clients
|
||||
└── utils/ # Shared frontend logic and Vitest tests
|
||||
```
|
||||
|
||||
## Key Files
|
||||
|
||||
### Configuration
|
||||
- **`.env`** - Environment variables (database, API keys, etc.)
|
||||
- **`docker-compose.yml`** - Services: MySQL + FastAPI backend
|
||||
- **`.env`** - Runtime configuration for database, auth, Square, SMTP2GO, ports, and gateway TLS.
|
||||
- **`docker-compose.yml`** - Services for FastAPI backend, Vite frontend, Nginx gateway, and production static frontend.
|
||||
- **`restart.sh`** - Rebuilds images, runs frontend/backend unit tests, and restarts the stack only if tests pass.
|
||||
|
||||
### Backend Application
|
||||
- **`backend/app/main.py`** - FastAPI app initialization, CORS, routes
|
||||
- **`backend/app/core/config.py`** - Settings management
|
||||
- **`backend/app/core/security.py`** - JWT tokens, password hashing
|
||||
- **`backend/app/models/models.py`** - Database tables (User, Membership, Payment, etc.)
|
||||
- **`backend/app/schemas/schemas.py`** - API request/response models
|
||||
- **`backend/app/main.py`** - FastAPI app initialization, CORS, startup default-data seeding, routes, and health checks.
|
||||
- **`backend/app/core/config.py`** - Settings management.
|
||||
- **`backend/app/core/init_db.py`** - Default membership tiers, super admin, email templates, and profile questions.
|
||||
- **`backend/app/core/security.py`** - JWT tokens and password hashing.
|
||||
- **`backend/app/models/models.py`** - Database tables.
|
||||
- **`backend/app/schemas/schemas.py`** - API request/response models.
|
||||
- **`backend/app/tests/test_profile_question_logic.py`** - Fast backend unit tests for profile answer validation.
|
||||
|
||||
### API Endpoints (v1)
|
||||
- **`auth.py`** - Register, login
|
||||
- **`users.py`** - User profile, admin user management
|
||||
- **`tiers.py`** - Membership tier CRUD
|
||||
- **`memberships.py`** - Membership management
|
||||
- **`payments.py`** - Payment processing & history
|
||||
### Frontend Application
|
||||
- **`frontend/src/pages/Dashboard.tsx`** - Main member/admin dashboard.
|
||||
- **`frontend/src/components/MembershipSetup.tsx`** - Membership tier selection and payment flow.
|
||||
- **`frontend/src/components/SquarePayment.tsx`** - Square Web Payments SDK form.
|
||||
- **`frontend/src/components/AdminProfileQuestionManager.tsx`** - Admin profile-question configuration.
|
||||
- **`frontend/src/components/ProfileQuestionsForm.tsx`** - Member/admin answer form with dependency handling.
|
||||
- **`frontend/src/components/EmailTemplateManagement.tsx`** - Email template editing.
|
||||
- **`frontend/src/components/BounceManagement.tsx`** - SMTP2GO bounce management.
|
||||
- **`frontend/src/utils/profileQuestionLogic.test.ts`** - Fast frontend unit tests for profile-question visibility/editability.
|
||||
|
||||
## API Endpoints
|
||||
|
||||
- **`auth.py`** - Register, login, forgot password, reset password, change password.
|
||||
- **`users.py`** - Current user profile, admin user CRUD, profile-question CRUD, member/admin profile answers, and role-guarded admin password reset emails.
|
||||
- **`tiers.py`** - Membership tier CRUD.
|
||||
- **`memberships.py`** - Member/admin membership management.
|
||||
- **`payments.py`** - Payment history, manual payments, Square config/process/refund.
|
||||
- **`events.py`** - Event CRUD, upcoming events, RSVP create/update, RSVP listing.
|
||||
- **`email.py`** - SMTP2GO test emails, welcome email tests, bounce webhook, bounce stats, cleanup, deactivation.
|
||||
- **`email_templates.py`** - Database-backed template listing, lookup, update, and default seeding.
|
||||
- **`feature_flags.py`** - Public feature flag listing/lookup and super-admin-only reload.
|
||||
|
||||
## Database Models
|
||||
|
||||
Fully implemented:
|
||||
- **User** - Authentication, profile, roles (member/admin/super_admin)
|
||||
- **MembershipTier** - Configurable tiers with fees and benefits
|
||||
- **Membership** - User memberships with status tracking
|
||||
- **Payment** - Payment records with multiple methods
|
||||
- **Event** - Event management (model ready, endpoints TODO)
|
||||
- **EventRSVP** - Event registration (model ready, endpoints TODO)
|
||||
- **VolunteerRole** - Volunteer roles (model ready, endpoints TODO)
|
||||
- **VolunteerAssignment** - Role assignments (model ready, endpoints TODO)
|
||||
- **VolunteerSchedule** - Shift scheduling (model ready, endpoints TODO)
|
||||
- **Certificate** - Training certificates (model ready, endpoints TODO)
|
||||
- **File** - File repository (model ready, endpoints TODO)
|
||||
- **Notification** - Email tracking (model ready, endpoints TODO)
|
||||
- **User** - Authentication, profile, roles, volunteer level.
|
||||
- **ProfileQuestion** - Configurable profile fields, options, dependencies, admin-only edit flags.
|
||||
- **UserProfileAnswer** - Per-user answers with update attribution.
|
||||
- **MembershipTier** - Configurable tiers with fees and benefits.
|
||||
- **Membership** - User memberships with status, dates, and auto-renew flag.
|
||||
- **Payment** - Payment records for Square, cash, check, and dummy methods.
|
||||
- **Event** - Event management records.
|
||||
- **EventRSVP** - RSVP and attendance records.
|
||||
- **EmailTemplate** - Editable database-backed email templates.
|
||||
- **EmailBounce** - SMTP2GO bounce, complaint, and unsubscribe tracking.
|
||||
- **PasswordResetToken** - One-time password reset support.
|
||||
- **VolunteerRole** - Volunteer role definitions.
|
||||
- **VolunteerAssignment** - Member-to-role assignments.
|
||||
- **VolunteerSchedule** - Volunteer shift schedules.
|
||||
- **Certificate** - Training/certificate records.
|
||||
- **File** - File repository metadata.
|
||||
- **Notification** - Email notification logs.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Start everything
|
||||
docker-compose up -d
|
||||
docker compose up -d
|
||||
|
||||
# View logs
|
||||
docker-compose logs -f
|
||||
docker compose logs -f
|
||||
|
||||
# Access API docs
|
||||
# http://localhost:8000/docs
|
||||
# http://localhost:8050/docs
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
# Run both fast test suites and restart only if they pass
|
||||
./restart.sh
|
||||
|
||||
# Run test suites individually
|
||||
docker compose run --rm frontend npm test
|
||||
docker compose run --rm backend pytest -q
|
||||
```
|
||||
|
||||
## Default Credentials
|
||||
|
||||
**Admin**: admin@swanseaairport.org / admin123
|
||||
|
||||
**Database**: Configured via environment variables (see .env file)
|
||||
**Database**: Configured via environment variables in `.env`.
|
||||
|
||||
## What's Next
|
||||
## Remaining Roadmap
|
||||
|
||||
1. Test the API endpoints
|
||||
2. Add Square payment integration
|
||||
3. Implement email notifications
|
||||
4. Create event management endpoints
|
||||
5. Add volunteer management endpoints
|
||||
6. Build frontend interface
|
||||
1. Expand authenticated API tests for member/admin workflows
|
||||
2. Add member file repository endpoints and UI
|
||||
3. Build richer volunteer assignment, schedule, and certificate screens
|
||||
4. Add renewal reminder batch jobs
|
||||
5. Add reporting and analytics
|
||||
|
||||
Reference in New Issue
Block a user