SimpleMD Project Migration - Complete Reference
Created: 2024-12-11 17:16:12 | Last updated: 2024-12-11 17:16:12 | 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
-
Core Components:
- config.py
- security.py
- exceptions.py
- middleware.py -
Database Components:
- models.py
- repositories/- base.py
- document_repo.py
- user_repo.py
- image_repo.py
- migrations.py
-
Service Components:
- document_service.py
- user_service.py
- image_service.py
- admin_service.py -
Route Components:
- auth.py
- documents.py
- admin.py
- images.py
- public.py -
Main Application:
- New streamlined main.py -
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
- User authentication with JWT
- Document CRUD operations
- Public/private document sharing
- Image upload and management
- Admin dashboard
- Markdown rendering
- File upload handling
Database Schema
-
users table
- id, username, password_hash, created_at -
documents table
- id, title, content, user_id, created_at, updated_at
- is_public, deleted_at, deleted_by -
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
- ✅ Core components
- ✅ Database layer
- ✅ Services layer
- ✅ Routes layer
- ✅ Main application
- ✅ Documentation
Next Steps to Implement
- Create test suite
- Add logging system
- Implement proper error handling
- Create migration scripts
- 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
- User authentication flows
- Document CRUD operations
- Image upload functionality
- Admin capabilities
- Public/private document access
- Database operations
- File system operations
Security Considerations
- JWT token handling
- Password hashing
- File upload validation
- Admin access control
- Database injection prevention
- XSS prevention
- CSRF protection
Reference Artifacts Created
- code-organization (restructure plan)
- core-components (core functionality)
- database-components (data layer)
- service-components (business logic)
- route-components (API routes)
- new-main (application entry)
- project-documentation (README/SETUP)
- final-requirements (dependencies)