Spaces:
Running

45.5 kB
wabden's picture
create the best landing page for this GRANADA DEVELOPMENT PLAN: PHASED IMPLEMENTATION Our Approach • MVP-First: Focus on delivering a Minimum Viable Product (MVP) rapidly to validate core concepts and gather feedback. The MVP will include user authentication, basic proposal creation, and showing initial donor opportunities. • Iterative Development: Build in short, focused sprints, adding features incrementally. • Modularity: Adhere strictly to the defined file structure and separation of concerns to ensure scalability and maintainability. • Test-Driven (where applicable): Encourage writing tests for critical components as development progresses. • Containerized Environment: Develop entirely within Docker to ensure consistent environments from dev to production. ________________________________________ Phase 0: Project Initialization & Core Infrastructure Setup (1-2 Days) Goal: Get the project environment running with basic frontend and backend services that can communicate. 1. Generate Project Structure: o Action: Run the Python script (generate_granada_structure.py) you requested. This creates all folders and empty files. o Files Affected: All empty files and directories. 2. Basic Git Initialization: o Action: git init in the root granada/ directory. o Action: Ensure .gitignore is correctly populated. o Files Affected: .gitignore 3. Populate Core Configuration & Dependencies: o Backend (backend/):  Add essential dependencies to requirements.txt. (e.g., fastapi, uvicorn, sqlalchemy, asyncpg, pydantic, python-jose, passlib).  Populate main.py with the basic FastAPI app setup, CORS, and inclusion of the auth router (even if empty initially).  Populate core/config.py with BaseSettings for env vars.  Populate core/db.py with basic SQLAlchemy engine/session setup.  Populate core/security.py with basic JWT and password hashing functions.  Populate core/exceptions.py with APIException class.  Populate core/logging_config.py with basic Loguru setup. o Frontend (frontend/):  Add essential dependencies to frontend/package.json (e.g., react, react-dom, react-router-dom, axios, zustand, tailwindcss, clsx, tailwind-merge).  Populate frontend/src/main.jsx and frontend/src/App.jsx with basic React app structure and BrowserRouter.  Populate frontend/src/index.css, frontend/src/tailwind.config.js, frontend/src/postcss.config.js with basic Tailwind CSS setup.  Populate frontend/src/lib/api.js with a basic Axios instance. o Root Level (granada/):  Add initial content to README.md (project overview, basic setup instructions).  Populate .env.example with placeholders for DB, API keys.  Populate Dockerfile with multi-stage build for React and FastAPI.  Populate docker-compose.yml for db, redis, backend, frontend services. Include celery_worker and celery_beat as placeholders for future use, initially disabled or with no tasks. 4. Database Migration Setup (Alembic): o Action: Populate backend/alembic.ini and backend/migrations/env.py (referencing backend.core.db.Base). o Action: Add init_db.sh script for Docker entrypoint to run migrations. o Files Affected: alembic.ini, migrations/env.py, scripts/init_db.sh 5. Initial Local Development Environment Test: o Action: Run docker-compose up --build -d from the granada/ root. o Verification:  Check Docker logs (docker-compose logs -f) for errors.  Confirm backend is accessible at http://localhost:8000/docs (FastAPI Swagger UI).  Confirm frontend is accessible at http://localhost:3000. ________________________________________ Phase 1: Core User Management & Authentication (MVP 1 - ~5-7 Days) Goal: Users can register, log in, and access a personalized (though empty) dashboard. This establishes secure access. 1. Backend - User & Auth Logic: o Files: backend/models/user.py, backend/schemas/user.py, backend/services/user_service.py (create this), backend/routers/auth.py. o Details:  Define User, Organization, Role, UserRole models in models/user.py.  Create Pydantic schemas for UserCreate, UserLogin, UserResponse, OrganizationCreate, OrganizationResponse in schemas/user.py.  Implement user_service.py with functions for:  create_user_and_organization (including password hashing using security.py).  authenticate_user (verifying password).  get_user_by_email, get_organization_by_id.  Implement routers/auth.py with POST /register, POST /token (for login), and GET /me (protected endpoint using security.get_current_user). 2. Database Migrations for User Models: o Action: docker-compose exec backend alembic revision --autogenerate -m "Create user and organization tables" o Action: docker-compose exec backend alembic upgrade head o Action: Populate scripts/seed_data.py with basic admin and demo user/organization data. Run docker-compose exec backend python scripts/seed_data.py. 3. Frontend - Authentication UI & State: o Files: frontend/src/pages/Auth/Login.jsx, frontend/src/routes/PrivateRoute.jsx, frontend/src/store/authStore.js, frontend/src/services/authService.js. o Details:  Design Login.jsx to handle both login and registration (using isRegister prop). Include input fields and submit buttons.  Implement authService.js to call backend /auth/token and /auth/register endpoints.  Implement authStore.js (Zustand) to manage user object and token in memory and localStorage. Include login, register, logout, isAuthenticated actions.  Create PrivateRoute.jsx to protect routes based on isAuthenticated().  Modify App.jsx to use PrivateRoute for protected routes.  Create a simple DashboardLayout.jsx in components/dashboard/ to serve as a basic layout wrapper for protected pages.  Create Dashboard.jsx in pages/Dashboard/ with a simple "Welcome" message based on useAuthStore. 4. Verification (Phase 1): o Register a new user through the frontend UI. o Log in with the new user. o Confirm the user is redirected to the dashboard. o Log out and ensure redirection to login. o Test admin@granada.com login with adminpass (from seed data). ________________________________________ Phase 2: Core Proposal Management (MVP 2 - ~7-10 Days) Goal: Users can create new proposals, view a list of their proposals, and edit proposal sections. 1. Backend - Proposal Logic: o Files: backend/models/proposal.py, backend/schemas/proposal.py, backend/services/proposal_service.py (create this), backend/routers/proposals.py. o Details:  Define Proposal, ProposalSection, ProposalVersion models in models/proposal.py.  Create Pydantic schemas for ProposalCreate, ProposalUpdate, ProposalResponse, ProposalSectionCreate, ProposalSectionUpdate, ProposalSectionResponse in schemas/proposal.py.  Implement proposal_service.py with CRUD for proposals and sections (create_proposal, get_proposal_by_id, update_proposal, delete_proposal, create_proposal_section, update_proposal_section).  Implement routers/proposals.py with corresponding endpoints (e.g., POST /proposals/, GET /proposals/{id}, PUT /proposals/{id}/sections/{section_id}).  Important: Ensure all proposal operations are scoped to the current_user.organization_id. 2. Database Migrations for Proposal Models: o Action: docker-compose exec backend alembic revision --autogenerate -m "Add proposal and section tables" o Action: docker-compose exec backend alembic upgrade head 3. Frontend - Proposal UI: o Files: frontend/src/pages/ProposalEditor/ProposalEditor.jsx, frontend/src/components/proposal/ProposalSectionEditor.jsx (create this), frontend/src/store/proposalStore.js, frontend/src/services/proposalService.js, frontend/src/components/navigation/SidebarNav.jsx. o Details:  Update SidebarNav.jsx to include a link to "Proposals" (e.g., /proposals).  Implement proposalService.js to interact with backend proposal API.  Implement proposalStore.js (Zustand) to manage proposal list and currentProposal state.  Design ProposalEditor.jsx:  Input fields for proposal title, short description.  A list or dynamic rendering of ProposalSectionEditor components.  Buttons for "Create Proposal", "Save Proposal Details".  Basic tabs for "Overview" and "Sections".  Design ProposalSectionEditor.jsx: A simple textarea or rich text editor for section content. 4. Verification (Phase 2): o Log in as a demo user. o Navigate to /proposals (or a dedicated "create proposal" page). o Create a new proposal with title and short description. o Add a few sections (e.g., "Background", "Justification"). o Edit content of sections. o Verify that proposals are correctly saved and retrieved. ________________________________________ Phase 3: Basic AI Integration (Proposal Section Generation) (MVP 3 - ~3-5 Days) Goal: Enable users to generate content for a proposal section using AI. 1. Backend - AI Service: o Files: backend/core/config.py, backend/services/proposal_generation.py (create this), backend/routers/proposals.py. o Details:  Add OPENAI_API_KEY (or DeepSeek) to backend/.env.example.backend and load it via core/config.py.  Implement proposal_generation.py: Contains the logic to call the LLM API (e.g., OpenAI's chat.completions.create). It should take proposal_id, section_name, and user_prompt as input, fetch relevant proposal context, formulate the prompt, and return generated content.  Add an endpoint like POST /proposals/{proposal_id}/generate-section in routers/proposals.py that calls proposal_generation.py service. This endpoint will update the specific ProposalSection. 2. Frontend - AI Trigger: o Files: frontend/src/components/proposal/ProposalSectionEditor.jsx, frontend/src/pages/ProposalEditor/ProposalEditor.jsx, frontend/src/services/proposalService.js, frontend/src/store/proposalStore.js. o Details:  Add an "AI Generate" button to ProposalSectionEditor.jsx.  Modify proposalService.js to include the generateSection API call.  Modify proposalStore.js to include an action to trigger AI generation and update the currentProposal's sections with the AI-generated content.  Wire up the button in ProposalEditor.jsx to call the generateSection action. 3. Verification (Phase 3): o Enter API keys in your .env file for AI. o Create a new proposal or open an existing one. o Click "AI Generate" on a section. o Observe AI-generated content appearing in the section. ________________________________________ Phase 4: Donor Data Ingestion & Basic Matching (MVP 4 - ~7-10 Days) Goal: Automatically collect donor call data and display a list of active opportunities to users. 1. Backend - Donor Data & Basic Matching: o Files: backend/models/donor.py, backend/schemas/donor.py, backend/services/donor_service.py (create this), backend/routers/donors.py, backend/scrapers/base_scraper.py, backend/scrapers/undp_scraper.py (or similar first), backend/scrapers/scheduler.py, backend/main.py (for Celery integration). o Details:  Define Donor and DonorCall models in models/donor.py.  Create Pydantic schemas for DonorCreate, DonorResponse, DonorCallCreate, DonorCallResponse in schemas/donor.py.  Implement base_scraper.py (abstract class).  Implement at least one concrete scraper (e.g., undp_scraper.py) to fetch and parse data. Start with a simple HTML parsing approach (BeautifulSoup, httpx).  Implement scheduler.py to orchestrate scraper runs.  Implement donor_service.py with get_active_donor_calls (basic filtering) and logic to save_scraped_data (creating/updating Donor and DonorCall records).  Configure Celery in main.py and potentially add a Celery Beat schedule for the scraping task. (Initially, you can trigger the scrape task manually for testing).  Implement routers/donors.py with GET /donors/calls to list active donor calls. 2. Database Migrations for Donor Models: o Action: docker-compose exec backend alembic revision --autogenerate -m "Add donor and donor_call tables" o Action: docker-compose exec backend alembic upgrade head 3. Frontend - Donor Opportunities Display: o Files: frontend/src/pages/DonorMatching/DonorMatching.jsx, frontend/src/components/donor/DonorCard.jsx (create this), frontend/src/components/donor/DonorFilterPanel.jsx (basic placeholder), frontend/src/store/donorStore.js, frontend/src/services/donorService.js, frontend/src/components/navigation/SidebarNav.jsx. o Details:  Update SidebarNav.jsx to link to "Donor Opportunities" (e.g., /donors).  Implement donorService.js to fetch donor calls.  Implement donorStore.js to manage donorCalls state.  Design DonorMatching.jsx to display a list of DonorCard components.  Design DonorCard.jsx to show title, deadline, short description, and a link to the full call.  Implement a basic DonorFilterPanel.jsx (e.g., just a search bar or country filter for now). 4. Verification (Phase 4): o Manually trigger a scrape task (e.g., via docker-compose exec backend python -c "from backend.scrapers.scheduler import scrape_all_donor_calls; import asyncio; asyncio.run(scrape_all_donor_calls())" or set up a test route for it). o Verify donor calls are populated in the database. o Log in to the frontend. o Navigate to "Donor Opportunities". o See the list of scraped donor calls. ________________________________________ Phase 5: MVP Refinement & Production Preparation (~5-7 Days) Goal: Polish the MVP, improve user experience, add basic testing, and prepare for initial deployment. 1. Frontend UI/UX Improvements: o Files: All frontend components and pages. o Details:  Integrate shadcn/ui components (buttons, input, cards, tabs, select) across the app to enhance visual consistency and accessibility.  Add loading states, error messages (using useToast), and empty states for lists.  Refine navigation (SidebarNav, Header, Breadcrumbs).  Implement a Dark/Light mode toggle (using uiStore.js). 2. Backend Enhancements: o Files: backend/routers, backend/services. o Details:  Implement robust validation using Pydantic in schemas.  Improve error handling in services and routers using core/exceptions.py.  Ensure all database operations are async/await compatible.  Add get_all_users and get_all_organizations to user_service.py and admin.py for future admin dashboard. 3. Basic Testing: o Files: backend/tests/, frontend/src/tests/. o Details:  Write a few critical unit tests for core backend functions (e.g., password hashing, JWT creation).  Write a few integration tests for key API endpoints (e.g., user registration, login).  Set up Jest/React Testing Library for frontend component tests (e.g., for a simple button or input). 4. Documentation & Deployment Scripts: o Files: README.md, docs/, scripts/deploy.sh. o Details:  Update README.md with comprehensive "Getting Started" for local Docker Compose setup.  Add a basic deploy.sh script (even if it's just a placeholder for a real CI/CD pipeline).  Start drafting docs/user_manual.md and docs/api_reference.md. ________________________________________ Beyond MVP: Future Phases Once the MVP is stable and validated, we'd proceed with the following phases: • Phase 6: Advanced AI Matching & SDG Tagger: Implement PgVector, embedding generation, and ai_review.py for semantic matching and sdg_tagging.py for live SDG analysis. • Phase 7: Logical Framework & Budget Builders: Develop interactive UI and backend logic for logframe_builder.py and budget_builder.py. • Phase 8: Collaboration & Notifications: Implement real-time co-editing, comment threads, and the full notification system. • Phase 9: Export & File Management: Full implementation of exporters/ module and file_service.py with S3 integration. • Phase 10: Reporting & M&E: Develop post-award tracking, indicator progress, and report generation. • Phase 11: Learning Hub & Integrations: Build out educational content and third-party integrations (CRM, PM tools). • Phase 12: Scaling & SaaS Features: Multi-tenancy refinements, advanced analytics, subscription management, performance optimizations. ________________________________________ This detailed plan provides a clear roadmap. We are now ready to begin with Phase 0: Project Initialization & Core Infrastructure Setup. Do you want me to start generating the actual initial content for the files as per Phase 0 (e.g., main.py, App.jsx, requirements.txt, etc.)? - Initial Deployment
8ad0c55 verified