πŸ“» 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

Multi-NCS Operations

Check-ins

Real-time Features

Email Notifications

API Endpoints

Authentication (/auth)

Users (/users)

Nets (/nets)

Net Roles (/nets/{net_id}/roles)

Check-ins (/check-ins)

Frequencies (/frequencies)

Templates (/templates)

Statistics (/statistics)

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


πŸ—ΊοΈ Roadmap

Future enhancements planned:

Completed

In Progress / Planned

Stretch Goals


βœ… Tested Environments

Environment Status Notes
Debian Trixie βœ… Tested Python 3.13, production with Caddy reverse proxy
Windows 11 βœ… Tested Development with PowerShell scripts
Host Migration βœ… Tested LAN to production domain migration
Windows Server ⬜ Untested Should work with PowerShell scripts

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

Backend (Python)

Frontend (TypeScript)