# elevate-project/samiksha-service architecture

> Architecture diagram of the GitHub repository elevate-project/samiksha-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elevate-project/samiksha-service
- Repository: https://github.com/elevate-project/samiksha-service

## Overview

##### Project type and purpose
- This is a full‐stack Survey & Observation application (“Survey Service”) comprising:
- A Node.js/Express‐based backend microservice (app.js)
- An Angular frontend (samiksha-ui-2)
- Multiple supporting microservices (entity-management, user, notification, interface, scheduler) referenced in setup docs
- Infrastructure components: PostgreSQL (Citus), MongoDB, Cassandra, Elasticsearch, Redis, Kafka/Zookeeper, cloud file storage

##### File structure
- Top‐level backend folders:
- config: environment and infrastructure configs (DB, Kafka, cloud storage)
- controllers/v1,v2,v3: HTTP API handlers (REST endpoints)
- module: domain logic split by functional area + validation helpers
- models + databaseQueries: ORM models and raw queries (Postgres, Mongo)
- generics: cross‐cutting helpers (file upload, Kafka producers/consumers, middleware, services to other microservices)
- healthCheck: readiness probes for each external component
- routes/index.js: Express router setup
- Frontend: samiksha-ui-2 (Angular app) under a separate directory
- Deployment and docs: Dockerfile, docker-compose.yml, ansible.yml, scripts for Dockerized & native installs
- External dependency definitions: .env.sample for Survey and samples for other services

