How tejas-952007/bhasa2code works
Bhasha2Code is an offline-first multilingual assistant for code generation, debugging, execution, and learning. A user submits a prompt through the browser; the backend manages session context, classifies language/tone/intent, builds a prompt, and requests local LLM generation. Generated code can be validated and run in an isolated sandbox, while the UI presents study explanations and manages saved work. The README documents the major tiers; several internal route-to-service connections are not shown in sampled source, so those links are documented rather than inferred from module names.
Main entry points: chat_stream.py Chat endpoints · nlp_pipeline.py NLP pipeline · api.js API client · code.py Code endpoints
Components 23
Browser experience
- Workspace app
frontend/src/App.jsx - Response renderer
frontend/src/components/response/ResponseRenderer.jsx - Code workspace
frontend/src/components/code/CodeArtifact.jsx - Study flowcharts
frontend/src/components/study/VisualFlowchart.jsx - API client
frontend/src/services/api.js
Backend API
- Chat endpoints
backend/app/api/routes/chat_stream.py - Code endpoints
backend/app/api/routes/code.py - Session endpoints
backend/app/api/routes/sessions.py
Language and generation
- NLP pipeline
backend/app/nlp/pipeline/nlp_pipeline.py - Language detection
backend/app/nlp/language_detection/language_detector.py - Text preprocessing
backend/app/nlp/preprocessing/text_preprocessor.py - Tone classification
backend/app/nlp/tone_classification/tone_classifier.py - Intent classification
backend/app/nlp/intent_classification/intent_classifier.py - Conversation context
backend/app/context/context_manager.py - Prompt builder
backend/app/prompt/prompt_builder.py - LLM service
backend/app/llm/llm_service.py
Code verification
- Response validator
backend/app/validation/response_validator.py - Sandbox runner
backend/app/sandbox/sandbox_runner.py
Local persistence
- Data repositories
backend/app/database/repositories - Local database
backend/app/database/engine.py
Other components
- Learner
- Local Ollama
- Docker runtime
Connections 27
- Learner → Workspace app: submits prompt
README.md - Workspace app → API client: requests data
frontend/src/App.jsx - API client → Chat endpoints: streams chat
README.md - Chat endpoints → NLP pipeline: analyzes input
- NLP pipeline → Text preprocessing: preprocesses text
backend/app/nlp/pipeline/nlp_pipeline.py - NLP pipeline → Language detection: detects language
backend/app/nlp/pipeline/nlp_pipeline.py - NLP pipeline → Tone classification: classifies tone
backend/app/nlp/pipeline/nlp_pipeline.py - NLP pipeline → Intent classification: classifies intent
backend/app/nlp/pipeline/nlp_pipeline.py - Chat endpoints → Conversation context: builds context
- Conversation context → Data repositories: retrieves history
backend/app/context/context_manager.py - Chat endpoints → Prompt builder: compiles prompt
- Prompt builder → LLM service: provides specification
backend/app/llm/llm_service.py - LLM service → Local Ollama: generates locally
README.md - Local Ollama → Response validator: returns generated text
README.md - Response validator → Chat endpoints: returns validated output
README.md - Chat endpoints → Response renderer: streams response
README.md - Response renderer → Code workspace: renders code
frontend/src/components/response/ResponseRenderer.jsx - Response renderer → Study flowcharts: renders study content
frontend/src/components/response/ResponseRenderer.jsx - Code workspace → API client: validates and runs
frontend/src/components/code/CodeArtifact.jsx - API client → Code endpoints: requests validation
README.md - Code endpoints → Response validator: validates code
README.md - Code endpoints → Sandbox runner: runs code
README.md - Sandbox runner → Docker runtime: executes isolated
README.md - Code endpoints → Code workspace: returns execution result
README.md - API client → Session endpoints: manages sessions
- Session endpoints → Data repositories: reads and writes
backend/app/api/routes/sessions.py - Data repositories → Local database: persists records
backend/app/database/engine.py