- **Schemas Layer:** Defines Pydantic models for request validation and API responses.
+
- **Service Layer:** Implements business logic (NLP, chat assistant).
+
- **Routes Layer:** Defines API endpoints exposed via FastAPI.
+
- **Utility Layer:** Includes reusable components like embedding generation, configuration, logging, and security helpers.
+
- **Worker Layer:** Handles background jobs such as scheduled chat message fetching and NLP processing.
+
+
This modular layout ensures that each component can evolve independently β for example, NLP services or integrations can scale separately from the main API.
+
+
The **frontend** is built using **React** and consumes REST APIs exposed by the FastAPI backend. It serves as the user interface for screens, chatbot interactions, and employee views.
+
+
### π Repository Structure
+
+
```bash
+
/repo
+
ββ /api # FastAPI app
+
β ββ main.py
+
β ββ routers/
+
β β ββ auth.py
+
β β ββ chat.py
+
β β ββ employees.py
+
β ββ models/ # ORM classes
+
β ββ services/ # Business logic (NLP invocations, DB helpers)
β β βββ pages/ # Dashboard and chatbot screens
+
β β βββ services/ # API service calls
+
β β βββ hooks/ # Custom React hooks
+
β β βββ contexts/ # Auth and user management
+
β β βββ assets/ # Icons, images, and theme files
+
β β βββ utils/ # Helper functions
+
β βββ public/ # Static assets
+
β βββ package.json
+
β βββ vite.config.js or next.config.js
+
β βββ README.md
+
ββ /db
+
β ββ migrations.sql
+
ββ docker-compose.yml
+
ββ Dockerfile.api
+
ββ README.md
+
```
+
+
## 2. Database Schema β SQL DDL
+
+
The database schema defines all core entities and their relationships for the MVP.
+
It is implemented in **PostgreSQL** and **pgvector** for storing text embeddings used in semantic search.
+
+
The schema captures four main domains:
+
+
### **Employee Domain**
+
- **Tables:** `employees`, `employee_tag`
+
- Manages employee profiles, departmental details, and tag associations.
+
- Defines users of the system (employees and admins) and establishes relationships between employees and tags for access control and contextual filtering.
+
+
### **Message Domain**
+
- **Tables:** `messages`
+
- Stores sanitized chat messages fetched from configured data sources.
+
- Each message is tied to an employee (sender) and a data source (Telegram or Google Chat), and includes an embedding vector for semantic search.
+
+
### **Tag Domain**
+
- **Tables:** `tags`
+
- Defines organizational tags or categories such as projects, teams, or topics.
+
- Tags serve as contextual identifiers used to categorize employees, data sources, and messages.
+
+
### **Data Source Domain**
+
- **Tables:** `data_sources`
+
- Represents external chat integrations (Google Chat or Telegram groups).
+
- Each data source is linked to a specific tag and acts as an entry point for message ingestion.
+
- Foreign key relationships use `ON DELETE CASCADE` for integrity.
+
+
> Example: Deleting a project automatically removes related skills or employees linked via `projects_employee`.
+
+
---
+
+
### π§βπΌ **employees**
+
+
```sql
+
CREATE TABLE employees (
+
id SERIAL PRIMARY KEY,
+
external_id JSONB,
+
name VARCHAR(150) NOT NULL,
+
role VARCHAR(50) NOT NULL, -- e.g., 'Java Developer'