SimpleMD Project Migration - Complete Reference

Created: 2024-12-14 05:11:10 | Last updated: 2024-12-14 05:11:10 | Status: Public

Original Structure

  • FastAPI web app for markdown document management
  • Current structure is monolithic
  • All code in app/ directory
  • SQLite database with basic tables
  • Uses JWT auth and admin roles

Target Structure

app/
├── core/               # Core functionality
├── database/          # Database and repositories
├── routes/            # API routes
├── services/          # Business logic
├── static/            # Static files
├── templates/         # Jinja2 templates
└── main.py           # Entry point

Components Already Created

  1. Core Components:
    - config.py
    - security.py
    - exceptions.py
    - middleware.py

  2. Database Components:
    - models.py
    - repositories/

    • base.py
    • document_repo.py
    • user_repo.py
    • image_repo.py
    • migrations.py
  3. Service Components:
    - document_service.py
    - user_service.py
    - image_service.py
    - admin_service.py

  4. Route Components:
    - auth.py
    - documents.py
    - admin.py
    - images.py
    - public.py

  5. Main Application:
    - New streamlined main.py

  6. Documentation:
    - README.md
    - SETUP.md

Required Files

  • requirements.txt (created)
  • .env (needs to be created by user)
  • add_admin.py (exists)

Dependencies Added

  • pydantic-settings==2.1.0
  • pytest==7.4.3
  • pytest-asyncio==0.23.2
  • httpx==0.25.2
  • pytest-cov==4.1.0

Critical Features Preserved

  1. User authentication with JWT
  2. Document CRUD operations
  3. Public/private document sharing
  4. Image upload and management
  5. Admin dashboard
  6. Markdown rendering
  7. File upload handling

Database Schema

  1. users table
    - id, username, password_hash, created_at

  2. documents table
    - id, title, content, user_id, created_at, updated_at
    - is_public, deleted_at, deleted_by

  3. images table
    - id, filename, original_filename, user_id
    - document_id, uploaded_at

Environment Variables

Required in .env:

SECRET_KEY="your-secret-key-here"
ADMIN_USERS="admin"
DEBUG=False

Migration Progress

  1. ✅ Core components
  2. ✅ Database layer
  3. ✅ Services layer
  4. ✅ Routes layer
  5. ✅ Main application
  6. ✅ Documentation

Next Steps to Implement

  1. Create test suite
  2. Add logging system
  3. Implement proper error handling
  4. Create migration scripts
  5. Set up CI/CD

Current Static Files

static/
├── css/
│   ├── _markdown-content.css
│   ├── ill13.css
│   ├── image-uploader.css
│   ├── markdown-uploader.css
│   ├── mvp.css
│   └── nav.css
├── js/
│   ├── image-uploader.js
│   └── markdown-uploader.js
└── uploads/

Current Templates

templates/
├── base.html
├── error.html
├── home.html
├── login.html
├── register.html
├── admin/
│   ├── images.html
│   └── storage.html
└── documents/
    ├── create.html
    ├── edit.html
    ├── list.html
    ├── public_list.html
    └── view.html

Testing Requirements

  1. User authentication flows
  2. Document CRUD operations
  3. Image upload functionality
  4. Admin capabilities
  5. Public/private document access
  6. Database operations
  7. File system operations

Security Considerations

  1. JWT token handling
  2. Password hashing
  3. File upload validation
  4. Admin access control
  5. Database injection prevention
  6. XSS prevention
  7. CSRF protection

Reference Artifacts Created

  1. code-organization (restructure plan)
  2. core-components (core functionality)
  3. database-components (data layer)
  4. service-components (business logic)
  5. route-components (API routes)
  6. new-main (application entry)
  7. project-documentation (README/SETUP)
  8. final-requirements (dependencies)