##### Read README for additional insights
- Service exposes REST endpoints for creating/consuming surveys, observations, reports
- Communicates with other ELEVATE microservices via HTTP (via generics/httpRequest helper) or Kafka (via generics/kafkaCommunications)
- Data persistence in multiple stores:
- Postgres (user, core survey structures, relational data)
- MongoDB (forms, profiling configs imported via scripts)
- Cassandra & Elasticsearch for high‐volume or search use cases
- File storage through cloud gateways (AWS, GCP, Azure)

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Frontend Layer"
    UI["Angular UI (samiksha-ui-2)"]:::frontend
  end

  subgraph "Backend - Survey Service"
    A["app.js"]:::backend

    subgraph "Config"
      C1["index.js"]:::backend
      C2["dbConfig.js"]:::backend
      C3["cassandra.js"]:::backend
      C4["elasticSearch.js"]:::backend
      C5["kafkaConfig.js"]:::backend
      C6["cloud-service.js"]:::backend
    end

    subgraph "Controllers"
      CtrlV1["v1 Controllers"]:::backend
      CtrlV2["v2 Controllers"]:::backend
      CtrlV3["v3 Controllers"]:::backend
    end

    NodeR["routes/index.js"]:::backend

    subgraph "Domain Modules"
      Mods["module/"]:::backend
    end

    subgraph "Models & Queries"
      Mdl["models/"]:::backend
      Qry["databaseQueries/"]:::backend
    end

    subgraph "Generics"
      H1["httpRequest.js"]:::backend
      KComm["kafkaCommunications.js"]:::backend
      Svc["services/"]:::backend
      Mid["middleware/"]:::backend
      Cons["submissionRatingQueueConsumer.js"]:::backend
    end

    subgraph "HealthCheck"
      HC1["index.js"]:::backend
      HC2["kafka.js"]:::backend
      HC3["mongodb.js"]:::backend
      HC4["elastic-search.js"]:::backend
      HC5["improvement-project.js"]:::backend
      HC6["kendra.js"]:::backend
    end

    subgraph "File Storage Helpers"
      FS1["awsFileUpload.js"]:::backend
      FS2["gcpFileUpload.js"]:::backend
      FS3["azureFileUpload.js"]:::backend
      FSMod["module/cloud-services/files/"]:::backend
    end
  end

  subgraph "Messaging Layer"
    Kafka["Kafka Cluster"]:::message
    Zoo["Zookeeper"]:::message
  end

  subgraph "External Microservices"
    EM["Entity-Management"]:::external
    US["User Service"]:::external
    NT["Notification Service"]:::external
    IF["Interface Service"]:::external
    SCH["Scheduler Service"]:::external
  end

  subgraph "Data Layer"
    Postgres["PostgreSQL / Citus"]:::datastore
    Mongo["MongoDB"]:::datastore
    Cass["Cassandra"]:::datastore
    ES["Elasticsearch"]:::datastore
    Redis["Redis"]:::datastore
  end

  FS["File Storage (S3/GCP/Azure)"]:::datastore

  UI -->|"HTTP/REST"| A
  A -->|"loads"| C1
  A -->|"routes via"| NodeR
  NodeR -->|"routes to"| CtrlV1
  NodeR -->|"routes to"| CtrlV2
  NodeR -->|"routes to"| CtrlV3
  CtrlV1 -->|"calls"| Mods
  CtrlV2 -->|"calls"| Mods
  CtrlV3 -->|"calls"| Mods
  Mods -->|"DB Ops"| Mdl
  Mods -->|"DB Queries"| Qry
  Mods -->|"uses HTTP"| H1
  Mods -->|"uses KafkaComm"| KComm
  H1 -->|"> HTTP"| EM
  H1 -->|"> HTTP"| US
  KComm -->|"produce/consume"| Kafka
  Cons -->|"consume"| Kafka
  Cons -->|"invoke Modules"| Mods
  A -->|"health probes"| HC1
  HC1 -->|"probe Kafka"| HC2
  HC1 -->|"probe Mongo"| HC3
  HC1 -->|"probe Elasticsearch"| HC4
  HC1 -->|"probe Improvement"| HC5
  HC1 -->|"probe Kendra"| HC6
  Mods -->|"upload/download"| FS1
  Mods -->|"upload/download"| FS2
  Mods -->|"upload/download"| FS3
  FS1 -->|"to storage"| FS
  FS2 -->|"to storage"| FS
  FS3 -->|"to storage"| FS
  Kafka -->|"coordinator"| Zoo

  classDef frontend fill:#D0E1FF,stroke:#4D79FF,color:#000
  classDef backend fill:#D0FFD6,stroke:#28A745,color:#000
  classDef message fill:#FFE5B4,stroke:#FF8C00,color:#000
  classDef datastore fill:#E5D1FF,stroke:#8000FF,color:#000
  classDef external fill:#F0F0F0,stroke:#A9A9A9,color:#000

  click UI "https://github.com/elevate-project/samiksha-service/tree/main/samiksha-ui-2/"
  click A "https://github.com/elevate-project/samiksha-service/blob/main/app.js"
  click C1 "https://github.com/elevate-project/samiksha-service/blob/main/config/index.js"
  click C2 "https://github.com/elevate-project/samiksha-service/blob/main/config/dbConfig.js"
  click C3 "https://github.com/elevate-project/samiksha-service/blob/main/config/db/cassandra.js"
  click C4 "https://github.com/elevate-project/samiksha-service/blob/main/config/db/elasticSearch.js"
  click C5 "https://github.com/elevate-project/samiksha-service/blob/main/config/kafkaConfig.js"
  click C6 "https://github.com/elevate-project/samiksha-service/blob/main/config/cloud-service.js"
  click CtrlV1 "https://github.com/elevate-project/samiksha-service/tree/main/controllers/v1/"
  click CtrlV2 "https://github.com/elevate-project/samiksha-service/tree/main/controllers/v2/"
  click CtrlV3 "https://github.com/elevate-project/samiksha-service/tree/main/controllers/v3/"
  click NodeR "https://github.com/elevate-project/samiksha-service/blob/main/routes/index.js"
  click Mods "https://github.com/elevate-project/samiksha-service/tree/main/module/"
  click Mdl "https://github.com/elevate-project/samiksha-service/tree/main/models/"
  click Qry "https://github.com/elevate-project/samiksha-service/tree/main/databaseQueries/"
  click H1 "https://github.com/elevate-project/samiksha-service/blob/main/generics/helpers/httpRequest.js"
  click KComm "https://github.com/elevate-project/samiksha-service/blob/main/generics/helpers/kafkaCommunications.js"
  click Svc "https://github.com/elevate-project/samiksha-service/tree/main/generics/services/"
  click Mid "https://github.com/elevate-project/samiksha-service/tree/main/generics/middleware/"
  click Cons "https://github.com/elevate-project/samiksha-service/blob/main/generics/kafkaConsumers/submissionRatingQueueConsumer.js"
  click HC1 "https://github.com/elevate-project/samiksha-service/blob/main/healthCheck/index.js"
  click HC2 "https://github.com/elevate-project/samiksha-service/blob/main/healthCheck/kafka.js"
  click HC3 "https://github.com/elevate-project/samiksha-service/blob/main/healthCheck/mongodb.js"
  click HC4 "https://github.com/elevate-project/samiksha-service/blob/main/healthCheck/elastic-search.js"
  click HC5 "https://github.com/elevate-project/samiksha-service/blob/main/healthCheck/improvement-project.js"
  click HC6 "https://github.com/elevate-project/samiksha-service/blob/main/healthCheck/kendra.js"
  click FS1 "https://github.com/elevate-project/samiksha-service/blob/main/generics/helpers/awsFileUpload.js"
  click FS2 "https://github.com/elevate-project/samiksha-service/blob/main/generics/helpers/gcpFileUpload.js"
  click FS3 "https://github.com/elevate-project/samiksha-service/blob/main/generics/helpers/azureFileUpload.js"
  click FSMod "https://github.com/elevate-project/samiksha-service/tree/main/module/cloud-services/files/"
```
