DATS is a collaborative text analysis platform built for teams. It's built with React and TypeScript in the frontend and Python in the backend, and is designed for excellent performance and user experience. The backend is a FastAPI server with an OpenAPI-based API and uses PostgreSQL as main storage, Redis for the task queue, Weaviate for vector storage, and ElasticSearch for text.
Monorepo Structure:
frontend/- React web application with MUI componentsbackend/- FastAPI server with SQLAlchemy ORM and background workersdocker/- Docker compose files to start the entire stack in development or productiondocs/- Documentation filespublic/- Static assets served directly- Various config files - TypeScript, Vite, Vitest, Prettier, Oxlint configurations
Refer to /docs/ARCHITECTURE.md for detailed architecture documentation.
You're an expert in the following areas:
- TypeScript
- Python
- React and React Router
- SQLAlchemy ORM
- PostgreSQL
- HTML, CSS and Styled Components
- Use early returns for readability.
- Emphasize type safety and static analysis.
- Follow consistent Prettier and Ruff formatting.
- Do not install new dependencies
- Avoid "unknown" unless absolutely necessary.
- Never use "any".
- Prefer type definitions; avoid type assertions (as, !).
- Use functional components with hooks.
- Event handlers should be prefixed with "handle", like "handleClick" for onClick.
- Avoid unnecessary re-renders by using React.memo, useMemo, and useCallback appropriately.
- Use descriptive prop types with TypeScript interfaces.
- Do not import React unless it is used directly.
- SQLAlchemy model file names end with
_orm.py. - Add appropriate indexes for query performance.
- Always handle database errors gracefully.
- RESTful endpoints are in files with names ending in
_endpoint.py. - Authentication endpoints under
/backend/src/core/auth/. - Use consistent error responses.
- Validate request data using the validation decorators and schemas in
_dto.pyfiles. - Keep API routes thin, use service methods for business logic.
- JWT tokens for authentication.
- Use authenticated decorators for protected routes.
- Always verify user permissions before data access.
- Always catch and handle errors appropriately.
- Log errors with appropriate context.
- Return user-friendly error messages.
- Never expose sensitive information in errors.
- Use React.memo for expensive components.
- Implement pagination for large lists.
- Use database indexes effectively.
- Cache expensive computations.
- Sanitize all user input.
- Never store sensitive data in plain text.
- Use environment variables for secrets.