📻 ECTLogger

ECTLogger Development Guide

Project Structure

ectlogger/
├── backend/
│   ├── app/
│   │   ├── __init__.py
│   │   ├── main.py              # FastAPI application entry point
│   │   ├── config.py            # Configuration settings
│   │   ├── database.py          # Database connection and session
│   │   ├── models.py            # SQLAlchemy models
│   │   ├── schemas.py           # Pydantic schemas for validation
│   │   ├── auth.py              # Authentication utilities
│   │   ├── dependencies.py      # FastAPI dependencies
│   │   ├── email_service.py     # Email notification service
│   │   └── routers/
│   │       ├── __init__.py
│   │       ├── auth.py          # Authentication endpoints
│   │       ├── users.py         # User management endpoints
│   │       ├── nets.py          # Net management endpoints
│   │       ├── check_ins.py     # Check-in endpoints
│   │       └── frequencies.py   # Frequency management endpoints
│   └── requirements.txt
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   │   └── Navbar.tsx       # Navigation bar component
│   │   ├── contexts/
│   │   │   └── AuthContext.tsx  # Authentication context
│   │   ├── pages/
│   │   │   ├── Login.tsx        # Login page
│   │   │   ├── Dashboard.tsx    # Main dashboard
│   │   │   ├── NetView.tsx      # Net details and check-ins
│   │   │   └── CreateNet.tsx    # Create new net
│   │   ├── services/
│   │   │   └── api.ts           # API client and endpoints
│   │   ├── App.tsx              # Main application component
│   │   ├── main.tsx             # Application entry point
│   │   └── vite-env.d.ts        # TypeScript declarations
│   ├── index.html
│   ├── package.json
│   ├── tsconfig.json
│   └── vite.config.ts
├── .env.example
├── .gitignore
├── LICENSE
├── README.md
└── MANUAL-INSTALLATION.md

Key Features Implemented

Authentication

Net Management

Check-ins

Real-time Features

Email Notifications

API Endpoints

Authentication (/auth)

Users (/users)

Nets (/nets)

Check-ins (/check-ins)

Frequencies (/frequencies)

WebSocket

Database Models

User

Net

CheckIn

Frequency

NetRole

CustomField & CustomFieldValue

ChatMessage

Adding New Features

Adding a New Field to Check-ins

  1. Backend: Update models.py
    # In CheckIn model
    new_field = Column(String(255))
    
  2. Backend: Update schemas.py
    # In CheckInBase schema
    new_field: Optional[str] = None
    
  3. Frontend: Update check-in form in NetView.tsx
    <TextField
      label="New Field"
      value={checkInForm.new_field}
      onChange={(e) => setCheckInForm({...checkInForm, new_field: e.target.value})}
    />
    

Adding Custom Reports

  1. Create new router in backend/app/routers/reports.py
  2. Add database queries for report data
  3. Create frontend page in frontend/src/pages/Reports.tsx
  4. Add route to App.tsx

Adding SMS Notifications

  1. Integrate SMS service (Twilio, AWS SNS)
  2. Update email_service.py to include SMS sending
  3. Add SMS gateway configuration to user profiles
  4. Update notification triggers to send both email and SMS

Testing

Backend Testing

cd backend
pip install pytest pytest-asyncio httpx
pytest

Frontend Testing

cd frontend
npm install --save-dev vitest @testing-library/react
npm test

Code Style

Backend (Python)

Frontend (TypeScript)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Write tests
  5. Submit a pull request

Common Development Tasks

Adding a New Page

  1. Create component in frontend/src/pages/
  2. Add route in App.tsx
  3. Add navigation link if needed

Adding a New API Endpoint

  1. Define schema in schemas.py
  2. Add route in appropriate router file
  3. Update API client in frontend/src/services/api.ts
  4. Use in frontend components

Database Migrations (Future Enhancement)

Consider adding Alembic for database migrations:

cd backend
alembic init alembic
alembic revision --autogenerate -m "Initial migration"
alembic upgrade head

Performance Considerations

Security Best Practices